documentation.d.ts 3.0 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234
  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. /** Associative array from JSON sprite data file */
  11360. private _cellData;
  11361. /** Array of sprite names from JSON sprite data file */
  11362. private _spriteMap;
  11363. /** True when packed cell data from JSON file is ready*/
  11364. private _packedAndReady;
  11365. /**
  11366. * An event triggered when the manager is disposed.
  11367. */
  11368. onDisposeObservable: Observable<SpriteManager>;
  11369. private _onDisposeObserver;
  11370. /**
  11371. * Callback called when the manager is disposed
  11372. */
  11373. onDispose: () => void;
  11374. private _capacity;
  11375. private _fromPacked;
  11376. private _spriteTexture;
  11377. private _epsilon;
  11378. private _scene;
  11379. private _vertexData;
  11380. private _buffer;
  11381. private _vertexBuffers;
  11382. private _indexBuffer;
  11383. private _effectBase;
  11384. private _effectFog;
  11385. /**
  11386. * Gets or sets the spritesheet texture
  11387. */
  11388. texture: Texture;
  11389. /**
  11390. * Creates a new sprite manager
  11391. * @param name defines the manager's name
  11392. * @param imgUrl defines the sprite sheet url
  11393. * @param capacity defines the maximum allowed number of sprites
  11394. * @param cellSize defines the size of a sprite cell
  11395. * @param scene defines the hosting scene
  11396. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11397. * @param samplingMode defines the smapling mode to use with spritesheet
  11398. * @param fromPacked set to false; do not alter
  11399. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11400. */
  11401. constructor(
  11402. /** defines the manager's name */
  11403. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11404. private _makePacked;
  11405. private _appendSpriteVertex;
  11406. /**
  11407. * Intersects the sprites with a ray
  11408. * @param ray defines the ray to intersect with
  11409. * @param camera defines the current active camera
  11410. * @param predicate defines a predicate used to select candidate sprites
  11411. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11412. * @returns null if no hit or a PickingInfo
  11413. */
  11414. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11415. /**
  11416. * Render all child sprites
  11417. */
  11418. render(): void;
  11419. /**
  11420. * Release associated resources
  11421. */
  11422. dispose(): void;
  11423. }
  11424. }
  11425. declare module BABYLON {
  11426. /**
  11427. * Class used to represent a sprite
  11428. * @see http://doc.babylonjs.com/babylon101/sprites
  11429. */
  11430. export class Sprite {
  11431. /** defines the name */
  11432. name: string;
  11433. /** Gets or sets the current world position */
  11434. position: Vector3;
  11435. /** Gets or sets the main color */
  11436. color: Color4;
  11437. /** Gets or sets the width */
  11438. width: number;
  11439. /** Gets or sets the height */
  11440. height: number;
  11441. /** Gets or sets rotation angle */
  11442. angle: number;
  11443. /** Gets or sets the cell index in the sprite sheet */
  11444. cellIndex: number;
  11445. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11446. cellRef: string;
  11447. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11448. invertU: number;
  11449. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11450. invertV: number;
  11451. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11452. disposeWhenFinishedAnimating: boolean;
  11453. /** Gets the list of attached animations */
  11454. animations: Animation[];
  11455. /** Gets or sets a boolean indicating if the sprite can be picked */
  11456. isPickable: boolean;
  11457. /**
  11458. * Gets or sets the associated action manager
  11459. */
  11460. actionManager: Nullable<ActionManager>;
  11461. private _animationStarted;
  11462. private _loopAnimation;
  11463. private _fromIndex;
  11464. private _toIndex;
  11465. private _delay;
  11466. private _direction;
  11467. private _manager;
  11468. private _time;
  11469. private _onAnimationEnd;
  11470. /**
  11471. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11472. */
  11473. isVisible: boolean;
  11474. /**
  11475. * Gets or sets the sprite size
  11476. */
  11477. size: number;
  11478. /**
  11479. * Creates a new Sprite
  11480. * @param name defines the name
  11481. * @param manager defines the manager
  11482. */
  11483. constructor(
  11484. /** defines the name */
  11485. name: string, manager: ISpriteManager);
  11486. /**
  11487. * Starts an animation
  11488. * @param from defines the initial key
  11489. * @param to defines the end key
  11490. * @param loop defines if the animation must loop
  11491. * @param delay defines the start delay (in ms)
  11492. * @param onAnimationEnd defines a callback to call when animation ends
  11493. */
  11494. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11495. /** Stops current animation (if any) */
  11496. stopAnimation(): void;
  11497. /** @hidden */
  11498. _animate(deltaTime: number): void;
  11499. /** Release associated resources */
  11500. dispose(): void;
  11501. }
  11502. }
  11503. declare module BABYLON {
  11504. /**
  11505. * Information about the result of picking within a scene
  11506. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11507. */
  11508. export class PickingInfo {
  11509. /** @hidden */
  11510. _pickingUnavailable: boolean;
  11511. /**
  11512. * If the pick collided with an object
  11513. */
  11514. hit: boolean;
  11515. /**
  11516. * Distance away where the pick collided
  11517. */
  11518. distance: number;
  11519. /**
  11520. * The location of pick collision
  11521. */
  11522. pickedPoint: Nullable<Vector3>;
  11523. /**
  11524. * The mesh corresponding the the pick collision
  11525. */
  11526. pickedMesh: Nullable<AbstractMesh>;
  11527. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11528. bu: number;
  11529. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11530. bv: number;
  11531. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11532. faceId: number;
  11533. /** Id of the the submesh that was picked */
  11534. subMeshId: number;
  11535. /** If a sprite was picked, this will be the sprite the pick collided with */
  11536. pickedSprite: Nullable<Sprite>;
  11537. /**
  11538. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11539. */
  11540. originMesh: Nullable<AbstractMesh>;
  11541. /**
  11542. * The ray that was used to perform the picking.
  11543. */
  11544. ray: Nullable<Ray>;
  11545. /**
  11546. * Gets the normal correspodning to the face the pick collided with
  11547. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11548. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11549. * @returns The normal correspodning to the face the pick collided with
  11550. */
  11551. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11552. /**
  11553. * Gets the texture coordinates of where the pick occured
  11554. * @returns the vector containing the coordnates of the texture
  11555. */
  11556. getTextureCoordinates(): Nullable<Vector2>;
  11557. }
  11558. }
  11559. declare module BABYLON {
  11560. /**
  11561. * Gather the list of pointer event types as constants.
  11562. */
  11563. export class PointerEventTypes {
  11564. /**
  11565. * 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.
  11566. */
  11567. static readonly POINTERDOWN: number;
  11568. /**
  11569. * The pointerup event is fired when a pointer is no longer active.
  11570. */
  11571. static readonly POINTERUP: number;
  11572. /**
  11573. * The pointermove event is fired when a pointer changes coordinates.
  11574. */
  11575. static readonly POINTERMOVE: number;
  11576. /**
  11577. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11578. */
  11579. static readonly POINTERWHEEL: number;
  11580. /**
  11581. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11582. */
  11583. static readonly POINTERPICK: number;
  11584. /**
  11585. * The pointertap event is fired when a the object has been touched and released without drag.
  11586. */
  11587. static readonly POINTERTAP: number;
  11588. /**
  11589. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11590. */
  11591. static readonly POINTERDOUBLETAP: number;
  11592. }
  11593. /**
  11594. * Base class of pointer info types.
  11595. */
  11596. export class PointerInfoBase {
  11597. /**
  11598. * Defines the type of event (PointerEventTypes)
  11599. */
  11600. type: number;
  11601. /**
  11602. * Defines the related dom event
  11603. */
  11604. event: PointerEvent | MouseWheelEvent;
  11605. /**
  11606. * Instantiates the base class of pointers info.
  11607. * @param type Defines the type of event (PointerEventTypes)
  11608. * @param event Defines the related dom event
  11609. */
  11610. constructor(
  11611. /**
  11612. * Defines the type of event (PointerEventTypes)
  11613. */
  11614. type: number,
  11615. /**
  11616. * Defines the related dom event
  11617. */
  11618. event: PointerEvent | MouseWheelEvent);
  11619. }
  11620. /**
  11621. * This class is used to store pointer related info for the onPrePointerObservable event.
  11622. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11623. */
  11624. export class PointerInfoPre extends PointerInfoBase {
  11625. /**
  11626. * Ray from a pointer if availible (eg. 6dof controller)
  11627. */
  11628. ray: Nullable<Ray>;
  11629. /**
  11630. * Defines the local position of the pointer on the canvas.
  11631. */
  11632. localPosition: Vector2;
  11633. /**
  11634. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11635. */
  11636. skipOnPointerObservable: boolean;
  11637. /**
  11638. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11639. * @param type Defines the type of event (PointerEventTypes)
  11640. * @param event Defines the related dom event
  11641. * @param localX Defines the local x coordinates of the pointer when the event occured
  11642. * @param localY Defines the local y coordinates of the pointer when the event occured
  11643. */
  11644. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11645. }
  11646. /**
  11647. * This type contains all the data related to a pointer event in Babylon.js.
  11648. * 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.
  11649. */
  11650. export class PointerInfo extends PointerInfoBase {
  11651. /**
  11652. * Defines the picking info associated to the info (if any)\
  11653. */
  11654. pickInfo: Nullable<PickingInfo>;
  11655. /**
  11656. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11657. * @param type Defines the type of event (PointerEventTypes)
  11658. * @param event Defines the related dom event
  11659. * @param pickInfo Defines the picking info associated to the info (if any)\
  11660. */
  11661. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11662. /**
  11663. * Defines the picking info associated to the info (if any)\
  11664. */
  11665. pickInfo: Nullable<PickingInfo>);
  11666. }
  11667. /**
  11668. * Data relating to a touch event on the screen.
  11669. */
  11670. export interface PointerTouch {
  11671. /**
  11672. * X coordinate of touch.
  11673. */
  11674. x: number;
  11675. /**
  11676. * Y coordinate of touch.
  11677. */
  11678. y: number;
  11679. /**
  11680. * Id of touch. Unique for each finger.
  11681. */
  11682. pointerId: number;
  11683. /**
  11684. * Event type passed from DOM.
  11685. */
  11686. type: any;
  11687. }
  11688. }
  11689. declare module BABYLON {
  11690. /**
  11691. * Manage the mouse inputs to control the movement of a free camera.
  11692. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11693. */
  11694. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11695. /**
  11696. * Define if touch is enabled in the mouse input
  11697. */
  11698. touchEnabled: boolean;
  11699. /**
  11700. * Defines the camera the input is attached to.
  11701. */
  11702. camera: FreeCamera;
  11703. /**
  11704. * Defines the buttons associated with the input to handle camera move.
  11705. */
  11706. buttons: number[];
  11707. /**
  11708. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11709. */
  11710. angularSensibility: number;
  11711. private _pointerInput;
  11712. private _onMouseMove;
  11713. private _observer;
  11714. private previousPosition;
  11715. /**
  11716. * Observable for when a pointer move event occurs containing the move offset
  11717. */
  11718. onPointerMovedObservable: Observable<{
  11719. offsetX: number;
  11720. offsetY: number;
  11721. }>;
  11722. /**
  11723. * @hidden
  11724. * If the camera should be rotated automatically based on pointer movement
  11725. */
  11726. _allowCameraRotation: boolean;
  11727. /**
  11728. * Manage the mouse inputs to control the movement of a free camera.
  11729. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11730. * @param touchEnabled Defines if touch is enabled or not
  11731. */
  11732. constructor(
  11733. /**
  11734. * Define if touch is enabled in the mouse input
  11735. */
  11736. touchEnabled?: boolean);
  11737. /**
  11738. * Attach the input controls to a specific dom element to get the input from.
  11739. * @param element Defines the element the controls should be listened from
  11740. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11741. */
  11742. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11743. /**
  11744. * Called on JS contextmenu event.
  11745. * Override this method to provide functionality.
  11746. */
  11747. protected onContextMenu(evt: PointerEvent): void;
  11748. /**
  11749. * Detach the current controls from the specified dom element.
  11750. * @param element Defines the element to stop listening the inputs from
  11751. */
  11752. detachControl(element: Nullable<HTMLElement>): void;
  11753. /**
  11754. * Gets the class name of the current intput.
  11755. * @returns the class name
  11756. */
  11757. getClassName(): string;
  11758. /**
  11759. * Get the friendly name associated with the input class.
  11760. * @returns the input friendly name
  11761. */
  11762. getSimpleName(): string;
  11763. }
  11764. }
  11765. declare module BABYLON {
  11766. /**
  11767. * Manage the touch inputs to control the movement of a free camera.
  11768. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11769. */
  11770. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11771. /**
  11772. * Defines the camera the input is attached to.
  11773. */
  11774. camera: FreeCamera;
  11775. /**
  11776. * Defines the touch sensibility for rotation.
  11777. * The higher the faster.
  11778. */
  11779. touchAngularSensibility: number;
  11780. /**
  11781. * Defines the touch sensibility for move.
  11782. * The higher the faster.
  11783. */
  11784. touchMoveSensibility: number;
  11785. private _offsetX;
  11786. private _offsetY;
  11787. private _pointerPressed;
  11788. private _pointerInput;
  11789. private _observer;
  11790. private _onLostFocus;
  11791. /**
  11792. * Attach the input controls to a specific dom element to get the input from.
  11793. * @param element Defines the element the controls should be listened from
  11794. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11795. */
  11796. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11797. /**
  11798. * Detach the current controls from the specified dom element.
  11799. * @param element Defines the element to stop listening the inputs from
  11800. */
  11801. detachControl(element: Nullable<HTMLElement>): void;
  11802. /**
  11803. * Update the current camera state depending on the inputs that have been used this frame.
  11804. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11805. */
  11806. checkInputs(): void;
  11807. /**
  11808. * Gets the class name of the current intput.
  11809. * @returns the class name
  11810. */
  11811. getClassName(): string;
  11812. /**
  11813. * Get the friendly name associated with the input class.
  11814. * @returns the input friendly name
  11815. */
  11816. getSimpleName(): string;
  11817. }
  11818. }
  11819. declare module BABYLON {
  11820. /**
  11821. * Default Inputs manager for the FreeCamera.
  11822. * It groups all the default supported inputs for ease of use.
  11823. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11824. */
  11825. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11826. /**
  11827. * @hidden
  11828. */
  11829. _mouseInput: Nullable<FreeCameraMouseInput>;
  11830. /**
  11831. * Instantiates a new FreeCameraInputsManager.
  11832. * @param camera Defines the camera the inputs belong to
  11833. */
  11834. constructor(camera: FreeCamera);
  11835. /**
  11836. * Add keyboard input support to the input manager.
  11837. * @returns the current input manager
  11838. */
  11839. addKeyboard(): FreeCameraInputsManager;
  11840. /**
  11841. * Add mouse input support to the input manager.
  11842. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11843. * @returns the current input manager
  11844. */
  11845. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11846. /**
  11847. * Removes the mouse input support from the manager
  11848. * @returns the current input manager
  11849. */
  11850. removeMouse(): FreeCameraInputsManager;
  11851. /**
  11852. * Add touch input support to the input manager.
  11853. * @returns the current input manager
  11854. */
  11855. addTouch(): FreeCameraInputsManager;
  11856. /**
  11857. * Remove all attached input methods from a camera
  11858. */
  11859. clear(): void;
  11860. }
  11861. }
  11862. declare module BABYLON {
  11863. /**
  11864. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11865. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11866. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11867. */
  11868. export class FreeCamera extends TargetCamera {
  11869. /**
  11870. * Define the collision ellipsoid of the camera.
  11871. * This is helpful to simulate a camera body like the player body around the camera
  11872. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11873. */
  11874. ellipsoid: Vector3;
  11875. /**
  11876. * Define an offset for the position of the ellipsoid around the camera.
  11877. * This can be helpful to determine the center of the body near the gravity center of the body
  11878. * instead of its head.
  11879. */
  11880. ellipsoidOffset: Vector3;
  11881. /**
  11882. * Enable or disable collisions of the camera with the rest of the scene objects.
  11883. */
  11884. checkCollisions: boolean;
  11885. /**
  11886. * Enable or disable gravity on the camera.
  11887. */
  11888. applyGravity: boolean;
  11889. /**
  11890. * Define the input manager associated to the camera.
  11891. */
  11892. inputs: FreeCameraInputsManager;
  11893. /**
  11894. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11895. * Higher values reduce sensitivity.
  11896. */
  11897. /**
  11898. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11899. * Higher values reduce sensitivity.
  11900. */
  11901. angularSensibility: number;
  11902. /**
  11903. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11904. */
  11905. keysUp: number[];
  11906. /**
  11907. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11908. */
  11909. keysDown: number[];
  11910. /**
  11911. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11912. */
  11913. keysLeft: number[];
  11914. /**
  11915. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11916. */
  11917. keysRight: number[];
  11918. /**
  11919. * Event raised when the camera collide with a mesh in the scene.
  11920. */
  11921. onCollide: (collidedMesh: AbstractMesh) => void;
  11922. private _collider;
  11923. private _needMoveForGravity;
  11924. private _oldPosition;
  11925. private _diffPosition;
  11926. private _newPosition;
  11927. /** @hidden */
  11928. _localDirection: Vector3;
  11929. /** @hidden */
  11930. _transformedDirection: Vector3;
  11931. /**
  11932. * Instantiates a Free Camera.
  11933. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11934. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  11935. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11936. * @param name Define the name of the camera in the scene
  11937. * @param position Define the start position of the camera in the scene
  11938. * @param scene Define the scene the camera belongs to
  11939. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  11940. */
  11941. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  11942. /**
  11943. * Attached controls to the current camera.
  11944. * @param element Defines the element the controls should be listened from
  11945. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11946. */
  11947. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11948. /**
  11949. * Detach the current controls from the camera.
  11950. * The camera will stop reacting to inputs.
  11951. * @param element Defines the element to stop listening the inputs from
  11952. */
  11953. detachControl(element: HTMLElement): void;
  11954. private _collisionMask;
  11955. /**
  11956. * Define a collision mask to limit the list of object the camera can collide with
  11957. */
  11958. collisionMask: number;
  11959. /** @hidden */
  11960. _collideWithWorld(displacement: Vector3): void;
  11961. private _onCollisionPositionChange;
  11962. /** @hidden */
  11963. _checkInputs(): void;
  11964. /** @hidden */
  11965. _decideIfNeedsToMove(): boolean;
  11966. /** @hidden */
  11967. _updatePosition(): void;
  11968. /**
  11969. * Destroy the camera and release the current resources hold by it.
  11970. */
  11971. dispose(): void;
  11972. /**
  11973. * Gets the current object class name.
  11974. * @return the class name
  11975. */
  11976. getClassName(): string;
  11977. }
  11978. }
  11979. declare module BABYLON {
  11980. /**
  11981. * Represents a gamepad control stick position
  11982. */
  11983. export class StickValues {
  11984. /**
  11985. * The x component of the control stick
  11986. */
  11987. x: number;
  11988. /**
  11989. * The y component of the control stick
  11990. */
  11991. y: number;
  11992. /**
  11993. * Initializes the gamepad x and y control stick values
  11994. * @param x The x component of the gamepad control stick value
  11995. * @param y The y component of the gamepad control stick value
  11996. */
  11997. constructor(
  11998. /**
  11999. * The x component of the control stick
  12000. */
  12001. x: number,
  12002. /**
  12003. * The y component of the control stick
  12004. */
  12005. y: number);
  12006. }
  12007. /**
  12008. * An interface which manages callbacks for gamepad button changes
  12009. */
  12010. export interface GamepadButtonChanges {
  12011. /**
  12012. * Called when a gamepad has been changed
  12013. */
  12014. changed: boolean;
  12015. /**
  12016. * Called when a gamepad press event has been triggered
  12017. */
  12018. pressChanged: boolean;
  12019. /**
  12020. * Called when a touch event has been triggered
  12021. */
  12022. touchChanged: boolean;
  12023. /**
  12024. * Called when a value has changed
  12025. */
  12026. valueChanged: boolean;
  12027. }
  12028. /**
  12029. * Represents a gamepad
  12030. */
  12031. export class Gamepad {
  12032. /**
  12033. * The id of the gamepad
  12034. */
  12035. id: string;
  12036. /**
  12037. * The index of the gamepad
  12038. */
  12039. index: number;
  12040. /**
  12041. * The browser gamepad
  12042. */
  12043. browserGamepad: any;
  12044. /**
  12045. * Specifies what type of gamepad this represents
  12046. */
  12047. type: number;
  12048. private _leftStick;
  12049. private _rightStick;
  12050. /** @hidden */
  12051. _isConnected: boolean;
  12052. private _leftStickAxisX;
  12053. private _leftStickAxisY;
  12054. private _rightStickAxisX;
  12055. private _rightStickAxisY;
  12056. /**
  12057. * Triggered when the left control stick has been changed
  12058. */
  12059. private _onleftstickchanged;
  12060. /**
  12061. * Triggered when the right control stick has been changed
  12062. */
  12063. private _onrightstickchanged;
  12064. /**
  12065. * Represents a gamepad controller
  12066. */
  12067. static GAMEPAD: number;
  12068. /**
  12069. * Represents a generic controller
  12070. */
  12071. static GENERIC: number;
  12072. /**
  12073. * Represents an XBox controller
  12074. */
  12075. static XBOX: number;
  12076. /**
  12077. * Represents a pose-enabled controller
  12078. */
  12079. static POSE_ENABLED: number;
  12080. /**
  12081. * Represents an Dual Shock controller
  12082. */
  12083. static DUALSHOCK: number;
  12084. /**
  12085. * Specifies whether the left control stick should be Y-inverted
  12086. */
  12087. protected _invertLeftStickY: boolean;
  12088. /**
  12089. * Specifies if the gamepad has been connected
  12090. */
  12091. readonly isConnected: boolean;
  12092. /**
  12093. * Initializes the gamepad
  12094. * @param id The id of the gamepad
  12095. * @param index The index of the gamepad
  12096. * @param browserGamepad The browser gamepad
  12097. * @param leftStickX The x component of the left joystick
  12098. * @param leftStickY The y component of the left joystick
  12099. * @param rightStickX The x component of the right joystick
  12100. * @param rightStickY The y component of the right joystick
  12101. */
  12102. constructor(
  12103. /**
  12104. * The id of the gamepad
  12105. */
  12106. id: string,
  12107. /**
  12108. * The index of the gamepad
  12109. */
  12110. index: number,
  12111. /**
  12112. * The browser gamepad
  12113. */
  12114. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12115. /**
  12116. * Callback triggered when the left joystick has changed
  12117. * @param callback
  12118. */
  12119. onleftstickchanged(callback: (values: StickValues) => void): void;
  12120. /**
  12121. * Callback triggered when the right joystick has changed
  12122. * @param callback
  12123. */
  12124. onrightstickchanged(callback: (values: StickValues) => void): void;
  12125. /**
  12126. * Gets the left joystick
  12127. */
  12128. /**
  12129. * Sets the left joystick values
  12130. */
  12131. leftStick: StickValues;
  12132. /**
  12133. * Gets the right joystick
  12134. */
  12135. /**
  12136. * Sets the right joystick value
  12137. */
  12138. rightStick: StickValues;
  12139. /**
  12140. * Updates the gamepad joystick positions
  12141. */
  12142. update(): void;
  12143. /**
  12144. * Disposes the gamepad
  12145. */
  12146. dispose(): void;
  12147. }
  12148. /**
  12149. * Represents a generic gamepad
  12150. */
  12151. export class GenericPad extends Gamepad {
  12152. private _buttons;
  12153. private _onbuttondown;
  12154. private _onbuttonup;
  12155. /**
  12156. * Observable triggered when a button has been pressed
  12157. */
  12158. onButtonDownObservable: Observable<number>;
  12159. /**
  12160. * Observable triggered when a button has been released
  12161. */
  12162. onButtonUpObservable: Observable<number>;
  12163. /**
  12164. * Callback triggered when a button has been pressed
  12165. * @param callback Called when a button has been pressed
  12166. */
  12167. onbuttondown(callback: (buttonPressed: number) => void): void;
  12168. /**
  12169. * Callback triggered when a button has been released
  12170. * @param callback Called when a button has been released
  12171. */
  12172. onbuttonup(callback: (buttonReleased: number) => void): void;
  12173. /**
  12174. * Initializes the generic gamepad
  12175. * @param id The id of the generic gamepad
  12176. * @param index The index of the generic gamepad
  12177. * @param browserGamepad The browser gamepad
  12178. */
  12179. constructor(id: string, index: number, browserGamepad: any);
  12180. private _setButtonValue;
  12181. /**
  12182. * Updates the generic gamepad
  12183. */
  12184. update(): void;
  12185. /**
  12186. * Disposes the generic gamepad
  12187. */
  12188. dispose(): void;
  12189. }
  12190. }
  12191. declare module BABYLON {
  12192. interface Engine {
  12193. /**
  12194. * Creates a raw texture
  12195. * @param data defines the data to store in the texture
  12196. * @param width defines the width of the texture
  12197. * @param height defines the height of the texture
  12198. * @param format defines the format of the data
  12199. * @param generateMipMaps defines if the engine should generate the mip levels
  12200. * @param invertY defines if data must be stored with Y axis inverted
  12201. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12202. * @param compression defines the compression used (null by default)
  12203. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12204. * @returns the raw texture inside an InternalTexture
  12205. */
  12206. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12207. /**
  12208. * Update a raw texture
  12209. * @param texture defines the texture to update
  12210. * @param data defines the data to store in the texture
  12211. * @param format defines the format of the data
  12212. * @param invertY defines if data must be stored with Y axis inverted
  12213. */
  12214. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12215. /**
  12216. * Update a raw texture
  12217. * @param texture defines the texture to update
  12218. * @param data defines the data to store in the texture
  12219. * @param format defines the format of the data
  12220. * @param invertY defines if data must be stored with Y axis inverted
  12221. * @param compression defines the compression used (null by default)
  12222. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12223. */
  12224. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12225. /**
  12226. * Creates a new raw cube texture
  12227. * @param data defines the array of data to use to create each face
  12228. * @param size defines the size of the textures
  12229. * @param format defines the format of the data
  12230. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12231. * @param generateMipMaps defines if the engine should generate the mip levels
  12232. * @param invertY defines if data must be stored with Y axis inverted
  12233. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12234. * @param compression defines the compression used (null by default)
  12235. * @returns the cube texture as an InternalTexture
  12236. */
  12237. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12238. /**
  12239. * Update a raw cube texture
  12240. * @param texture defines the texture to udpdate
  12241. * @param data defines the data to store
  12242. * @param format defines the data format
  12243. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12244. * @param invertY defines if data must be stored with Y axis inverted
  12245. */
  12246. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12247. /**
  12248. * Update a raw cube texture
  12249. * @param texture defines the texture to udpdate
  12250. * @param data defines the data to store
  12251. * @param format defines the data format
  12252. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12253. * @param invertY defines if data must be stored with Y axis inverted
  12254. * @param compression defines the compression used (null by default)
  12255. */
  12256. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12257. /**
  12258. * Update a raw cube texture
  12259. * @param texture defines the texture to udpdate
  12260. * @param data defines the data to store
  12261. * @param format defines the data format
  12262. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12263. * @param invertY defines if data must be stored with Y axis inverted
  12264. * @param compression defines the compression used (null by default)
  12265. * @param level defines which level of the texture to update
  12266. */
  12267. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12268. /**
  12269. * Creates a new raw cube texture from a specified url
  12270. * @param url defines the url where the data is located
  12271. * @param scene defines the current scene
  12272. * @param size defines the size of the textures
  12273. * @param format defines the format of the data
  12274. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12275. * @param noMipmap defines if the engine should avoid generating the mip levels
  12276. * @param callback defines a callback used to extract texture data from loaded data
  12277. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12278. * @param onLoad defines a callback called when texture is loaded
  12279. * @param onError defines a callback called if there is an error
  12280. * @returns the cube texture as an InternalTexture
  12281. */
  12282. 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;
  12283. /**
  12284. * Creates a new raw cube texture from a specified url
  12285. * @param url defines the url where the data is located
  12286. * @param scene defines the current scene
  12287. * @param size defines the size of the textures
  12288. * @param format defines the format of the data
  12289. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12290. * @param noMipmap defines if the engine should avoid generating the mip levels
  12291. * @param callback defines a callback used to extract texture data from loaded data
  12292. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12293. * @param onLoad defines a callback called when texture is loaded
  12294. * @param onError defines a callback called if there is an error
  12295. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12296. * @param invertY defines if data must be stored with Y axis inverted
  12297. * @returns the cube texture as an InternalTexture
  12298. */
  12299. 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;
  12300. /**
  12301. * Creates a new raw 3D texture
  12302. * @param data defines the data used to create the texture
  12303. * @param width defines the width of the texture
  12304. * @param height defines the height of the texture
  12305. * @param depth defines the depth of the texture
  12306. * @param format defines the format of the texture
  12307. * @param generateMipMaps defines if the engine must generate mip levels
  12308. * @param invertY defines if data must be stored with Y axis inverted
  12309. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12310. * @param compression defines the compressed used (can be null)
  12311. * @param textureType defines the compressed used (can be null)
  12312. * @returns a new raw 3D texture (stored in an InternalTexture)
  12313. */
  12314. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12315. /**
  12316. * Update a raw 3D texture
  12317. * @param texture defines the texture to update
  12318. * @param data defines the data to store
  12319. * @param format defines the data format
  12320. * @param invertY defines if data must be stored with Y axis inverted
  12321. */
  12322. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12323. /**
  12324. * Update a raw 3D texture
  12325. * @param texture defines the texture to update
  12326. * @param data defines the data to store
  12327. * @param format defines the data format
  12328. * @param invertY defines if data must be stored with Y axis inverted
  12329. * @param compression defines the used compression (can be null)
  12330. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12331. */
  12332. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12333. }
  12334. }
  12335. declare module BABYLON {
  12336. /**
  12337. * Raw texture can help creating a texture directly from an array of data.
  12338. * This can be super useful if you either get the data from an uncompressed source or
  12339. * if you wish to create your texture pixel by pixel.
  12340. */
  12341. export class RawTexture extends Texture {
  12342. /**
  12343. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12344. */
  12345. format: number;
  12346. private _engine;
  12347. /**
  12348. * Instantiates a new RawTexture.
  12349. * Raw texture can help creating a texture directly from an array of data.
  12350. * This can be super useful if you either get the data from an uncompressed source or
  12351. * if you wish to create your texture pixel by pixel.
  12352. * @param data define the array of data to use to create the texture
  12353. * @param width define the width of the texture
  12354. * @param height define the height of the texture
  12355. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12356. * @param scene define the scene the texture belongs to
  12357. * @param generateMipMaps define whether mip maps should be generated or not
  12358. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12359. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12360. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12361. */
  12362. constructor(data: ArrayBufferView, width: number, height: number,
  12363. /**
  12364. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12365. */
  12366. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12367. /**
  12368. * Updates the texture underlying data.
  12369. * @param data Define the new data of the texture
  12370. */
  12371. update(data: ArrayBufferView): void;
  12372. /**
  12373. * Creates a luminance texture from some data.
  12374. * @param data Define the texture data
  12375. * @param width Define the width of the texture
  12376. * @param height Define the height of the texture
  12377. * @param scene Define the scene the texture belongs to
  12378. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12379. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12380. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12381. * @returns the luminance texture
  12382. */
  12383. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12384. /**
  12385. * Creates a luminance alpha texture from some data.
  12386. * @param data Define the texture data
  12387. * @param width Define the width of the texture
  12388. * @param height Define the height of the texture
  12389. * @param scene Define the scene the texture belongs to
  12390. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12391. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12392. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12393. * @returns the luminance alpha texture
  12394. */
  12395. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12396. /**
  12397. * Creates an alpha texture from some data.
  12398. * @param data Define the texture data
  12399. * @param width Define the width of the texture
  12400. * @param height Define the height of the texture
  12401. * @param scene Define the scene the texture belongs to
  12402. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12403. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12404. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12405. * @returns the alpha texture
  12406. */
  12407. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12408. /**
  12409. * Creates a RGB texture from some data.
  12410. * @param data Define the texture data
  12411. * @param width Define the width of the texture
  12412. * @param height Define the height of the texture
  12413. * @param scene Define the scene the texture belongs to
  12414. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12415. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12416. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12417. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12418. * @returns the RGB alpha texture
  12419. */
  12420. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12421. /**
  12422. * Creates a RGBA texture from some data.
  12423. * @param data Define the texture data
  12424. * @param width Define the width of the texture
  12425. * @param height Define the height of the texture
  12426. * @param scene Define the scene the texture belongs to
  12427. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12428. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12429. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12430. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12431. * @returns the RGBA texture
  12432. */
  12433. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12434. /**
  12435. * Creates a R texture from some data.
  12436. * @param data Define the texture data
  12437. * @param width Define the width of the texture
  12438. * @param height Define the height of the texture
  12439. * @param scene Define the scene the texture belongs to
  12440. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12441. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12442. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12443. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12444. * @returns the R texture
  12445. */
  12446. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12447. }
  12448. }
  12449. declare module BABYLON {
  12450. /**
  12451. * Interface for the size containing width and height
  12452. */
  12453. export interface ISize {
  12454. /**
  12455. * Width
  12456. */
  12457. width: number;
  12458. /**
  12459. * Heighht
  12460. */
  12461. height: number;
  12462. }
  12463. /**
  12464. * Size containing widht and height
  12465. */
  12466. export class Size implements ISize {
  12467. /**
  12468. * Width
  12469. */
  12470. width: number;
  12471. /**
  12472. * Height
  12473. */
  12474. height: number;
  12475. /**
  12476. * Creates a Size object from the given width and height (floats).
  12477. * @param width width of the new size
  12478. * @param height height of the new size
  12479. */
  12480. constructor(width: number, height: number);
  12481. /**
  12482. * Returns a string with the Size width and height
  12483. * @returns a string with the Size width and height
  12484. */
  12485. toString(): string;
  12486. /**
  12487. * "Size"
  12488. * @returns the string "Size"
  12489. */
  12490. getClassName(): string;
  12491. /**
  12492. * Returns the Size hash code.
  12493. * @returns a hash code for a unique width and height
  12494. */
  12495. getHashCode(): number;
  12496. /**
  12497. * Updates the current size from the given one.
  12498. * @param src the given size
  12499. */
  12500. copyFrom(src: Size): void;
  12501. /**
  12502. * Updates in place the current Size from the given floats.
  12503. * @param width width of the new size
  12504. * @param height height of the new size
  12505. * @returns the updated Size.
  12506. */
  12507. copyFromFloats(width: number, height: number): Size;
  12508. /**
  12509. * Updates in place the current Size from the given floats.
  12510. * @param width width to set
  12511. * @param height height to set
  12512. * @returns the updated Size.
  12513. */
  12514. set(width: number, height: number): Size;
  12515. /**
  12516. * Multiplies the width and height by numbers
  12517. * @param w factor to multiple the width by
  12518. * @param h factor to multiple the height by
  12519. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12520. */
  12521. multiplyByFloats(w: number, h: number): Size;
  12522. /**
  12523. * Clones the size
  12524. * @returns a new Size copied from the given one.
  12525. */
  12526. clone(): Size;
  12527. /**
  12528. * True if the current Size and the given one width and height are strictly equal.
  12529. * @param other the other size to compare against
  12530. * @returns True if the current Size and the given one width and height are strictly equal.
  12531. */
  12532. equals(other: Size): boolean;
  12533. /**
  12534. * The surface of the Size : width * height (float).
  12535. */
  12536. readonly surface: number;
  12537. /**
  12538. * Create a new size of zero
  12539. * @returns a new Size set to (0.0, 0.0)
  12540. */
  12541. static Zero(): Size;
  12542. /**
  12543. * Sums the width and height of two sizes
  12544. * @param otherSize size to add to this size
  12545. * @returns a new Size set as the addition result of the current Size and the given one.
  12546. */
  12547. add(otherSize: Size): Size;
  12548. /**
  12549. * Subtracts the width and height of two
  12550. * @param otherSize size to subtract to this size
  12551. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12552. */
  12553. subtract(otherSize: Size): Size;
  12554. /**
  12555. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12556. * @param start starting size to lerp between
  12557. * @param end end size to lerp between
  12558. * @param amount amount to lerp between the start and end values
  12559. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12560. */
  12561. static Lerp(start: Size, end: Size, amount: number): Size;
  12562. }
  12563. }
  12564. declare module BABYLON {
  12565. /**
  12566. * Defines a runtime animation
  12567. */
  12568. export class RuntimeAnimation {
  12569. private _events;
  12570. /**
  12571. * The current frame of the runtime animation
  12572. */
  12573. private _currentFrame;
  12574. /**
  12575. * The animation used by the runtime animation
  12576. */
  12577. private _animation;
  12578. /**
  12579. * The target of the runtime animation
  12580. */
  12581. private _target;
  12582. /**
  12583. * The initiating animatable
  12584. */
  12585. private _host;
  12586. /**
  12587. * The original value of the runtime animation
  12588. */
  12589. private _originalValue;
  12590. /**
  12591. * The original blend value of the runtime animation
  12592. */
  12593. private _originalBlendValue;
  12594. /**
  12595. * The offsets cache of the runtime animation
  12596. */
  12597. private _offsetsCache;
  12598. /**
  12599. * The high limits cache of the runtime animation
  12600. */
  12601. private _highLimitsCache;
  12602. /**
  12603. * Specifies if the runtime animation has been stopped
  12604. */
  12605. private _stopped;
  12606. /**
  12607. * The blending factor of the runtime animation
  12608. */
  12609. private _blendingFactor;
  12610. /**
  12611. * The BabylonJS scene
  12612. */
  12613. private _scene;
  12614. /**
  12615. * The current value of the runtime animation
  12616. */
  12617. private _currentValue;
  12618. /** @hidden */
  12619. _animationState: _IAnimationState;
  12620. /**
  12621. * The active target of the runtime animation
  12622. */
  12623. private _activeTargets;
  12624. private _currentActiveTarget;
  12625. private _directTarget;
  12626. /**
  12627. * The target path of the runtime animation
  12628. */
  12629. private _targetPath;
  12630. /**
  12631. * The weight of the runtime animation
  12632. */
  12633. private _weight;
  12634. /**
  12635. * The ratio offset of the runtime animation
  12636. */
  12637. private _ratioOffset;
  12638. /**
  12639. * The previous delay of the runtime animation
  12640. */
  12641. private _previousDelay;
  12642. /**
  12643. * The previous ratio of the runtime animation
  12644. */
  12645. private _previousRatio;
  12646. private _enableBlending;
  12647. private _keys;
  12648. private _minFrame;
  12649. private _maxFrame;
  12650. private _minValue;
  12651. private _maxValue;
  12652. private _targetIsArray;
  12653. /**
  12654. * Gets the current frame of the runtime animation
  12655. */
  12656. readonly currentFrame: number;
  12657. /**
  12658. * Gets the weight of the runtime animation
  12659. */
  12660. readonly weight: number;
  12661. /**
  12662. * Gets the current value of the runtime animation
  12663. */
  12664. readonly currentValue: any;
  12665. /**
  12666. * Gets the target path of the runtime animation
  12667. */
  12668. readonly targetPath: string;
  12669. /**
  12670. * Gets the actual target of the runtime animation
  12671. */
  12672. readonly target: any;
  12673. /** @hidden */
  12674. _onLoop: () => void;
  12675. /**
  12676. * Create a new RuntimeAnimation object
  12677. * @param target defines the target of the animation
  12678. * @param animation defines the source animation object
  12679. * @param scene defines the hosting scene
  12680. * @param host defines the initiating Animatable
  12681. */
  12682. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12683. private _preparePath;
  12684. /**
  12685. * Gets the animation from the runtime animation
  12686. */
  12687. readonly animation: Animation;
  12688. /**
  12689. * Resets the runtime animation to the beginning
  12690. * @param restoreOriginal defines whether to restore the target property to the original value
  12691. */
  12692. reset(restoreOriginal?: boolean): void;
  12693. /**
  12694. * Specifies if the runtime animation is stopped
  12695. * @returns Boolean specifying if the runtime animation is stopped
  12696. */
  12697. isStopped(): boolean;
  12698. /**
  12699. * Disposes of the runtime animation
  12700. */
  12701. dispose(): void;
  12702. /**
  12703. * Apply the interpolated value to the target
  12704. * @param currentValue defines the value computed by the animation
  12705. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12706. */
  12707. setValue(currentValue: any, weight: number): void;
  12708. private _getOriginalValues;
  12709. private _setValue;
  12710. /**
  12711. * Gets the loop pmode of the runtime animation
  12712. * @returns Loop Mode
  12713. */
  12714. private _getCorrectLoopMode;
  12715. /**
  12716. * Move the current animation to a given frame
  12717. * @param frame defines the frame to move to
  12718. */
  12719. goToFrame(frame: number): void;
  12720. /**
  12721. * @hidden Internal use only
  12722. */
  12723. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12724. /**
  12725. * Execute the current animation
  12726. * @param delay defines the delay to add to the current frame
  12727. * @param from defines the lower bound of the animation range
  12728. * @param to defines the upper bound of the animation range
  12729. * @param loop defines if the current animation must loop
  12730. * @param speedRatio defines the current speed ratio
  12731. * @param weight defines the weight of the animation (default is -1 so no weight)
  12732. * @param onLoop optional callback called when animation loops
  12733. * @returns a boolean indicating if the animation is running
  12734. */
  12735. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12736. }
  12737. }
  12738. declare module BABYLON {
  12739. /**
  12740. * Class used to store an actual running animation
  12741. */
  12742. export class Animatable {
  12743. /** defines the target object */
  12744. target: any;
  12745. /** defines the starting frame number (default is 0) */
  12746. fromFrame: number;
  12747. /** defines the ending frame number (default is 100) */
  12748. toFrame: number;
  12749. /** defines if the animation must loop (default is false) */
  12750. loopAnimation: boolean;
  12751. /** defines a callback to call when animation ends if it is not looping */
  12752. onAnimationEnd?: (() => void) | null | undefined;
  12753. /** defines a callback to call when animation loops */
  12754. onAnimationLoop?: (() => void) | null | undefined;
  12755. private _localDelayOffset;
  12756. private _pausedDelay;
  12757. private _runtimeAnimations;
  12758. private _paused;
  12759. private _scene;
  12760. private _speedRatio;
  12761. private _weight;
  12762. private _syncRoot;
  12763. /**
  12764. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12765. * This will only apply for non looping animation (default is true)
  12766. */
  12767. disposeOnEnd: boolean;
  12768. /**
  12769. * Gets a boolean indicating if the animation has started
  12770. */
  12771. animationStarted: boolean;
  12772. /**
  12773. * Observer raised when the animation ends
  12774. */
  12775. onAnimationEndObservable: Observable<Animatable>;
  12776. /**
  12777. * Observer raised when the animation loops
  12778. */
  12779. onAnimationLoopObservable: Observable<Animatable>;
  12780. /**
  12781. * Gets the root Animatable used to synchronize and normalize animations
  12782. */
  12783. readonly syncRoot: Nullable<Animatable>;
  12784. /**
  12785. * Gets the current frame of the first RuntimeAnimation
  12786. * Used to synchronize Animatables
  12787. */
  12788. readonly masterFrame: number;
  12789. /**
  12790. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12791. */
  12792. weight: number;
  12793. /**
  12794. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12795. */
  12796. speedRatio: number;
  12797. /**
  12798. * Creates a new Animatable
  12799. * @param scene defines the hosting scene
  12800. * @param target defines the target object
  12801. * @param fromFrame defines the starting frame number (default is 0)
  12802. * @param toFrame defines the ending frame number (default is 100)
  12803. * @param loopAnimation defines if the animation must loop (default is false)
  12804. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12805. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12806. * @param animations defines a group of animation to add to the new Animatable
  12807. * @param onAnimationLoop defines a callback to call when animation loops
  12808. */
  12809. constructor(scene: Scene,
  12810. /** defines the target object */
  12811. target: any,
  12812. /** defines the starting frame number (default is 0) */
  12813. fromFrame?: number,
  12814. /** defines the ending frame number (default is 100) */
  12815. toFrame?: number,
  12816. /** defines if the animation must loop (default is false) */
  12817. loopAnimation?: boolean, speedRatio?: number,
  12818. /** defines a callback to call when animation ends if it is not looping */
  12819. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12820. /** defines a callback to call when animation loops */
  12821. onAnimationLoop?: (() => void) | null | undefined);
  12822. /**
  12823. * Synchronize and normalize current Animatable with a source Animatable
  12824. * This is useful when using animation weights and when animations are not of the same length
  12825. * @param root defines the root Animatable to synchronize with
  12826. * @returns the current Animatable
  12827. */
  12828. syncWith(root: Animatable): Animatable;
  12829. /**
  12830. * Gets the list of runtime animations
  12831. * @returns an array of RuntimeAnimation
  12832. */
  12833. getAnimations(): RuntimeAnimation[];
  12834. /**
  12835. * Adds more animations to the current animatable
  12836. * @param target defines the target of the animations
  12837. * @param animations defines the new animations to add
  12838. */
  12839. appendAnimations(target: any, animations: Animation[]): void;
  12840. /**
  12841. * Gets the source animation for a specific property
  12842. * @param property defines the propertyu to look for
  12843. * @returns null or the source animation for the given property
  12844. */
  12845. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12846. /**
  12847. * Gets the runtime animation for a specific property
  12848. * @param property defines the propertyu to look for
  12849. * @returns null or the runtime animation for the given property
  12850. */
  12851. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12852. /**
  12853. * Resets the animatable to its original state
  12854. */
  12855. reset(): void;
  12856. /**
  12857. * Allows the animatable to blend with current running animations
  12858. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12859. * @param blendingSpeed defines the blending speed to use
  12860. */
  12861. enableBlending(blendingSpeed: number): void;
  12862. /**
  12863. * Disable animation blending
  12864. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12865. */
  12866. disableBlending(): void;
  12867. /**
  12868. * Jump directly to a given frame
  12869. * @param frame defines the frame to jump to
  12870. */
  12871. goToFrame(frame: number): void;
  12872. /**
  12873. * Pause the animation
  12874. */
  12875. pause(): void;
  12876. /**
  12877. * Restart the animation
  12878. */
  12879. restart(): void;
  12880. private _raiseOnAnimationEnd;
  12881. /**
  12882. * Stop and delete the current animation
  12883. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12884. * @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)
  12885. */
  12886. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  12887. /**
  12888. * Wait asynchronously for the animation to end
  12889. * @returns a promise which will be fullfilled when the animation ends
  12890. */
  12891. waitAsync(): Promise<Animatable>;
  12892. /** @hidden */
  12893. _animate(delay: number): boolean;
  12894. }
  12895. interface Scene {
  12896. /** @hidden */
  12897. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  12898. /** @hidden */
  12899. _processLateAnimationBindingsForMatrices(holder: {
  12900. totalWeight: number;
  12901. animations: RuntimeAnimation[];
  12902. originalValue: Matrix;
  12903. }): any;
  12904. /** @hidden */
  12905. _processLateAnimationBindingsForQuaternions(holder: {
  12906. totalWeight: number;
  12907. animations: RuntimeAnimation[];
  12908. originalValue: Quaternion;
  12909. }, refQuaternion: Quaternion): Quaternion;
  12910. /** @hidden */
  12911. _processLateAnimationBindings(): void;
  12912. /**
  12913. * Will start the animation sequence of a given target
  12914. * @param target defines the target
  12915. * @param from defines from which frame should animation start
  12916. * @param to defines until which frame should animation run.
  12917. * @param weight defines the weight to apply to the animation (1.0 by default)
  12918. * @param loop defines if the animation loops
  12919. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12920. * @param onAnimationEnd defines the function to be executed when the animation ends
  12921. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12922. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12923. * @param onAnimationLoop defines the callback to call when an animation loops
  12924. * @returns the animatable object created for this animation
  12925. */
  12926. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12927. /**
  12928. * Will start the animation sequence of a given target
  12929. * @param target defines the target
  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 animate 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 animatable object created for this animation
  12940. */
  12941. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12942. /**
  12943. * Will start the animation sequence of a given target and its hierarchy
  12944. * @param target defines the target
  12945. * @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.
  12946. * @param from defines from which frame should animation start
  12947. * @param to defines until which frame should animation run.
  12948. * @param loop defines if the animation loops
  12949. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12950. * @param onAnimationEnd defines the function to be executed when the animation ends
  12951. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12952. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12953. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12954. * @param onAnimationLoop defines the callback to call when an animation loops
  12955. * @returns the list of created animatables
  12956. */
  12957. 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[];
  12958. /**
  12959. * Begin a new animation on a given node
  12960. * @param target defines the target where the animation will take place
  12961. * @param animations defines the list of animations to start
  12962. * @param from defines the initial value
  12963. * @param to defines the final value
  12964. * @param loop defines if you want animation to loop (off by default)
  12965. * @param speedRatio defines the speed ratio to apply to all animations
  12966. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12967. * @param onAnimationLoop defines the callback to call when an animation loops
  12968. * @returns the list of created animatables
  12969. */
  12970. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  12971. /**
  12972. * Begin a new animation on a given node and its hierarchy
  12973. * @param target defines the root node where the animation will take place
  12974. * @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.
  12975. * @param animations defines the list of animations to start
  12976. * @param from defines the initial value
  12977. * @param to defines the final value
  12978. * @param loop defines if you want animation to loop (off by default)
  12979. * @param speedRatio defines the speed ratio to apply to all animations
  12980. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12981. * @param onAnimationLoop defines the callback to call when an animation loops
  12982. * @returns the list of animatables created for all nodes
  12983. */
  12984. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  12985. /**
  12986. * Gets the animatable associated with a specific target
  12987. * @param target defines the target of the animatable
  12988. * @returns the required animatable if found
  12989. */
  12990. getAnimatableByTarget(target: any): Nullable<Animatable>;
  12991. /**
  12992. * Gets all animatables associated with a given target
  12993. * @param target defines the target to look animatables for
  12994. * @returns an array of Animatables
  12995. */
  12996. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  12997. /**
  12998. * Stops and removes all animations that have been applied to the scene
  12999. */
  13000. stopAllAnimations(): void;
  13001. }
  13002. interface Bone {
  13003. /**
  13004. * Copy an animation range from another bone
  13005. * @param source defines the source bone
  13006. * @param rangeName defines the range name to copy
  13007. * @param frameOffset defines the frame offset
  13008. * @param rescaleAsRequired defines if rescaling must be applied if required
  13009. * @param skelDimensionsRatio defines the scaling ratio
  13010. * @returns true if operation was successful
  13011. */
  13012. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13013. }
  13014. }
  13015. declare module BABYLON {
  13016. /**
  13017. * Class used to override all child animations of a given target
  13018. */
  13019. export class AnimationPropertiesOverride {
  13020. /**
  13021. * Gets or sets a value indicating if animation blending must be used
  13022. */
  13023. enableBlending: boolean;
  13024. /**
  13025. * Gets or sets the blending speed to use when enableBlending is true
  13026. */
  13027. blendingSpeed: number;
  13028. /**
  13029. * Gets or sets the default loop mode to use
  13030. */
  13031. loopMode: number;
  13032. }
  13033. }
  13034. declare module BABYLON {
  13035. /**
  13036. * Class used to handle skinning animations
  13037. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13038. */
  13039. export class Skeleton implements IAnimatable {
  13040. /** defines the skeleton name */
  13041. name: string;
  13042. /** defines the skeleton Id */
  13043. id: string;
  13044. /**
  13045. * Defines the list of child bones
  13046. */
  13047. bones: Bone[];
  13048. /**
  13049. * Defines an estimate of the dimension of the skeleton at rest
  13050. */
  13051. dimensionsAtRest: Vector3;
  13052. /**
  13053. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13054. */
  13055. needInitialSkinMatrix: boolean;
  13056. /**
  13057. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13058. */
  13059. overrideMesh: Nullable<AbstractMesh>;
  13060. /**
  13061. * Gets the list of animations attached to this skeleton
  13062. */
  13063. animations: Array<Animation>;
  13064. private _scene;
  13065. private _isDirty;
  13066. private _transformMatrices;
  13067. private _transformMatrixTexture;
  13068. private _meshesWithPoseMatrix;
  13069. private _animatables;
  13070. private _identity;
  13071. private _synchronizedWithMesh;
  13072. private _ranges;
  13073. private _lastAbsoluteTransformsUpdateId;
  13074. private _canUseTextureForBones;
  13075. private _uniqueId;
  13076. /** @hidden */
  13077. _numBonesWithLinkedTransformNode: number;
  13078. /** @hidden */
  13079. _hasWaitingData: Nullable<boolean>;
  13080. /**
  13081. * Specifies if the skeleton should be serialized
  13082. */
  13083. doNotSerialize: boolean;
  13084. private _useTextureToStoreBoneMatrices;
  13085. /**
  13086. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13087. * Please note that this option is not available if the hardware does not support it
  13088. */
  13089. useTextureToStoreBoneMatrices: boolean;
  13090. private _animationPropertiesOverride;
  13091. /**
  13092. * Gets or sets the animation properties override
  13093. */
  13094. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13095. /**
  13096. * List of inspectable custom properties (used by the Inspector)
  13097. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13098. */
  13099. inspectableCustomProperties: IInspectable[];
  13100. /**
  13101. * An observable triggered before computing the skeleton's matrices
  13102. */
  13103. onBeforeComputeObservable: Observable<Skeleton>;
  13104. /**
  13105. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13106. */
  13107. readonly isUsingTextureForMatrices: boolean;
  13108. /**
  13109. * Gets the unique ID of this skeleton
  13110. */
  13111. readonly uniqueId: number;
  13112. /**
  13113. * Creates a new skeleton
  13114. * @param name defines the skeleton name
  13115. * @param id defines the skeleton Id
  13116. * @param scene defines the hosting scene
  13117. */
  13118. constructor(
  13119. /** defines the skeleton name */
  13120. name: string,
  13121. /** defines the skeleton Id */
  13122. id: string, scene: Scene);
  13123. /**
  13124. * Gets the current object class name.
  13125. * @return the class name
  13126. */
  13127. getClassName(): string;
  13128. /**
  13129. * Returns an array containing the root bones
  13130. * @returns an array containing the root bones
  13131. */
  13132. getChildren(): Array<Bone>;
  13133. /**
  13134. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13135. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13136. * @returns a Float32Array containing matrices data
  13137. */
  13138. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13139. /**
  13140. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13141. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13142. * @returns a raw texture containing the data
  13143. */
  13144. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13145. /**
  13146. * Gets the current hosting scene
  13147. * @returns a scene object
  13148. */
  13149. getScene(): Scene;
  13150. /**
  13151. * Gets a string representing the current skeleton data
  13152. * @param fullDetails defines a boolean indicating if we want a verbose version
  13153. * @returns a string representing the current skeleton data
  13154. */
  13155. toString(fullDetails?: boolean): string;
  13156. /**
  13157. * Get bone's index searching by name
  13158. * @param name defines bone's name to search for
  13159. * @return the indice of the bone. Returns -1 if not found
  13160. */
  13161. getBoneIndexByName(name: string): number;
  13162. /**
  13163. * Creater a new animation range
  13164. * @param name defines the name of the range
  13165. * @param from defines the start key
  13166. * @param to defines the end key
  13167. */
  13168. createAnimationRange(name: string, from: number, to: number): void;
  13169. /**
  13170. * Delete a specific animation range
  13171. * @param name defines the name of the range
  13172. * @param deleteFrames defines if frames must be removed as well
  13173. */
  13174. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13175. /**
  13176. * Gets a specific animation range
  13177. * @param name defines the name of the range to look for
  13178. * @returns the requested animation range or null if not found
  13179. */
  13180. getAnimationRange(name: string): Nullable<AnimationRange>;
  13181. /**
  13182. * Gets the list of all animation ranges defined on this skeleton
  13183. * @returns an array
  13184. */
  13185. getAnimationRanges(): Nullable<AnimationRange>[];
  13186. /**
  13187. * Copy animation range from a source skeleton.
  13188. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13189. * @param source defines the source skeleton
  13190. * @param name defines the name of the range to copy
  13191. * @param rescaleAsRequired defines if rescaling must be applied if required
  13192. * @returns true if operation was successful
  13193. */
  13194. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13195. /**
  13196. * Forces the skeleton to go to rest pose
  13197. */
  13198. returnToRest(): void;
  13199. private _getHighestAnimationFrame;
  13200. /**
  13201. * Begin a specific animation range
  13202. * @param name defines the name of the range to start
  13203. * @param loop defines if looping must be turned on (false by default)
  13204. * @param speedRatio defines the speed ratio to apply (1 by default)
  13205. * @param onAnimationEnd defines a callback which will be called when animation will end
  13206. * @returns a new animatable
  13207. */
  13208. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13209. /** @hidden */
  13210. _markAsDirty(): void;
  13211. /** @hidden */
  13212. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13213. /** @hidden */
  13214. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13215. private _computeTransformMatrices;
  13216. /**
  13217. * Build all resources required to render a skeleton
  13218. */
  13219. prepare(): void;
  13220. /**
  13221. * Gets the list of animatables currently running for this skeleton
  13222. * @returns an array of animatables
  13223. */
  13224. getAnimatables(): IAnimatable[];
  13225. /**
  13226. * Clone the current skeleton
  13227. * @param name defines the name of the new skeleton
  13228. * @param id defines the id of the new skeleton
  13229. * @returns the new skeleton
  13230. */
  13231. clone(name: string, id: string): Skeleton;
  13232. /**
  13233. * Enable animation blending for this skeleton
  13234. * @param blendingSpeed defines the blending speed to apply
  13235. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13236. */
  13237. enableBlending(blendingSpeed?: number): void;
  13238. /**
  13239. * Releases all resources associated with the current skeleton
  13240. */
  13241. dispose(): void;
  13242. /**
  13243. * Serialize the skeleton in a JSON object
  13244. * @returns a JSON object
  13245. */
  13246. serialize(): any;
  13247. /**
  13248. * Creates a new skeleton from serialized data
  13249. * @param parsedSkeleton defines the serialized data
  13250. * @param scene defines the hosting scene
  13251. * @returns a new skeleton
  13252. */
  13253. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13254. /**
  13255. * Compute all node absolute transforms
  13256. * @param forceUpdate defines if computation must be done even if cache is up to date
  13257. */
  13258. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13259. /**
  13260. * Gets the root pose matrix
  13261. * @returns a matrix
  13262. */
  13263. getPoseMatrix(): Nullable<Matrix>;
  13264. /**
  13265. * Sorts bones per internal index
  13266. */
  13267. sortBones(): void;
  13268. private _sortBones;
  13269. }
  13270. }
  13271. declare module BABYLON {
  13272. /**
  13273. * Class used to store bone information
  13274. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13275. */
  13276. export class Bone extends Node {
  13277. /**
  13278. * defines the bone name
  13279. */
  13280. name: string;
  13281. private static _tmpVecs;
  13282. private static _tmpQuat;
  13283. private static _tmpMats;
  13284. /**
  13285. * Gets the list of child bones
  13286. */
  13287. children: Bone[];
  13288. /** Gets the animations associated with this bone */
  13289. animations: Animation[];
  13290. /**
  13291. * Gets or sets bone length
  13292. */
  13293. length: number;
  13294. /**
  13295. * @hidden Internal only
  13296. * Set this value to map this bone to a different index in the transform matrices
  13297. * Set this value to -1 to exclude the bone from the transform matrices
  13298. */
  13299. _index: Nullable<number>;
  13300. private _skeleton;
  13301. private _localMatrix;
  13302. private _restPose;
  13303. private _baseMatrix;
  13304. private _absoluteTransform;
  13305. private _invertedAbsoluteTransform;
  13306. private _parent;
  13307. private _scalingDeterminant;
  13308. private _worldTransform;
  13309. private _localScaling;
  13310. private _localRotation;
  13311. private _localPosition;
  13312. private _needToDecompose;
  13313. private _needToCompose;
  13314. /** @hidden */
  13315. _linkedTransformNode: Nullable<TransformNode>;
  13316. /** @hidden */
  13317. _waitingTransformNodeId: Nullable<string>;
  13318. /** @hidden */
  13319. /** @hidden */
  13320. _matrix: Matrix;
  13321. /**
  13322. * Create a new bone
  13323. * @param name defines the bone name
  13324. * @param skeleton defines the parent skeleton
  13325. * @param parentBone defines the parent (can be null if the bone is the root)
  13326. * @param localMatrix defines the local matrix
  13327. * @param restPose defines the rest pose matrix
  13328. * @param baseMatrix defines the base matrix
  13329. * @param index defines index of the bone in the hiearchy
  13330. */
  13331. constructor(
  13332. /**
  13333. * defines the bone name
  13334. */
  13335. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13336. /**
  13337. * Gets the current object class name.
  13338. * @return the class name
  13339. */
  13340. getClassName(): string;
  13341. /**
  13342. * Gets the parent skeleton
  13343. * @returns a skeleton
  13344. */
  13345. getSkeleton(): Skeleton;
  13346. /**
  13347. * Gets parent bone
  13348. * @returns a bone or null if the bone is the root of the bone hierarchy
  13349. */
  13350. getParent(): Nullable<Bone>;
  13351. /**
  13352. * Returns an array containing the root bones
  13353. * @returns an array containing the root bones
  13354. */
  13355. getChildren(): Array<Bone>;
  13356. /**
  13357. * Sets the parent bone
  13358. * @param parent defines the parent (can be null if the bone is the root)
  13359. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13360. */
  13361. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13362. /**
  13363. * Gets the local matrix
  13364. * @returns a matrix
  13365. */
  13366. getLocalMatrix(): Matrix;
  13367. /**
  13368. * Gets the base matrix (initial matrix which remains unchanged)
  13369. * @returns a matrix
  13370. */
  13371. getBaseMatrix(): Matrix;
  13372. /**
  13373. * Gets the rest pose matrix
  13374. * @returns a matrix
  13375. */
  13376. getRestPose(): Matrix;
  13377. /**
  13378. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13379. */
  13380. getWorldMatrix(): Matrix;
  13381. /**
  13382. * Sets the local matrix to rest pose matrix
  13383. */
  13384. returnToRest(): void;
  13385. /**
  13386. * Gets the inverse of the absolute transform matrix.
  13387. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13388. * @returns a matrix
  13389. */
  13390. getInvertedAbsoluteTransform(): Matrix;
  13391. /**
  13392. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13393. * @returns a matrix
  13394. */
  13395. getAbsoluteTransform(): Matrix;
  13396. /**
  13397. * Links with the given transform node.
  13398. * The local matrix of this bone is copied from the transform node every frame.
  13399. * @param transformNode defines the transform node to link to
  13400. */
  13401. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13402. /**
  13403. * Gets the node used to drive the bone's transformation
  13404. * @returns a transform node or null
  13405. */
  13406. getTransformNode(): Nullable<TransformNode>;
  13407. /** Gets or sets current position (in local space) */
  13408. position: Vector3;
  13409. /** Gets or sets current rotation (in local space) */
  13410. rotation: Vector3;
  13411. /** Gets or sets current rotation quaternion (in local space) */
  13412. rotationQuaternion: Quaternion;
  13413. /** Gets or sets current scaling (in local space) */
  13414. scaling: Vector3;
  13415. /**
  13416. * Gets the animation properties override
  13417. */
  13418. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13419. private _decompose;
  13420. private _compose;
  13421. /**
  13422. * Update the base and local matrices
  13423. * @param matrix defines the new base or local matrix
  13424. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13425. * @param updateLocalMatrix defines if the local matrix should be updated
  13426. */
  13427. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13428. /** @hidden */
  13429. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13430. /**
  13431. * Flag the bone as dirty (Forcing it to update everything)
  13432. */
  13433. markAsDirty(): void;
  13434. /** @hidden */
  13435. _markAsDirtyAndCompose(): void;
  13436. private _markAsDirtyAndDecompose;
  13437. /**
  13438. * Translate the bone in local or world space
  13439. * @param vec The amount to translate the bone
  13440. * @param space The space that the translation is in
  13441. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13442. */
  13443. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13444. /**
  13445. * Set the postion of the bone in local or world space
  13446. * @param position The position to set the bone
  13447. * @param space The space that the position is in
  13448. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13449. */
  13450. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13451. /**
  13452. * Set the absolute position of the bone (world space)
  13453. * @param position The position to set the bone
  13454. * @param mesh The mesh that this bone is attached to
  13455. */
  13456. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13457. /**
  13458. * Scale the bone on the x, y and z axes (in local space)
  13459. * @param x The amount to scale the bone on the x axis
  13460. * @param y The amount to scale the bone on the y axis
  13461. * @param z The amount to scale the bone on the z axis
  13462. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13463. */
  13464. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13465. /**
  13466. * Set the bone scaling in local space
  13467. * @param scale defines the scaling vector
  13468. */
  13469. setScale(scale: Vector3): void;
  13470. /**
  13471. * Gets the current scaling in local space
  13472. * @returns the current scaling vector
  13473. */
  13474. getScale(): Vector3;
  13475. /**
  13476. * Gets the current scaling in local space and stores it in a target vector
  13477. * @param result defines the target vector
  13478. */
  13479. getScaleToRef(result: Vector3): void;
  13480. /**
  13481. * Set the yaw, pitch, and roll of the bone in local or world space
  13482. * @param yaw The rotation of the bone on the y axis
  13483. * @param pitch The rotation of the bone on the x axis
  13484. * @param roll The rotation of the bone on the z axis
  13485. * @param space The space that the axes of rotation are in
  13486. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13487. */
  13488. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13489. /**
  13490. * Add a rotation to the bone on an axis in local or world space
  13491. * @param axis The axis to rotate the bone on
  13492. * @param amount The amount to rotate the bone
  13493. * @param space The space that the axis is in
  13494. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13495. */
  13496. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13497. /**
  13498. * Set the rotation of the bone to a particular axis angle in local or world space
  13499. * @param axis The axis to rotate the bone on
  13500. * @param angle The angle that the bone should be rotated to
  13501. * @param space The space that the axis is in
  13502. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13503. */
  13504. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13505. /**
  13506. * Set the euler rotation of the bone in local of world space
  13507. * @param rotation The euler rotation that the bone should be set to
  13508. * @param space The space that the rotation is in
  13509. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13510. */
  13511. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13512. /**
  13513. * Set the quaternion rotation of the bone in local of world space
  13514. * @param quat The quaternion rotation that the bone should be set to
  13515. * @param space The space that the rotation is in
  13516. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13517. */
  13518. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13519. /**
  13520. * Set the rotation matrix of the bone in local of world space
  13521. * @param rotMat The rotation matrix that the bone should be set to
  13522. * @param space The space that the rotation is in
  13523. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13524. */
  13525. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13526. private _rotateWithMatrix;
  13527. private _getNegativeRotationToRef;
  13528. /**
  13529. * Get the position of the bone in local or world space
  13530. * @param space The space that the returned position is in
  13531. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13532. * @returns The position of the bone
  13533. */
  13534. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13535. /**
  13536. * Copy the position of the bone to a vector3 in local or world space
  13537. * @param space The space that the returned position is in
  13538. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13539. * @param result The vector3 to copy the position to
  13540. */
  13541. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13542. /**
  13543. * Get the absolute position of the bone (world space)
  13544. * @param mesh The mesh that this bone is attached to
  13545. * @returns The absolute position of the bone
  13546. */
  13547. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13548. /**
  13549. * Copy the absolute position of the bone (world space) to the result param
  13550. * @param mesh The mesh that this bone is attached to
  13551. * @param result The vector3 to copy the absolute position to
  13552. */
  13553. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13554. /**
  13555. * Compute the absolute transforms of this bone and its children
  13556. */
  13557. computeAbsoluteTransforms(): void;
  13558. /**
  13559. * Get the world direction from an axis that is in the local space of the bone
  13560. * @param localAxis The local direction that is used to compute the world direction
  13561. * @param mesh The mesh that this bone is attached to
  13562. * @returns The world direction
  13563. */
  13564. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13565. /**
  13566. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13567. * @param localAxis The local direction that is used to compute the world direction
  13568. * @param mesh The mesh that this bone is attached to
  13569. * @param result The vector3 that the world direction will be copied to
  13570. */
  13571. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13572. /**
  13573. * Get the euler rotation of the bone in 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. * @returns The euler rotation
  13577. */
  13578. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13579. /**
  13580. * Copy the euler rotation of the bone to a vector3. The rotation can be in either 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. * @param result The vector3 that the rotation should be copied to
  13584. */
  13585. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13586. /**
  13587. * Get the quaternion rotation of the bone 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. * @returns The quaternion rotation
  13591. */
  13592. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13593. /**
  13594. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13595. * @param space The space that the rotation should be in
  13596. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13597. * @param result The quaternion that the rotation should be copied to
  13598. */
  13599. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13600. /**
  13601. * Get the rotation matrix of the bone in local or world space
  13602. * @param space The space that the rotation should be in
  13603. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13604. * @returns The rotation matrix
  13605. */
  13606. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13607. /**
  13608. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13609. * @param space The space that the rotation should be in
  13610. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13611. * @param result The quaternion that the rotation should be copied to
  13612. */
  13613. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13614. /**
  13615. * Get the world position of a point that is in the local space of the bone
  13616. * @param position The local position
  13617. * @param mesh The mesh that this bone is attached to
  13618. * @returns The world position
  13619. */
  13620. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13621. /**
  13622. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13623. * @param position The local position
  13624. * @param mesh The mesh that this bone is attached to
  13625. * @param result The vector3 that the world position should be copied to
  13626. */
  13627. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13628. /**
  13629. * Get the local position of a point that is in world space
  13630. * @param position The world position
  13631. * @param mesh The mesh that this bone is attached to
  13632. * @returns The local position
  13633. */
  13634. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13635. /**
  13636. * Get the local position of a point that is in world space and copy it to the result param
  13637. * @param position The world position
  13638. * @param mesh The mesh that this bone is attached to
  13639. * @param result The vector3 that the local position should be copied to
  13640. */
  13641. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13642. }
  13643. }
  13644. declare module BABYLON {
  13645. /**
  13646. * 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.
  13647. * @see https://doc.babylonjs.com/how_to/transformnode
  13648. */
  13649. export class TransformNode extends Node {
  13650. /**
  13651. * Object will not rotate to face the camera
  13652. */
  13653. static BILLBOARDMODE_NONE: number;
  13654. /**
  13655. * Object will rotate to face the camera but only on the x axis
  13656. */
  13657. static BILLBOARDMODE_X: number;
  13658. /**
  13659. * Object will rotate to face the camera but only on the y axis
  13660. */
  13661. static BILLBOARDMODE_Y: number;
  13662. /**
  13663. * Object will rotate to face the camera but only on the z axis
  13664. */
  13665. static BILLBOARDMODE_Z: number;
  13666. /**
  13667. * Object will rotate to face the camera
  13668. */
  13669. static BILLBOARDMODE_ALL: number;
  13670. /**
  13671. * Object will rotate to face the camera's position instead of orientation
  13672. */
  13673. static BILLBOARDMODE_USE_POSITION: number;
  13674. private _forward;
  13675. private _forwardInverted;
  13676. private _up;
  13677. private _right;
  13678. private _rightInverted;
  13679. private _position;
  13680. private _rotation;
  13681. private _rotationQuaternion;
  13682. protected _scaling: Vector3;
  13683. protected _isDirty: boolean;
  13684. private _transformToBoneReferal;
  13685. private _isAbsoluteSynced;
  13686. private _billboardMode;
  13687. /**
  13688. * Gets or sets the billboard mode. Default is 0.
  13689. *
  13690. * | Value | Type | Description |
  13691. * | --- | --- | --- |
  13692. * | 0 | BILLBOARDMODE_NONE | |
  13693. * | 1 | BILLBOARDMODE_X | |
  13694. * | 2 | BILLBOARDMODE_Y | |
  13695. * | 4 | BILLBOARDMODE_Z | |
  13696. * | 7 | BILLBOARDMODE_ALL | |
  13697. *
  13698. */
  13699. billboardMode: number;
  13700. private _preserveParentRotationForBillboard;
  13701. /**
  13702. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13703. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13704. */
  13705. preserveParentRotationForBillboard: boolean;
  13706. /**
  13707. * 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
  13708. */
  13709. scalingDeterminant: number;
  13710. private _infiniteDistance;
  13711. /**
  13712. * Gets or sets the distance of the object to max, often used by skybox
  13713. */
  13714. infiniteDistance: boolean;
  13715. /**
  13716. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13717. * By default the system will update normals to compensate
  13718. */
  13719. ignoreNonUniformScaling: boolean;
  13720. /**
  13721. * 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
  13722. */
  13723. reIntegrateRotationIntoRotationQuaternion: boolean;
  13724. /** @hidden */
  13725. _poseMatrix: Nullable<Matrix>;
  13726. /** @hidden */
  13727. _localMatrix: Matrix;
  13728. private _usePivotMatrix;
  13729. private _absolutePosition;
  13730. private _absoluteScaling;
  13731. private _absoluteRotationQuaternion;
  13732. private _pivotMatrix;
  13733. private _pivotMatrixInverse;
  13734. protected _postMultiplyPivotMatrix: boolean;
  13735. protected _isWorldMatrixFrozen: boolean;
  13736. /** @hidden */
  13737. _indexInSceneTransformNodesArray: number;
  13738. /**
  13739. * An event triggered after the world matrix is updated
  13740. */
  13741. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13742. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13743. /**
  13744. * Gets a string identifying the name of the class
  13745. * @returns "TransformNode" string
  13746. */
  13747. getClassName(): string;
  13748. /**
  13749. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13750. */
  13751. position: Vector3;
  13752. /**
  13753. * 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)).
  13754. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13755. */
  13756. rotation: Vector3;
  13757. /**
  13758. * 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)).
  13759. */
  13760. scaling: Vector3;
  13761. /**
  13762. * 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).
  13763. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13764. */
  13765. rotationQuaternion: Nullable<Quaternion>;
  13766. /**
  13767. * The forward direction of that transform in world space.
  13768. */
  13769. readonly forward: Vector3;
  13770. /**
  13771. * The up direction of that transform in world space.
  13772. */
  13773. readonly up: Vector3;
  13774. /**
  13775. * The right direction of that transform in world space.
  13776. */
  13777. readonly right: Vector3;
  13778. /**
  13779. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13780. * @param matrix the matrix to copy the pose from
  13781. * @returns this TransformNode.
  13782. */
  13783. updatePoseMatrix(matrix: Matrix): TransformNode;
  13784. /**
  13785. * Returns the mesh Pose matrix.
  13786. * @returns the pose matrix
  13787. */
  13788. getPoseMatrix(): Matrix;
  13789. /** @hidden */
  13790. _isSynchronized(): boolean;
  13791. /** @hidden */
  13792. _initCache(): void;
  13793. /**
  13794. * Flag the transform node as dirty (Forcing it to update everything)
  13795. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13796. * @returns this transform node
  13797. */
  13798. markAsDirty(property: string): TransformNode;
  13799. /**
  13800. * Returns the current mesh absolute position.
  13801. * Returns a Vector3.
  13802. */
  13803. readonly absolutePosition: Vector3;
  13804. /**
  13805. * Returns the current mesh absolute scaling.
  13806. * Returns a Vector3.
  13807. */
  13808. readonly absoluteScaling: Vector3;
  13809. /**
  13810. * Returns the current mesh absolute rotation.
  13811. * Returns a Quaternion.
  13812. */
  13813. readonly absoluteRotationQuaternion: Quaternion;
  13814. /**
  13815. * Sets a new matrix to apply before all other transformation
  13816. * @param matrix defines the transform matrix
  13817. * @returns the current TransformNode
  13818. */
  13819. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13820. /**
  13821. * Sets a new pivot matrix to the current node
  13822. * @param matrix defines the new pivot matrix to use
  13823. * @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
  13824. * @returns the current TransformNode
  13825. */
  13826. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13827. /**
  13828. * Returns the mesh pivot matrix.
  13829. * Default : Identity.
  13830. * @returns the matrix
  13831. */
  13832. getPivotMatrix(): Matrix;
  13833. /**
  13834. * Instantiate (when possible) or clone that node with its hierarchy
  13835. * @param newParent defines the new parent to use for the instance (or clone)
  13836. * @returns an instance (or a clone) of the current node with its hiearchy
  13837. */
  13838. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  13839. /**
  13840. * Prevents the World matrix to be computed any longer
  13841. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13842. * @returns the TransformNode.
  13843. */
  13844. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13845. /**
  13846. * Allows back the World matrix computation.
  13847. * @returns the TransformNode.
  13848. */
  13849. unfreezeWorldMatrix(): this;
  13850. /**
  13851. * True if the World matrix has been frozen.
  13852. */
  13853. readonly isWorldMatrixFrozen: boolean;
  13854. /**
  13855. * Retuns the mesh absolute position in the World.
  13856. * @returns a Vector3.
  13857. */
  13858. getAbsolutePosition(): Vector3;
  13859. /**
  13860. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13861. * @param absolutePosition the absolute position to set
  13862. * @returns the TransformNode.
  13863. */
  13864. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13865. /**
  13866. * Sets the mesh position in its local space.
  13867. * @param vector3 the position to set in localspace
  13868. * @returns the TransformNode.
  13869. */
  13870. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13871. /**
  13872. * Returns the mesh position in the local space from the current World matrix values.
  13873. * @returns a new Vector3.
  13874. */
  13875. getPositionExpressedInLocalSpace(): Vector3;
  13876. /**
  13877. * Translates the mesh along the passed Vector3 in its local space.
  13878. * @param vector3 the distance to translate in localspace
  13879. * @returns the TransformNode.
  13880. */
  13881. locallyTranslate(vector3: Vector3): TransformNode;
  13882. private static _lookAtVectorCache;
  13883. /**
  13884. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13885. * @param targetPoint the position (must be in same space as current mesh) to look at
  13886. * @param yawCor optional yaw (y-axis) correction in radians
  13887. * @param pitchCor optional pitch (x-axis) correction in radians
  13888. * @param rollCor optional roll (z-axis) correction in radians
  13889. * @param space the choosen space of the target
  13890. * @returns the TransformNode.
  13891. */
  13892. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13893. /**
  13894. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13895. * This Vector3 is expressed in the World space.
  13896. * @param localAxis axis to rotate
  13897. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13898. */
  13899. getDirection(localAxis: Vector3): Vector3;
  13900. /**
  13901. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13902. * localAxis is expressed in the mesh local space.
  13903. * result is computed in the Wordl space from the mesh World matrix.
  13904. * @param localAxis axis to rotate
  13905. * @param result the resulting transformnode
  13906. * @returns this TransformNode.
  13907. */
  13908. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13909. /**
  13910. * Sets this transform node rotation to the given local axis.
  13911. * @param localAxis the axis in local space
  13912. * @param yawCor optional yaw (y-axis) correction in radians
  13913. * @param pitchCor optional pitch (x-axis) correction in radians
  13914. * @param rollCor optional roll (z-axis) correction in radians
  13915. * @returns this TransformNode
  13916. */
  13917. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13918. /**
  13919. * Sets a new pivot point to the current node
  13920. * @param point defines the new pivot point to use
  13921. * @param space defines if the point is in world or local space (local by default)
  13922. * @returns the current TransformNode
  13923. */
  13924. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13925. /**
  13926. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13927. * @returns the pivot point
  13928. */
  13929. getPivotPoint(): Vector3;
  13930. /**
  13931. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13932. * @param result the vector3 to store the result
  13933. * @returns this TransformNode.
  13934. */
  13935. getPivotPointToRef(result: Vector3): TransformNode;
  13936. /**
  13937. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13938. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13939. */
  13940. getAbsolutePivotPoint(): Vector3;
  13941. /**
  13942. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13943. * @param result vector3 to store the result
  13944. * @returns this TransformNode.
  13945. */
  13946. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13947. /**
  13948. * Defines the passed node as the parent of the current node.
  13949. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13950. * @see https://doc.babylonjs.com/how_to/parenting
  13951. * @param node the node ot set as the parent
  13952. * @returns this TransformNode.
  13953. */
  13954. setParent(node: Nullable<Node>): TransformNode;
  13955. private _nonUniformScaling;
  13956. /**
  13957. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13958. */
  13959. readonly nonUniformScaling: boolean;
  13960. /** @hidden */
  13961. _updateNonUniformScalingState(value: boolean): boolean;
  13962. /**
  13963. * Attach the current TransformNode to another TransformNode associated with a bone
  13964. * @param bone Bone affecting the TransformNode
  13965. * @param affectedTransformNode TransformNode associated with the bone
  13966. * @returns this object
  13967. */
  13968. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13969. /**
  13970. * Detach the transform node if its associated with a bone
  13971. * @returns this object
  13972. */
  13973. detachFromBone(): TransformNode;
  13974. private static _rotationAxisCache;
  13975. /**
  13976. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13977. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13978. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13979. * The passed axis is also normalized.
  13980. * @param axis the axis to rotate around
  13981. * @param amount the amount to rotate in radians
  13982. * @param space Space to rotate in (Default: local)
  13983. * @returns the TransformNode.
  13984. */
  13985. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13986. /**
  13987. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13988. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13989. * The passed axis is also normalized. .
  13990. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13991. * @param point the point to rotate around
  13992. * @param axis the axis to rotate around
  13993. * @param amount the amount to rotate in radians
  13994. * @returns the TransformNode
  13995. */
  13996. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13997. /**
  13998. * Translates the mesh along the axis vector for the passed distance in the given space.
  13999. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14000. * @param axis the axis to translate in
  14001. * @param distance the distance to translate
  14002. * @param space Space to rotate in (Default: local)
  14003. * @returns the TransformNode.
  14004. */
  14005. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14006. /**
  14007. * Adds a rotation step to the mesh current rotation.
  14008. * x, y, z are Euler angles expressed in radians.
  14009. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14010. * This means this rotation is made in the mesh local space only.
  14011. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14012. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14013. * ```javascript
  14014. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14015. * ```
  14016. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14017. * 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.
  14018. * @param x Rotation to add
  14019. * @param y Rotation to add
  14020. * @param z Rotation to add
  14021. * @returns the TransformNode.
  14022. */
  14023. addRotation(x: number, y: number, z: number): TransformNode;
  14024. /**
  14025. * @hidden
  14026. */
  14027. protected _getEffectiveParent(): Nullable<Node>;
  14028. /**
  14029. * Computes the world matrix of the node
  14030. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14031. * @returns the world matrix
  14032. */
  14033. computeWorldMatrix(force?: boolean): Matrix;
  14034. protected _afterComputeWorldMatrix(): void;
  14035. /**
  14036. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14037. * @param func callback function to add
  14038. *
  14039. * @returns the TransformNode.
  14040. */
  14041. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14042. /**
  14043. * Removes a registered callback function.
  14044. * @param func callback function to remove
  14045. * @returns the TransformNode.
  14046. */
  14047. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14048. /**
  14049. * Gets the position of the current mesh in camera space
  14050. * @param camera defines the camera to use
  14051. * @returns a position
  14052. */
  14053. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14054. /**
  14055. * Returns the distance from the mesh to the active camera
  14056. * @param camera defines the camera to use
  14057. * @returns the distance
  14058. */
  14059. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14060. /**
  14061. * Clone the current transform node
  14062. * @param name Name of the new clone
  14063. * @param newParent New parent for the clone
  14064. * @param doNotCloneChildren Do not clone children hierarchy
  14065. * @returns the new transform node
  14066. */
  14067. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14068. /**
  14069. * Serializes the objects information.
  14070. * @param currentSerializationObject defines the object to serialize in
  14071. * @returns the serialized object
  14072. */
  14073. serialize(currentSerializationObject?: any): any;
  14074. /**
  14075. * Returns a new TransformNode object parsed from the source provided.
  14076. * @param parsedTransformNode is the source.
  14077. * @param scene the scne the object belongs to
  14078. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14079. * @returns a new TransformNode object parsed from the source provided.
  14080. */
  14081. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14082. /**
  14083. * Get all child-transformNodes of this node
  14084. * @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
  14085. * @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
  14086. * @returns an array of TransformNode
  14087. */
  14088. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14089. /**
  14090. * Releases resources associated with this transform node.
  14091. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14092. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14093. */
  14094. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14095. /**
  14096. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14097. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14098. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14099. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14100. * @returns the current mesh
  14101. */
  14102. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14103. private _syncAbsoluteScalingAndRotation;
  14104. }
  14105. }
  14106. declare module BABYLON {
  14107. /**
  14108. * Defines the types of pose enabled controllers that are supported
  14109. */
  14110. export enum PoseEnabledControllerType {
  14111. /**
  14112. * HTC Vive
  14113. */
  14114. VIVE = 0,
  14115. /**
  14116. * Oculus Rift
  14117. */
  14118. OCULUS = 1,
  14119. /**
  14120. * Windows mixed reality
  14121. */
  14122. WINDOWS = 2,
  14123. /**
  14124. * Samsung gear VR
  14125. */
  14126. GEAR_VR = 3,
  14127. /**
  14128. * Google Daydream
  14129. */
  14130. DAYDREAM = 4,
  14131. /**
  14132. * Generic
  14133. */
  14134. GENERIC = 5
  14135. }
  14136. /**
  14137. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14138. */
  14139. export interface MutableGamepadButton {
  14140. /**
  14141. * Value of the button/trigger
  14142. */
  14143. value: number;
  14144. /**
  14145. * If the button/trigger is currently touched
  14146. */
  14147. touched: boolean;
  14148. /**
  14149. * If the button/trigger is currently pressed
  14150. */
  14151. pressed: boolean;
  14152. }
  14153. /**
  14154. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14155. * @hidden
  14156. */
  14157. export interface ExtendedGamepadButton extends GamepadButton {
  14158. /**
  14159. * If the button/trigger is currently pressed
  14160. */
  14161. readonly pressed: boolean;
  14162. /**
  14163. * If the button/trigger is currently touched
  14164. */
  14165. readonly touched: boolean;
  14166. /**
  14167. * Value of the button/trigger
  14168. */
  14169. readonly value: number;
  14170. }
  14171. /** @hidden */
  14172. export interface _GamePadFactory {
  14173. /**
  14174. * Returns wether or not the current gamepad can be created for this type of controller.
  14175. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14176. * @returns true if it can be created, otherwise false
  14177. */
  14178. canCreate(gamepadInfo: any): boolean;
  14179. /**
  14180. * Creates a new instance of the Gamepad.
  14181. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14182. * @returns the new gamepad instance
  14183. */
  14184. create(gamepadInfo: any): Gamepad;
  14185. }
  14186. /**
  14187. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14188. */
  14189. export class PoseEnabledControllerHelper {
  14190. /** @hidden */
  14191. static _ControllerFactories: _GamePadFactory[];
  14192. /** @hidden */
  14193. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14194. /**
  14195. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14196. * @param vrGamepad the gamepad to initialized
  14197. * @returns a vr controller of the type the gamepad identified as
  14198. */
  14199. static InitiateController(vrGamepad: any): Gamepad;
  14200. }
  14201. /**
  14202. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14203. */
  14204. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14205. /**
  14206. * If the controller is used in a webXR session
  14207. */
  14208. isXR: boolean;
  14209. private _deviceRoomPosition;
  14210. private _deviceRoomRotationQuaternion;
  14211. /**
  14212. * The device position in babylon space
  14213. */
  14214. devicePosition: Vector3;
  14215. /**
  14216. * The device rotation in babylon space
  14217. */
  14218. deviceRotationQuaternion: Quaternion;
  14219. /**
  14220. * The scale factor of the device in babylon space
  14221. */
  14222. deviceScaleFactor: number;
  14223. /**
  14224. * (Likely devicePosition should be used instead) The device position in its room space
  14225. */
  14226. position: Vector3;
  14227. /**
  14228. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14229. */
  14230. rotationQuaternion: Quaternion;
  14231. /**
  14232. * The type of controller (Eg. Windows mixed reality)
  14233. */
  14234. controllerType: PoseEnabledControllerType;
  14235. protected _calculatedPosition: Vector3;
  14236. private _calculatedRotation;
  14237. /**
  14238. * The raw pose from the device
  14239. */
  14240. rawPose: DevicePose;
  14241. private _trackPosition;
  14242. private _maxRotationDistFromHeadset;
  14243. private _draggedRoomRotation;
  14244. /**
  14245. * @hidden
  14246. */
  14247. _disableTrackPosition(fixedPosition: Vector3): void;
  14248. /**
  14249. * Internal, the mesh attached to the controller
  14250. * @hidden
  14251. */
  14252. _mesh: Nullable<AbstractMesh>;
  14253. private _poseControlledCamera;
  14254. private _leftHandSystemQuaternion;
  14255. /**
  14256. * Internal, matrix used to convert room space to babylon space
  14257. * @hidden
  14258. */
  14259. _deviceToWorld: Matrix;
  14260. /**
  14261. * Node to be used when casting a ray from the controller
  14262. * @hidden
  14263. */
  14264. _pointingPoseNode: Nullable<TransformNode>;
  14265. /**
  14266. * Name of the child mesh that can be used to cast a ray from the controller
  14267. */
  14268. static readonly POINTING_POSE: string;
  14269. /**
  14270. * Creates a new PoseEnabledController from a gamepad
  14271. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14272. */
  14273. constructor(browserGamepad: any);
  14274. private _workingMatrix;
  14275. /**
  14276. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14277. */
  14278. update(): void;
  14279. /**
  14280. * Updates only the pose device and mesh without doing any button event checking
  14281. */
  14282. protected _updatePoseAndMesh(): void;
  14283. /**
  14284. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14285. * @param poseData raw pose fromthe device
  14286. */
  14287. updateFromDevice(poseData: DevicePose): void;
  14288. /**
  14289. * @hidden
  14290. */
  14291. _meshAttachedObservable: Observable<AbstractMesh>;
  14292. /**
  14293. * Attaches a mesh to the controller
  14294. * @param mesh the mesh to be attached
  14295. */
  14296. attachToMesh(mesh: AbstractMesh): void;
  14297. /**
  14298. * Attaches the controllers mesh to a camera
  14299. * @param camera the camera the mesh should be attached to
  14300. */
  14301. attachToPoseControlledCamera(camera: TargetCamera): void;
  14302. /**
  14303. * Disposes of the controller
  14304. */
  14305. dispose(): void;
  14306. /**
  14307. * The mesh that is attached to the controller
  14308. */
  14309. readonly mesh: Nullable<AbstractMesh>;
  14310. /**
  14311. * Gets the ray of the controller in the direction the controller is pointing
  14312. * @param length the length the resulting ray should be
  14313. * @returns a ray in the direction the controller is pointing
  14314. */
  14315. getForwardRay(length?: number): Ray;
  14316. }
  14317. }
  14318. declare module BABYLON {
  14319. /**
  14320. * Defines the WebVRController object that represents controllers tracked in 3D space
  14321. */
  14322. export abstract class WebVRController extends PoseEnabledController {
  14323. /**
  14324. * Internal, the default controller model for the controller
  14325. */
  14326. protected _defaultModel: AbstractMesh;
  14327. /**
  14328. * Fired when the trigger state has changed
  14329. */
  14330. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14331. /**
  14332. * Fired when the main button state has changed
  14333. */
  14334. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14335. /**
  14336. * Fired when the secondary button state has changed
  14337. */
  14338. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14339. /**
  14340. * Fired when the pad state has changed
  14341. */
  14342. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14343. /**
  14344. * Fired when controllers stick values have changed
  14345. */
  14346. onPadValuesChangedObservable: Observable<StickValues>;
  14347. /**
  14348. * Array of button availible on the controller
  14349. */
  14350. protected _buttons: Array<MutableGamepadButton>;
  14351. private _onButtonStateChange;
  14352. /**
  14353. * Fired when a controller button's state has changed
  14354. * @param callback the callback containing the button that was modified
  14355. */
  14356. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14357. /**
  14358. * X and Y axis corresponding to the controllers joystick
  14359. */
  14360. pad: StickValues;
  14361. /**
  14362. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14363. */
  14364. hand: string;
  14365. /**
  14366. * The default controller model for the controller
  14367. */
  14368. readonly defaultModel: AbstractMesh;
  14369. /**
  14370. * Creates a new WebVRController from a gamepad
  14371. * @param vrGamepad the gamepad that the WebVRController should be created from
  14372. */
  14373. constructor(vrGamepad: any);
  14374. /**
  14375. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14376. */
  14377. update(): void;
  14378. /**
  14379. * Function to be called when a button is modified
  14380. */
  14381. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14382. /**
  14383. * Loads a mesh and attaches it to the controller
  14384. * @param scene the scene the mesh should be added to
  14385. * @param meshLoaded callback for when the mesh has been loaded
  14386. */
  14387. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14388. private _setButtonValue;
  14389. private _changes;
  14390. private _checkChanges;
  14391. /**
  14392. * Disposes of th webVRCOntroller
  14393. */
  14394. dispose(): void;
  14395. }
  14396. }
  14397. declare module BABYLON {
  14398. /**
  14399. * The HemisphericLight simulates the ambient environment light,
  14400. * so the passed direction is the light reflection direction, not the incoming direction.
  14401. */
  14402. export class HemisphericLight extends Light {
  14403. /**
  14404. * The groundColor is the light in the opposite direction to the one specified during creation.
  14405. * 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.
  14406. */
  14407. groundColor: Color3;
  14408. /**
  14409. * The light reflection direction, not the incoming direction.
  14410. */
  14411. direction: Vector3;
  14412. /**
  14413. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14414. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14415. * The HemisphericLight can't cast shadows.
  14416. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14417. * @param name The friendly name of the light
  14418. * @param direction The direction of the light reflection
  14419. * @param scene The scene the light belongs to
  14420. */
  14421. constructor(name: string, direction: Vector3, scene: Scene);
  14422. protected _buildUniformLayout(): void;
  14423. /**
  14424. * Returns the string "HemisphericLight".
  14425. * @return The class name
  14426. */
  14427. getClassName(): string;
  14428. /**
  14429. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14430. * Returns the updated direction.
  14431. * @param target The target the direction should point to
  14432. * @return The computed direction
  14433. */
  14434. setDirectionToTarget(target: Vector3): Vector3;
  14435. /**
  14436. * Returns the shadow generator associated to the light.
  14437. * @returns Always null for hemispheric lights because it does not support shadows.
  14438. */
  14439. getShadowGenerator(): Nullable<IShadowGenerator>;
  14440. /**
  14441. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14442. * @param effect The effect to update
  14443. * @param lightIndex The index of the light in the effect to update
  14444. * @returns The hemispheric light
  14445. */
  14446. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14447. /**
  14448. * Computes the world matrix of the node
  14449. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14450. * @param useWasUpdatedFlag defines a reserved property
  14451. * @returns the world matrix
  14452. */
  14453. computeWorldMatrix(): Matrix;
  14454. /**
  14455. * Returns the integer 3.
  14456. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14457. */
  14458. getTypeID(): number;
  14459. /**
  14460. * Prepares the list of defines specific to the light type.
  14461. * @param defines the list of defines
  14462. * @param lightIndex defines the index of the light for the effect
  14463. */
  14464. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14465. }
  14466. }
  14467. declare module BABYLON {
  14468. /** @hidden */
  14469. export var vrMultiviewToSingleviewPixelShader: {
  14470. name: string;
  14471. shader: string;
  14472. };
  14473. }
  14474. declare module BABYLON {
  14475. /**
  14476. * Renders to multiple views with a single draw call
  14477. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14478. */
  14479. export class MultiviewRenderTarget extends RenderTargetTexture {
  14480. /**
  14481. * Creates a multiview render target
  14482. * @param scene scene used with the render target
  14483. * @param size the size of the render target (used for each view)
  14484. */
  14485. constructor(scene: Scene, size?: number | {
  14486. width: number;
  14487. height: number;
  14488. } | {
  14489. ratio: number;
  14490. });
  14491. /**
  14492. * @hidden
  14493. * @param faceIndex the face index, if its a cube texture
  14494. */
  14495. _bindFrameBuffer(faceIndex?: number): void;
  14496. /**
  14497. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14498. * @returns the view count
  14499. */
  14500. getViewCount(): number;
  14501. }
  14502. }
  14503. declare module BABYLON {
  14504. /**
  14505. * Reprasents a camera frustum
  14506. */
  14507. export class Frustum {
  14508. /**
  14509. * Gets the planes representing the frustum
  14510. * @param transform matrix to be applied to the returned planes
  14511. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14512. */
  14513. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14514. /**
  14515. * Gets the near frustum plane transformed by the transform matrix
  14516. * @param transform transformation matrix to be applied to the resulting frustum plane
  14517. * @param frustumPlane the resuling frustum plane
  14518. */
  14519. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14520. /**
  14521. * Gets the far frustum plane transformed by the transform matrix
  14522. * @param transform transformation matrix to be applied to the resulting frustum plane
  14523. * @param frustumPlane the resuling frustum plane
  14524. */
  14525. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14526. /**
  14527. * Gets the left frustum plane transformed by the transform matrix
  14528. * @param transform transformation matrix to be applied to the resulting frustum plane
  14529. * @param frustumPlane the resuling frustum plane
  14530. */
  14531. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14532. /**
  14533. * Gets the right frustum plane transformed by the transform matrix
  14534. * @param transform transformation matrix to be applied to the resulting frustum plane
  14535. * @param frustumPlane the resuling frustum plane
  14536. */
  14537. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14538. /**
  14539. * Gets the top frustum plane transformed by the transform matrix
  14540. * @param transform transformation matrix to be applied to the resulting frustum plane
  14541. * @param frustumPlane the resuling frustum plane
  14542. */
  14543. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14544. /**
  14545. * Gets the bottom frustum plane transformed by the transform matrix
  14546. * @param transform transformation matrix to be applied to the resulting frustum plane
  14547. * @param frustumPlane the resuling frustum plane
  14548. */
  14549. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14550. /**
  14551. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14552. * @param transform transformation matrix to be applied to the resulting frustum planes
  14553. * @param frustumPlanes the resuling frustum planes
  14554. */
  14555. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14556. }
  14557. }
  14558. declare module BABYLON {
  14559. interface Engine {
  14560. /**
  14561. * Creates a new multiview render target
  14562. * @param width defines the width of the texture
  14563. * @param height defines the height of the texture
  14564. * @returns the created multiview texture
  14565. */
  14566. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14567. /**
  14568. * Binds a multiview framebuffer to be drawn to
  14569. * @param multiviewTexture texture to bind
  14570. */
  14571. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14572. }
  14573. interface Camera {
  14574. /**
  14575. * @hidden
  14576. * 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)
  14577. */
  14578. _useMultiviewToSingleView: boolean;
  14579. /**
  14580. * @hidden
  14581. * 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)
  14582. */
  14583. _multiviewTexture: Nullable<RenderTargetTexture>;
  14584. /**
  14585. * @hidden
  14586. * ensures the multiview texture of the camera exists and has the specified width/height
  14587. * @param width height to set on the multiview texture
  14588. * @param height width to set on the multiview texture
  14589. */
  14590. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14591. }
  14592. interface Scene {
  14593. /** @hidden */
  14594. _transformMatrixR: Matrix;
  14595. /** @hidden */
  14596. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14597. /** @hidden */
  14598. _createMultiviewUbo(): void;
  14599. /** @hidden */
  14600. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14601. /** @hidden */
  14602. _renderMultiviewToSingleView(camera: Camera): void;
  14603. }
  14604. }
  14605. declare module BABYLON {
  14606. /**
  14607. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14608. * This will not be used for webXR as it supports displaying texture arrays directly
  14609. */
  14610. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14611. /**
  14612. * Initializes a VRMultiviewToSingleview
  14613. * @param name name of the post process
  14614. * @param camera camera to be applied to
  14615. * @param scaleFactor scaling factor to the size of the output texture
  14616. */
  14617. constructor(name: string, camera: Camera, scaleFactor: number);
  14618. }
  14619. }
  14620. declare module BABYLON {
  14621. interface Engine {
  14622. /** @hidden */
  14623. _vrDisplay: any;
  14624. /** @hidden */
  14625. _vrSupported: boolean;
  14626. /** @hidden */
  14627. _oldSize: Size;
  14628. /** @hidden */
  14629. _oldHardwareScaleFactor: number;
  14630. /** @hidden */
  14631. _vrExclusivePointerMode: boolean;
  14632. /** @hidden */
  14633. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14634. /** @hidden */
  14635. _onVRDisplayPointerRestricted: () => void;
  14636. /** @hidden */
  14637. _onVRDisplayPointerUnrestricted: () => void;
  14638. /** @hidden */
  14639. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14640. /** @hidden */
  14641. _onVrDisplayDisconnect: Nullable<() => void>;
  14642. /** @hidden */
  14643. _onVrDisplayPresentChange: Nullable<() => void>;
  14644. /**
  14645. * Observable signaled when VR display mode changes
  14646. */
  14647. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14648. /**
  14649. * Observable signaled when VR request present is complete
  14650. */
  14651. onVRRequestPresentComplete: Observable<boolean>;
  14652. /**
  14653. * Observable signaled when VR request present starts
  14654. */
  14655. onVRRequestPresentStart: Observable<Engine>;
  14656. /**
  14657. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14658. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14659. */
  14660. isInVRExclusivePointerMode: boolean;
  14661. /**
  14662. * Gets a boolean indicating if a webVR device was detected
  14663. * @returns true if a webVR device was detected
  14664. */
  14665. isVRDevicePresent(): boolean;
  14666. /**
  14667. * Gets the current webVR device
  14668. * @returns the current webVR device (or null)
  14669. */
  14670. getVRDevice(): any;
  14671. /**
  14672. * Initializes a webVR display and starts listening to display change events
  14673. * The onVRDisplayChangedObservable will be notified upon these changes
  14674. * @returns A promise containing a VRDisplay and if vr is supported
  14675. */
  14676. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14677. /** @hidden */
  14678. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14679. /**
  14680. * Call this function to switch to webVR mode
  14681. * Will do nothing if webVR is not supported or if there is no webVR device
  14682. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14683. */
  14684. enableVR(): void;
  14685. /** @hidden */
  14686. _onVRFullScreenTriggered(): void;
  14687. }
  14688. }
  14689. declare module BABYLON {
  14690. /**
  14691. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14692. * IMPORTANT!! The data is right-hand data.
  14693. * @export
  14694. * @interface DevicePose
  14695. */
  14696. export interface DevicePose {
  14697. /**
  14698. * The position of the device, values in array are [x,y,z].
  14699. */
  14700. readonly position: Nullable<Float32Array>;
  14701. /**
  14702. * The linearVelocity of the device, values in array are [x,y,z].
  14703. */
  14704. readonly linearVelocity: Nullable<Float32Array>;
  14705. /**
  14706. * The linearAcceleration of the device, values in array are [x,y,z].
  14707. */
  14708. readonly linearAcceleration: Nullable<Float32Array>;
  14709. /**
  14710. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14711. */
  14712. readonly orientation: Nullable<Float32Array>;
  14713. /**
  14714. * The angularVelocity of the device, values in array are [x,y,z].
  14715. */
  14716. readonly angularVelocity: Nullable<Float32Array>;
  14717. /**
  14718. * The angularAcceleration of the device, values in array are [x,y,z].
  14719. */
  14720. readonly angularAcceleration: Nullable<Float32Array>;
  14721. }
  14722. /**
  14723. * Interface representing a pose controlled object in Babylon.
  14724. * A pose controlled object has both regular pose values as well as pose values
  14725. * from an external device such as a VR head mounted display
  14726. */
  14727. export interface PoseControlled {
  14728. /**
  14729. * The position of the object in babylon space.
  14730. */
  14731. position: Vector3;
  14732. /**
  14733. * The rotation quaternion of the object in babylon space.
  14734. */
  14735. rotationQuaternion: Quaternion;
  14736. /**
  14737. * The position of the device in babylon space.
  14738. */
  14739. devicePosition?: Vector3;
  14740. /**
  14741. * The rotation quaternion of the device in babylon space.
  14742. */
  14743. deviceRotationQuaternion: Quaternion;
  14744. /**
  14745. * The raw pose coming from the device.
  14746. */
  14747. rawPose: Nullable<DevicePose>;
  14748. /**
  14749. * The scale of the device to be used when translating from device space to babylon space.
  14750. */
  14751. deviceScaleFactor: number;
  14752. /**
  14753. * Updates the poseControlled values based on the input device pose.
  14754. * @param poseData the pose data to update the object with
  14755. */
  14756. updateFromDevice(poseData: DevicePose): void;
  14757. }
  14758. /**
  14759. * Set of options to customize the webVRCamera
  14760. */
  14761. export interface WebVROptions {
  14762. /**
  14763. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14764. */
  14765. trackPosition?: boolean;
  14766. /**
  14767. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14768. */
  14769. positionScale?: number;
  14770. /**
  14771. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14772. */
  14773. displayName?: string;
  14774. /**
  14775. * Should the native controller meshes be initialized. (default: true)
  14776. */
  14777. controllerMeshes?: boolean;
  14778. /**
  14779. * Creating a default HemiLight only on controllers. (default: true)
  14780. */
  14781. defaultLightingOnControllers?: boolean;
  14782. /**
  14783. * If you don't want to use the default VR button of the helper. (default: false)
  14784. */
  14785. useCustomVRButton?: boolean;
  14786. /**
  14787. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14788. */
  14789. customVRButton?: HTMLButtonElement;
  14790. /**
  14791. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14792. */
  14793. rayLength?: number;
  14794. /**
  14795. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14796. */
  14797. defaultHeight?: number;
  14798. /**
  14799. * If multiview should be used if availible (default: false)
  14800. */
  14801. useMultiview?: boolean;
  14802. }
  14803. /**
  14804. * This represents a WebVR camera.
  14805. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14806. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14807. */
  14808. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14809. private webVROptions;
  14810. /**
  14811. * @hidden
  14812. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14813. */
  14814. _vrDevice: any;
  14815. /**
  14816. * The rawPose of the vrDevice.
  14817. */
  14818. rawPose: Nullable<DevicePose>;
  14819. private _onVREnabled;
  14820. private _specsVersion;
  14821. private _attached;
  14822. private _frameData;
  14823. protected _descendants: Array<Node>;
  14824. private _deviceRoomPosition;
  14825. /** @hidden */
  14826. _deviceRoomRotationQuaternion: Quaternion;
  14827. private _standingMatrix;
  14828. /**
  14829. * Represents device position in babylon space.
  14830. */
  14831. devicePosition: Vector3;
  14832. /**
  14833. * Represents device rotation in babylon space.
  14834. */
  14835. deviceRotationQuaternion: Quaternion;
  14836. /**
  14837. * The scale of the device to be used when translating from device space to babylon space.
  14838. */
  14839. deviceScaleFactor: number;
  14840. private _deviceToWorld;
  14841. private _worldToDevice;
  14842. /**
  14843. * References to the webVR controllers for the vrDevice.
  14844. */
  14845. controllers: Array<WebVRController>;
  14846. /**
  14847. * Emits an event when a controller is attached.
  14848. */
  14849. onControllersAttachedObservable: Observable<WebVRController[]>;
  14850. /**
  14851. * Emits an event when a controller's mesh has been loaded;
  14852. */
  14853. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14854. /**
  14855. * Emits an event when the HMD's pose has been updated.
  14856. */
  14857. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14858. private _poseSet;
  14859. /**
  14860. * If the rig cameras be used as parent instead of this camera.
  14861. */
  14862. rigParenting: boolean;
  14863. private _lightOnControllers;
  14864. private _defaultHeight?;
  14865. /**
  14866. * Instantiates a WebVRFreeCamera.
  14867. * @param name The name of the WebVRFreeCamera
  14868. * @param position The starting anchor position for the camera
  14869. * @param scene The scene the camera belongs to
  14870. * @param webVROptions a set of customizable options for the webVRCamera
  14871. */
  14872. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14873. /**
  14874. * Gets the device distance from the ground in meters.
  14875. * @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.
  14876. */
  14877. deviceDistanceToRoomGround(): number;
  14878. /**
  14879. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14880. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14881. */
  14882. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14883. /**
  14884. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14885. * @returns A promise with a boolean set to if the standing matrix is supported.
  14886. */
  14887. useStandingMatrixAsync(): Promise<boolean>;
  14888. /**
  14889. * Disposes the camera
  14890. */
  14891. dispose(): void;
  14892. /**
  14893. * Gets a vrController by name.
  14894. * @param name The name of the controller to retreive
  14895. * @returns the controller matching the name specified or null if not found
  14896. */
  14897. getControllerByName(name: string): Nullable<WebVRController>;
  14898. private _leftController;
  14899. /**
  14900. * The controller corresponding to the users left hand.
  14901. */
  14902. readonly leftController: Nullable<WebVRController>;
  14903. private _rightController;
  14904. /**
  14905. * The controller corresponding to the users right hand.
  14906. */
  14907. readonly rightController: Nullable<WebVRController>;
  14908. /**
  14909. * Casts a ray forward from the vrCamera's gaze.
  14910. * @param length Length of the ray (default: 100)
  14911. * @returns the ray corresponding to the gaze
  14912. */
  14913. getForwardRay(length?: number): Ray;
  14914. /**
  14915. * @hidden
  14916. * Updates the camera based on device's frame data
  14917. */
  14918. _checkInputs(): void;
  14919. /**
  14920. * Updates the poseControlled values based on the input device pose.
  14921. * @param poseData Pose coming from the device
  14922. */
  14923. updateFromDevice(poseData: DevicePose): void;
  14924. private _htmlElementAttached;
  14925. private _detachIfAttached;
  14926. /**
  14927. * WebVR's attach control will start broadcasting frames to the device.
  14928. * Note that in certain browsers (chrome for example) this function must be called
  14929. * within a user-interaction callback. Example:
  14930. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14931. *
  14932. * @param element html element to attach the vrDevice to
  14933. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14934. */
  14935. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14936. /**
  14937. * Detaches the camera from the html element and disables VR
  14938. *
  14939. * @param element html element to detach from
  14940. */
  14941. detachControl(element: HTMLElement): void;
  14942. /**
  14943. * @returns the name of this class
  14944. */
  14945. getClassName(): string;
  14946. /**
  14947. * Calls resetPose on the vrDisplay
  14948. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  14949. */
  14950. resetToCurrentRotation(): void;
  14951. /**
  14952. * @hidden
  14953. * Updates the rig cameras (left and right eye)
  14954. */
  14955. _updateRigCameras(): void;
  14956. private _workingVector;
  14957. private _oneVector;
  14958. private _workingMatrix;
  14959. private updateCacheCalled;
  14960. private _correctPositionIfNotTrackPosition;
  14961. /**
  14962. * @hidden
  14963. * Updates the cached values of the camera
  14964. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  14965. */
  14966. _updateCache(ignoreParentClass?: boolean): void;
  14967. /**
  14968. * @hidden
  14969. * Get current device position in babylon world
  14970. */
  14971. _computeDevicePosition(): void;
  14972. /**
  14973. * Updates the current device position and rotation in the babylon world
  14974. */
  14975. update(): void;
  14976. /**
  14977. * @hidden
  14978. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  14979. * @returns an identity matrix
  14980. */
  14981. _getViewMatrix(): Matrix;
  14982. private _tmpMatrix;
  14983. /**
  14984. * This function is called by the two RIG cameras.
  14985. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  14986. * @hidden
  14987. */
  14988. _getWebVRViewMatrix(): Matrix;
  14989. /** @hidden */
  14990. _getWebVRProjectionMatrix(): Matrix;
  14991. private _onGamepadConnectedObserver;
  14992. private _onGamepadDisconnectedObserver;
  14993. private _updateCacheWhenTrackingDisabledObserver;
  14994. /**
  14995. * Initializes the controllers and their meshes
  14996. */
  14997. initControllers(): void;
  14998. }
  14999. }
  15000. declare module BABYLON {
  15001. /**
  15002. * Size options for a post process
  15003. */
  15004. export type PostProcessOptions = {
  15005. width: number;
  15006. height: number;
  15007. };
  15008. /**
  15009. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15010. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15011. */
  15012. export class PostProcess {
  15013. /** Name of the PostProcess. */
  15014. name: string;
  15015. /**
  15016. * Gets or sets the unique id of the post process
  15017. */
  15018. uniqueId: number;
  15019. /**
  15020. * Width of the texture to apply the post process on
  15021. */
  15022. width: number;
  15023. /**
  15024. * Height of the texture to apply the post process on
  15025. */
  15026. height: number;
  15027. /**
  15028. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15029. * @hidden
  15030. */
  15031. _outputTexture: Nullable<InternalTexture>;
  15032. /**
  15033. * Sampling mode used by the shader
  15034. * See https://doc.babylonjs.com/classes/3.1/texture
  15035. */
  15036. renderTargetSamplingMode: number;
  15037. /**
  15038. * Clear color to use when screen clearing
  15039. */
  15040. clearColor: Color4;
  15041. /**
  15042. * If the buffer needs to be cleared before applying the post process. (default: true)
  15043. * Should be set to false if shader will overwrite all previous pixels.
  15044. */
  15045. autoClear: boolean;
  15046. /**
  15047. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15048. */
  15049. alphaMode: number;
  15050. /**
  15051. * Sets the setAlphaBlendConstants of the babylon engine
  15052. */
  15053. alphaConstants: Color4;
  15054. /**
  15055. * Animations to be used for the post processing
  15056. */
  15057. animations: Animation[];
  15058. /**
  15059. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15060. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15061. */
  15062. enablePixelPerfectMode: boolean;
  15063. /**
  15064. * Force the postprocess to be applied without taking in account viewport
  15065. */
  15066. forceFullscreenViewport: boolean;
  15067. /**
  15068. * List of inspectable custom properties (used by the Inspector)
  15069. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15070. */
  15071. inspectableCustomProperties: IInspectable[];
  15072. /**
  15073. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15074. *
  15075. * | Value | Type | Description |
  15076. * | ----- | ----------------------------------- | ----------- |
  15077. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15078. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15079. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15080. *
  15081. */
  15082. scaleMode: number;
  15083. /**
  15084. * Force textures to be a power of two (default: false)
  15085. */
  15086. alwaysForcePOT: boolean;
  15087. private _samples;
  15088. /**
  15089. * Number of sample textures (default: 1)
  15090. */
  15091. samples: number;
  15092. /**
  15093. * Modify the scale of the post process to be the same as the viewport (default: false)
  15094. */
  15095. adaptScaleToCurrentViewport: boolean;
  15096. private _camera;
  15097. private _scene;
  15098. private _engine;
  15099. private _options;
  15100. private _reusable;
  15101. private _textureType;
  15102. /**
  15103. * Smart array of input and output textures for the post process.
  15104. * @hidden
  15105. */
  15106. _textures: SmartArray<InternalTexture>;
  15107. /**
  15108. * The index in _textures that corresponds to the output texture.
  15109. * @hidden
  15110. */
  15111. _currentRenderTextureInd: number;
  15112. private _effect;
  15113. private _samplers;
  15114. private _fragmentUrl;
  15115. private _vertexUrl;
  15116. private _parameters;
  15117. private _scaleRatio;
  15118. protected _indexParameters: any;
  15119. private _shareOutputWithPostProcess;
  15120. private _texelSize;
  15121. private _forcedOutputTexture;
  15122. /**
  15123. * Returns the fragment url or shader name used in the post process.
  15124. * @returns the fragment url or name in the shader store.
  15125. */
  15126. getEffectName(): string;
  15127. /**
  15128. * An event triggered when the postprocess is activated.
  15129. */
  15130. onActivateObservable: Observable<Camera>;
  15131. private _onActivateObserver;
  15132. /**
  15133. * A function that is added to the onActivateObservable
  15134. */
  15135. onActivate: Nullable<(camera: Camera) => void>;
  15136. /**
  15137. * An event triggered when the postprocess changes its size.
  15138. */
  15139. onSizeChangedObservable: Observable<PostProcess>;
  15140. private _onSizeChangedObserver;
  15141. /**
  15142. * A function that is added to the onSizeChangedObservable
  15143. */
  15144. onSizeChanged: (postProcess: PostProcess) => void;
  15145. /**
  15146. * An event triggered when the postprocess applies its effect.
  15147. */
  15148. onApplyObservable: Observable<Effect>;
  15149. private _onApplyObserver;
  15150. /**
  15151. * A function that is added to the onApplyObservable
  15152. */
  15153. onApply: (effect: Effect) => void;
  15154. /**
  15155. * An event triggered before rendering the postprocess
  15156. */
  15157. onBeforeRenderObservable: Observable<Effect>;
  15158. private _onBeforeRenderObserver;
  15159. /**
  15160. * A function that is added to the onBeforeRenderObservable
  15161. */
  15162. onBeforeRender: (effect: Effect) => void;
  15163. /**
  15164. * An event triggered after rendering the postprocess
  15165. */
  15166. onAfterRenderObservable: Observable<Effect>;
  15167. private _onAfterRenderObserver;
  15168. /**
  15169. * A function that is added to the onAfterRenderObservable
  15170. */
  15171. onAfterRender: (efect: Effect) => void;
  15172. /**
  15173. * 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
  15174. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15175. */
  15176. inputTexture: InternalTexture;
  15177. /**
  15178. * Gets the camera which post process is applied to.
  15179. * @returns The camera the post process is applied to.
  15180. */
  15181. getCamera(): Camera;
  15182. /**
  15183. * Gets the texel size of the postprocess.
  15184. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15185. */
  15186. readonly texelSize: Vector2;
  15187. /**
  15188. * Creates a new instance PostProcess
  15189. * @param name The name of the PostProcess.
  15190. * @param fragmentUrl The url of the fragment shader to be used.
  15191. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15192. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15193. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15194. * @param camera The camera to apply the render pass to.
  15195. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15196. * @param engine The engine which the post process will be applied. (default: current engine)
  15197. * @param reusable If the post process can be reused on the same frame. (default: false)
  15198. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15199. * @param textureType Type of textures used when performing the post process. (default: 0)
  15200. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15201. * @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
  15202. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15203. */
  15204. constructor(
  15205. /** Name of the PostProcess. */
  15206. 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);
  15207. /**
  15208. * Gets a string idenfifying the name of the class
  15209. * @returns "PostProcess" string
  15210. */
  15211. getClassName(): string;
  15212. /**
  15213. * Gets the engine which this post process belongs to.
  15214. * @returns The engine the post process was enabled with.
  15215. */
  15216. getEngine(): Engine;
  15217. /**
  15218. * The effect that is created when initializing the post process.
  15219. * @returns The created effect corresponding the the postprocess.
  15220. */
  15221. getEffect(): Effect;
  15222. /**
  15223. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15224. * @param postProcess The post process to share the output with.
  15225. * @returns This post process.
  15226. */
  15227. shareOutputWith(postProcess: PostProcess): PostProcess;
  15228. /**
  15229. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15230. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15231. */
  15232. useOwnOutput(): void;
  15233. /**
  15234. * Updates the effect with the current post process compile time values and recompiles the shader.
  15235. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15236. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15237. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15238. * @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
  15239. * @param onCompiled Called when the shader has been compiled.
  15240. * @param onError Called if there is an error when compiling a shader.
  15241. */
  15242. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15243. /**
  15244. * The post process is reusable if it can be used multiple times within one frame.
  15245. * @returns If the post process is reusable
  15246. */
  15247. isReusable(): boolean;
  15248. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15249. markTextureDirty(): void;
  15250. /**
  15251. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15252. * 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.
  15253. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15254. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15255. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15256. * @returns The target texture that was bound to be written to.
  15257. */
  15258. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15259. /**
  15260. * If the post process is supported.
  15261. */
  15262. readonly isSupported: boolean;
  15263. /**
  15264. * The aspect ratio of the output texture.
  15265. */
  15266. readonly aspectRatio: number;
  15267. /**
  15268. * Get a value indicating if the post-process is ready to be used
  15269. * @returns true if the post-process is ready (shader is compiled)
  15270. */
  15271. isReady(): boolean;
  15272. /**
  15273. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15274. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15275. */
  15276. apply(): Nullable<Effect>;
  15277. private _disposeTextures;
  15278. /**
  15279. * Disposes the post process.
  15280. * @param camera The camera to dispose the post process on.
  15281. */
  15282. dispose(camera?: Camera): void;
  15283. }
  15284. }
  15285. declare module BABYLON {
  15286. /** @hidden */
  15287. export var kernelBlurVaryingDeclaration: {
  15288. name: string;
  15289. shader: string;
  15290. };
  15291. }
  15292. declare module BABYLON {
  15293. /** @hidden */
  15294. export var kernelBlurFragment: {
  15295. name: string;
  15296. shader: string;
  15297. };
  15298. }
  15299. declare module BABYLON {
  15300. /** @hidden */
  15301. export var kernelBlurFragment2: {
  15302. name: string;
  15303. shader: string;
  15304. };
  15305. }
  15306. declare module BABYLON {
  15307. /** @hidden */
  15308. export var kernelBlurPixelShader: {
  15309. name: string;
  15310. shader: string;
  15311. };
  15312. }
  15313. declare module BABYLON {
  15314. /** @hidden */
  15315. export var kernelBlurVertex: {
  15316. name: string;
  15317. shader: string;
  15318. };
  15319. }
  15320. declare module BABYLON {
  15321. /** @hidden */
  15322. export var kernelBlurVertexShader: {
  15323. name: string;
  15324. shader: string;
  15325. };
  15326. }
  15327. declare module BABYLON {
  15328. /**
  15329. * The Blur Post Process which blurs an image based on a kernel and direction.
  15330. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15331. */
  15332. export class BlurPostProcess extends PostProcess {
  15333. /** The direction in which to blur the image. */
  15334. direction: Vector2;
  15335. private blockCompilation;
  15336. protected _kernel: number;
  15337. protected _idealKernel: number;
  15338. protected _packedFloat: boolean;
  15339. private _staticDefines;
  15340. /**
  15341. * Sets the length in pixels of the blur sample region
  15342. */
  15343. /**
  15344. * Gets the length in pixels of the blur sample region
  15345. */
  15346. kernel: number;
  15347. /**
  15348. * Sets wether or not the blur needs to unpack/repack floats
  15349. */
  15350. /**
  15351. * Gets wether or not the blur is unpacking/repacking floats
  15352. */
  15353. packedFloat: boolean;
  15354. /**
  15355. * Creates a new instance BlurPostProcess
  15356. * @param name The name of the effect.
  15357. * @param direction The direction in which to blur the image.
  15358. * @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.
  15359. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15360. * @param camera The camera to apply the render pass to.
  15361. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15362. * @param engine The engine which the post process will be applied. (default: current engine)
  15363. * @param reusable If the post process can be reused on the same frame. (default: false)
  15364. * @param textureType Type of textures used when performing the post process. (default: 0)
  15365. * @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)
  15366. */
  15367. constructor(name: string,
  15368. /** The direction in which to blur the image. */
  15369. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15370. /**
  15371. * Updates the effect with the current post process compile time values and recompiles the shader.
  15372. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15373. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15374. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15375. * @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
  15376. * @param onCompiled Called when the shader has been compiled.
  15377. * @param onError Called if there is an error when compiling a shader.
  15378. */
  15379. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15380. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15381. /**
  15382. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15383. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15384. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15385. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15386. * The gaps between physical kernels are compensated for in the weighting of the samples
  15387. * @param idealKernel Ideal blur kernel.
  15388. * @return Nearest best kernel.
  15389. */
  15390. protected _nearestBestKernel(idealKernel: number): number;
  15391. /**
  15392. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15393. * @param x The point on the Gaussian distribution to sample.
  15394. * @return the value of the Gaussian function at x.
  15395. */
  15396. protected _gaussianWeight(x: number): number;
  15397. /**
  15398. * Generates a string that can be used as a floating point number in GLSL.
  15399. * @param x Value to print.
  15400. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15401. * @return GLSL float string.
  15402. */
  15403. protected _glslFloat(x: number, decimalFigures?: number): string;
  15404. }
  15405. }
  15406. declare module BABYLON {
  15407. /**
  15408. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15409. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15410. * You can then easily use it as a reflectionTexture on a flat surface.
  15411. * In case the surface is not a plane, please consider relying on reflection probes.
  15412. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15413. */
  15414. export class MirrorTexture extends RenderTargetTexture {
  15415. private scene;
  15416. /**
  15417. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15418. * 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.
  15419. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15420. */
  15421. mirrorPlane: Plane;
  15422. /**
  15423. * Define the blur ratio used to blur the reflection if needed.
  15424. */
  15425. blurRatio: number;
  15426. /**
  15427. * Define the adaptive blur kernel used to blur the reflection if needed.
  15428. * This will autocompute the closest best match for the `blurKernel`
  15429. */
  15430. adaptiveBlurKernel: number;
  15431. /**
  15432. * Define the blur kernel used to blur the reflection if needed.
  15433. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15434. */
  15435. blurKernel: number;
  15436. /**
  15437. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15438. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15439. */
  15440. blurKernelX: number;
  15441. /**
  15442. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15443. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15444. */
  15445. blurKernelY: number;
  15446. private _autoComputeBlurKernel;
  15447. protected _onRatioRescale(): void;
  15448. private _updateGammaSpace;
  15449. private _imageProcessingConfigChangeObserver;
  15450. private _transformMatrix;
  15451. private _mirrorMatrix;
  15452. private _savedViewMatrix;
  15453. private _blurX;
  15454. private _blurY;
  15455. private _adaptiveBlurKernel;
  15456. private _blurKernelX;
  15457. private _blurKernelY;
  15458. private _blurRatio;
  15459. /**
  15460. * Instantiates a Mirror Texture.
  15461. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15462. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15463. * You can then easily use it as a reflectionTexture on a flat surface.
  15464. * In case the surface is not a plane, please consider relying on reflection probes.
  15465. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15466. * @param name
  15467. * @param size
  15468. * @param scene
  15469. * @param generateMipMaps
  15470. * @param type
  15471. * @param samplingMode
  15472. * @param generateDepthBuffer
  15473. */
  15474. constructor(name: string, size: number | {
  15475. width: number;
  15476. height: number;
  15477. } | {
  15478. ratio: number;
  15479. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15480. private _preparePostProcesses;
  15481. /**
  15482. * Clone the mirror texture.
  15483. * @returns the cloned texture
  15484. */
  15485. clone(): MirrorTexture;
  15486. /**
  15487. * Serialize the texture to a JSON representation you could use in Parse later on
  15488. * @returns the serialized JSON representation
  15489. */
  15490. serialize(): any;
  15491. /**
  15492. * Dispose the texture and release its associated resources.
  15493. */
  15494. dispose(): void;
  15495. }
  15496. }
  15497. declare module BABYLON {
  15498. /**
  15499. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15500. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15501. */
  15502. export class Texture extends BaseTexture {
  15503. /** @hidden */
  15504. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15505. /** @hidden */
  15506. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15507. /** @hidden */
  15508. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15509. /** nearest is mag = nearest and min = nearest and mip = linear */
  15510. static readonly NEAREST_SAMPLINGMODE: number;
  15511. /** nearest is mag = nearest and min = nearest and mip = linear */
  15512. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15513. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15514. static readonly BILINEAR_SAMPLINGMODE: number;
  15515. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15516. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15517. /** Trilinear is mag = linear and min = linear and mip = linear */
  15518. static readonly TRILINEAR_SAMPLINGMODE: number;
  15519. /** Trilinear is mag = linear and min = linear and mip = linear */
  15520. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15521. /** mag = nearest and min = nearest and mip = nearest */
  15522. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15523. /** mag = nearest and min = linear and mip = nearest */
  15524. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15525. /** mag = nearest and min = linear and mip = linear */
  15526. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15527. /** mag = nearest and min = linear and mip = none */
  15528. static readonly NEAREST_LINEAR: number;
  15529. /** mag = nearest and min = nearest and mip = none */
  15530. static readonly NEAREST_NEAREST: number;
  15531. /** mag = linear and min = nearest and mip = nearest */
  15532. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15533. /** mag = linear and min = nearest and mip = linear */
  15534. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15535. /** mag = linear and min = linear and mip = none */
  15536. static readonly LINEAR_LINEAR: number;
  15537. /** mag = linear and min = nearest and mip = none */
  15538. static readonly LINEAR_NEAREST: number;
  15539. /** Explicit coordinates mode */
  15540. static readonly EXPLICIT_MODE: number;
  15541. /** Spherical coordinates mode */
  15542. static readonly SPHERICAL_MODE: number;
  15543. /** Planar coordinates mode */
  15544. static readonly PLANAR_MODE: number;
  15545. /** Cubic coordinates mode */
  15546. static readonly CUBIC_MODE: number;
  15547. /** Projection coordinates mode */
  15548. static readonly PROJECTION_MODE: number;
  15549. /** Inverse Cubic coordinates mode */
  15550. static readonly SKYBOX_MODE: number;
  15551. /** Inverse Cubic coordinates mode */
  15552. static readonly INVCUBIC_MODE: number;
  15553. /** Equirectangular coordinates mode */
  15554. static readonly EQUIRECTANGULAR_MODE: number;
  15555. /** Equirectangular Fixed coordinates mode */
  15556. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15557. /** Equirectangular Fixed Mirrored coordinates mode */
  15558. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15559. /** Texture is not repeating outside of 0..1 UVs */
  15560. static readonly CLAMP_ADDRESSMODE: number;
  15561. /** Texture is repeating outside of 0..1 UVs */
  15562. static readonly WRAP_ADDRESSMODE: number;
  15563. /** Texture is repeating and mirrored */
  15564. static readonly MIRROR_ADDRESSMODE: number;
  15565. /**
  15566. * 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
  15567. */
  15568. static UseSerializedUrlIfAny: boolean;
  15569. /**
  15570. * Define the url of the texture.
  15571. */
  15572. url: Nullable<string>;
  15573. /**
  15574. * Define an offset on the texture to offset the u coordinates of the UVs
  15575. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15576. */
  15577. uOffset: number;
  15578. /**
  15579. * Define an offset on the texture to offset the v coordinates of the UVs
  15580. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15581. */
  15582. vOffset: number;
  15583. /**
  15584. * Define an offset on the texture to scale the u coordinates of the UVs
  15585. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15586. */
  15587. uScale: number;
  15588. /**
  15589. * Define an offset on the texture to scale the v coordinates of the UVs
  15590. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15591. */
  15592. vScale: number;
  15593. /**
  15594. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15595. * @see http://doc.babylonjs.com/how_to/more_materials
  15596. */
  15597. uAng: number;
  15598. /**
  15599. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15600. * @see http://doc.babylonjs.com/how_to/more_materials
  15601. */
  15602. vAng: number;
  15603. /**
  15604. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15605. * @see http://doc.babylonjs.com/how_to/more_materials
  15606. */
  15607. wAng: number;
  15608. /**
  15609. * Defines the center of rotation (U)
  15610. */
  15611. uRotationCenter: number;
  15612. /**
  15613. * Defines the center of rotation (V)
  15614. */
  15615. vRotationCenter: number;
  15616. /**
  15617. * Defines the center of rotation (W)
  15618. */
  15619. wRotationCenter: number;
  15620. /**
  15621. * Are mip maps generated for this texture or not.
  15622. */
  15623. readonly noMipmap: boolean;
  15624. /**
  15625. * List of inspectable custom properties (used by the Inspector)
  15626. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15627. */
  15628. inspectableCustomProperties: Nullable<IInspectable[]>;
  15629. private _noMipmap;
  15630. /** @hidden */
  15631. _invertY: boolean;
  15632. private _rowGenerationMatrix;
  15633. private _cachedTextureMatrix;
  15634. private _projectionModeMatrix;
  15635. private _t0;
  15636. private _t1;
  15637. private _t2;
  15638. private _cachedUOffset;
  15639. private _cachedVOffset;
  15640. private _cachedUScale;
  15641. private _cachedVScale;
  15642. private _cachedUAng;
  15643. private _cachedVAng;
  15644. private _cachedWAng;
  15645. private _cachedProjectionMatrixId;
  15646. private _cachedCoordinatesMode;
  15647. /** @hidden */
  15648. protected _initialSamplingMode: number;
  15649. /** @hidden */
  15650. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  15651. private _deleteBuffer;
  15652. protected _format: Nullable<number>;
  15653. private _delayedOnLoad;
  15654. private _delayedOnError;
  15655. /**
  15656. * Observable triggered once the texture has been loaded.
  15657. */
  15658. onLoadObservable: Observable<Texture>;
  15659. protected _isBlocking: boolean;
  15660. /**
  15661. * Is the texture preventing material to render while loading.
  15662. * If false, a default texture will be used instead of the loading one during the preparation step.
  15663. */
  15664. isBlocking: boolean;
  15665. /**
  15666. * Get the current sampling mode associated with the texture.
  15667. */
  15668. readonly samplingMode: number;
  15669. /**
  15670. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15671. */
  15672. readonly invertY: boolean;
  15673. /**
  15674. * Instantiates a new texture.
  15675. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15676. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15677. * @param url define the url of the picture to load as a texture
  15678. * @param scene define the scene or engine the texture will belong to
  15679. * @param noMipmap define if the texture will require mip maps or not
  15680. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15681. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15682. * @param onLoad define a callback triggered when the texture has been loaded
  15683. * @param onError define a callback triggered when an error occurred during the loading session
  15684. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15685. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15686. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15687. */
  15688. 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);
  15689. /**
  15690. * Update the url (and optional buffer) of this texture if url was null during construction.
  15691. * @param url the url of the texture
  15692. * @param buffer the buffer of the texture (defaults to null)
  15693. * @param onLoad callback called when the texture is loaded (defaults to null)
  15694. */
  15695. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15696. /**
  15697. * Finish the loading sequence of a texture flagged as delayed load.
  15698. * @hidden
  15699. */
  15700. delayLoad(): void;
  15701. private _prepareRowForTextureGeneration;
  15702. /**
  15703. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15704. * @returns the transform matrix of the texture.
  15705. */
  15706. getTextureMatrix(): Matrix;
  15707. /**
  15708. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15709. * @returns The reflection texture transform
  15710. */
  15711. getReflectionTextureMatrix(): Matrix;
  15712. /**
  15713. * Clones the texture.
  15714. * @returns the cloned texture
  15715. */
  15716. clone(): Texture;
  15717. /**
  15718. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15719. * @returns The JSON representation of the texture
  15720. */
  15721. serialize(): any;
  15722. /**
  15723. * Get the current class name of the texture useful for serialization or dynamic coding.
  15724. * @returns "Texture"
  15725. */
  15726. getClassName(): string;
  15727. /**
  15728. * Dispose the texture and release its associated resources.
  15729. */
  15730. dispose(): void;
  15731. /**
  15732. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15733. * @param parsedTexture Define the JSON representation of the texture
  15734. * @param scene Define the scene the parsed texture should be instantiated in
  15735. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15736. * @returns The parsed texture if successful
  15737. */
  15738. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15739. /**
  15740. * Creates a texture from its base 64 representation.
  15741. * @param data Define the base64 payload without the data: prefix
  15742. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15743. * @param scene Define the scene the texture should belong to
  15744. * @param noMipmap Forces the texture to not create mip map information if true
  15745. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15746. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15747. * @param onLoad define a callback triggered when the texture has been loaded
  15748. * @param onError define a callback triggered when an error occurred during the loading session
  15749. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15750. * @returns the created texture
  15751. */
  15752. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15753. /**
  15754. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15755. * @param data Define the base64 payload without the data: prefix
  15756. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15757. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15758. * @param scene Define the scene the texture should belong to
  15759. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15760. * @param noMipmap Forces the texture to not create mip map information if true
  15761. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15762. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15763. * @param onLoad define a callback triggered when the texture has been loaded
  15764. * @param onError define a callback triggered when an error occurred during the loading session
  15765. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15766. * @returns the created texture
  15767. */
  15768. 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;
  15769. }
  15770. }
  15771. declare module BABYLON {
  15772. /**
  15773. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15774. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15775. */
  15776. export class PostProcessManager {
  15777. private _scene;
  15778. private _indexBuffer;
  15779. private _vertexBuffers;
  15780. /**
  15781. * Creates a new instance PostProcess
  15782. * @param scene The scene that the post process is associated with.
  15783. */
  15784. constructor(scene: Scene);
  15785. private _prepareBuffers;
  15786. private _buildIndexBuffer;
  15787. /**
  15788. * Rebuilds the vertex buffers of the manager.
  15789. * @hidden
  15790. */
  15791. _rebuild(): void;
  15792. /**
  15793. * Prepares a frame to be run through a post process.
  15794. * @param sourceTexture The input texture to the post procesess. (default: null)
  15795. * @param postProcesses An array of post processes to be run. (default: null)
  15796. * @returns True if the post processes were able to be run.
  15797. * @hidden
  15798. */
  15799. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15800. /**
  15801. * Manually render a set of post processes to a texture.
  15802. * @param postProcesses An array of post processes to be run.
  15803. * @param targetTexture The target texture to render to.
  15804. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15805. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15806. * @param lodLevel defines which lod of the texture to render to
  15807. */
  15808. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15809. /**
  15810. * Finalize the result of the output of the postprocesses.
  15811. * @param doNotPresent If true the result will not be displayed to the screen.
  15812. * @param targetTexture The target texture to render to.
  15813. * @param faceIndex The index of the face to bind the target texture to.
  15814. * @param postProcesses The array of post processes to render.
  15815. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15816. * @hidden
  15817. */
  15818. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15819. /**
  15820. * Disposes of the post process manager.
  15821. */
  15822. dispose(): void;
  15823. }
  15824. }
  15825. declare module BABYLON {
  15826. /** Interface used by value gradients (color, factor, ...) */
  15827. export interface IValueGradient {
  15828. /**
  15829. * Gets or sets the gradient value (between 0 and 1)
  15830. */
  15831. gradient: number;
  15832. }
  15833. /** Class used to store color4 gradient */
  15834. export class ColorGradient implements IValueGradient {
  15835. /**
  15836. * Gets or sets the gradient value (between 0 and 1)
  15837. */
  15838. gradient: number;
  15839. /**
  15840. * Gets or sets first associated color
  15841. */
  15842. color1: Color4;
  15843. /**
  15844. * Gets or sets second associated color
  15845. */
  15846. color2?: Color4;
  15847. /**
  15848. * Will get a color picked randomly between color1 and color2.
  15849. * If color2 is undefined then color1 will be used
  15850. * @param result defines the target Color4 to store the result in
  15851. */
  15852. getColorToRef(result: Color4): void;
  15853. }
  15854. /** Class used to store color 3 gradient */
  15855. export class Color3Gradient implements IValueGradient {
  15856. /**
  15857. * Gets or sets the gradient value (between 0 and 1)
  15858. */
  15859. gradient: number;
  15860. /**
  15861. * Gets or sets the associated color
  15862. */
  15863. color: Color3;
  15864. }
  15865. /** Class used to store factor gradient */
  15866. export class FactorGradient implements IValueGradient {
  15867. /**
  15868. * Gets or sets the gradient value (between 0 and 1)
  15869. */
  15870. gradient: number;
  15871. /**
  15872. * Gets or sets first associated factor
  15873. */
  15874. factor1: number;
  15875. /**
  15876. * Gets or sets second associated factor
  15877. */
  15878. factor2?: number;
  15879. /**
  15880. * Will get a number picked randomly between factor1 and factor2.
  15881. * If factor2 is undefined then factor1 will be used
  15882. * @returns the picked number
  15883. */
  15884. getFactor(): number;
  15885. }
  15886. /**
  15887. * Helper used to simplify some generic gradient tasks
  15888. */
  15889. export class GradientHelper {
  15890. /**
  15891. * Gets the current gradient from an array of IValueGradient
  15892. * @param ratio defines the current ratio to get
  15893. * @param gradients defines the array of IValueGradient
  15894. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15895. */
  15896. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15897. }
  15898. }
  15899. declare module BABYLON {
  15900. interface AbstractScene {
  15901. /**
  15902. * The list of procedural textures added to the scene
  15903. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15904. */
  15905. proceduralTextures: Array<ProceduralTexture>;
  15906. }
  15907. /**
  15908. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  15909. * in a given scene.
  15910. */
  15911. export class ProceduralTextureSceneComponent implements ISceneComponent {
  15912. /**
  15913. * The component name helpfull to identify the component in the list of scene components.
  15914. */
  15915. readonly name: string;
  15916. /**
  15917. * The scene the component belongs to.
  15918. */
  15919. scene: Scene;
  15920. /**
  15921. * Creates a new instance of the component for the given scene
  15922. * @param scene Defines the scene to register the component in
  15923. */
  15924. constructor(scene: Scene);
  15925. /**
  15926. * Registers the component in a given scene
  15927. */
  15928. register(): void;
  15929. /**
  15930. * Rebuilds the elements related to this component in case of
  15931. * context lost for instance.
  15932. */
  15933. rebuild(): void;
  15934. /**
  15935. * Disposes the component and the associated ressources.
  15936. */
  15937. dispose(): void;
  15938. private _beforeClear;
  15939. }
  15940. }
  15941. declare module BABYLON {
  15942. interface Engine {
  15943. /**
  15944. * Creates a new render target cube texture
  15945. * @param size defines the size of the texture
  15946. * @param options defines the options used to create the texture
  15947. * @returns a new render target cube texture stored in an InternalTexture
  15948. */
  15949. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  15950. }
  15951. }
  15952. declare module BABYLON {
  15953. /** @hidden */
  15954. export var proceduralVertexShader: {
  15955. name: string;
  15956. shader: string;
  15957. };
  15958. }
  15959. declare module BABYLON {
  15960. /**
  15961. * 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.
  15962. * This is the base class of any Procedural texture and contains most of the shareable code.
  15963. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15964. */
  15965. export class ProceduralTexture extends Texture {
  15966. isCube: boolean;
  15967. /**
  15968. * Define if the texture is enabled or not (disabled texture will not render)
  15969. */
  15970. isEnabled: boolean;
  15971. /**
  15972. * Define if the texture must be cleared before rendering (default is true)
  15973. */
  15974. autoClear: boolean;
  15975. /**
  15976. * Callback called when the texture is generated
  15977. */
  15978. onGenerated: () => void;
  15979. /**
  15980. * Event raised when the texture is generated
  15981. */
  15982. onGeneratedObservable: Observable<ProceduralTexture>;
  15983. /** @hidden */
  15984. _generateMipMaps: boolean;
  15985. /** @hidden **/
  15986. _effect: Effect;
  15987. /** @hidden */
  15988. _textures: {
  15989. [key: string]: Texture;
  15990. };
  15991. private _size;
  15992. private _currentRefreshId;
  15993. private _refreshRate;
  15994. private _vertexBuffers;
  15995. private _indexBuffer;
  15996. private _uniforms;
  15997. private _samplers;
  15998. private _fragment;
  15999. private _floats;
  16000. private _ints;
  16001. private _floatsArrays;
  16002. private _colors3;
  16003. private _colors4;
  16004. private _vectors2;
  16005. private _vectors3;
  16006. private _matrices;
  16007. private _fallbackTexture;
  16008. private _fallbackTextureUsed;
  16009. private _engine;
  16010. private _cachedDefines;
  16011. private _contentUpdateId;
  16012. private _contentData;
  16013. /**
  16014. * Instantiates a new procedural texture.
  16015. * 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.
  16016. * This is the base class of any Procedural texture and contains most of the shareable code.
  16017. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16018. * @param name Define the name of the texture
  16019. * @param size Define the size of the texture to create
  16020. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16021. * @param scene Define the scene the texture belongs to
  16022. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16023. * @param generateMipMaps Define if the texture should creates mip maps or not
  16024. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16025. */
  16026. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16027. /**
  16028. * The effect that is created when initializing the post process.
  16029. * @returns The created effect corresponding the the postprocess.
  16030. */
  16031. getEffect(): Effect;
  16032. /**
  16033. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16034. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16035. */
  16036. getContent(): Nullable<ArrayBufferView>;
  16037. private _createIndexBuffer;
  16038. /** @hidden */
  16039. _rebuild(): void;
  16040. /**
  16041. * Resets the texture in order to recreate its associated resources.
  16042. * This can be called in case of context loss
  16043. */
  16044. reset(): void;
  16045. protected _getDefines(): string;
  16046. /**
  16047. * Is the texture ready to be used ? (rendered at least once)
  16048. * @returns true if ready, otherwise, false.
  16049. */
  16050. isReady(): boolean;
  16051. /**
  16052. * Resets the refresh counter of the texture and start bak from scratch.
  16053. * Could be useful to regenerate the texture if it is setup to render only once.
  16054. */
  16055. resetRefreshCounter(): void;
  16056. /**
  16057. * Set the fragment shader to use in order to render the texture.
  16058. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16059. */
  16060. setFragment(fragment: any): void;
  16061. /**
  16062. * Define the refresh rate of the texture or the rendering frequency.
  16063. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16064. */
  16065. refreshRate: number;
  16066. /** @hidden */
  16067. _shouldRender(): boolean;
  16068. /**
  16069. * Get the size the texture is rendering at.
  16070. * @returns the size (texture is always squared)
  16071. */
  16072. getRenderSize(): number;
  16073. /**
  16074. * Resize the texture to new value.
  16075. * @param size Define the new size the texture should have
  16076. * @param generateMipMaps Define whether the new texture should create mip maps
  16077. */
  16078. resize(size: number, generateMipMaps: boolean): void;
  16079. private _checkUniform;
  16080. /**
  16081. * Set a texture in the shader program used to render.
  16082. * @param name Define the name of the uniform samplers as defined in the shader
  16083. * @param texture Define the texture to bind to this sampler
  16084. * @return the texture itself allowing "fluent" like uniform updates
  16085. */
  16086. setTexture(name: string, texture: Texture): ProceduralTexture;
  16087. /**
  16088. * Set a float in the shader.
  16089. * @param name Define the name of the uniform as defined in the shader
  16090. * @param value Define the value to give to the uniform
  16091. * @return the texture itself allowing "fluent" like uniform updates
  16092. */
  16093. setFloat(name: string, value: number): ProceduralTexture;
  16094. /**
  16095. * Set a int in the shader.
  16096. * @param name Define the name of the uniform as defined in the shader
  16097. * @param value Define the value to give to the uniform
  16098. * @return the texture itself allowing "fluent" like uniform updates
  16099. */
  16100. setInt(name: string, value: number): ProceduralTexture;
  16101. /**
  16102. * Set an array of floats in the shader.
  16103. * @param name Define the name of the uniform as defined in the shader
  16104. * @param value Define the value to give to the uniform
  16105. * @return the texture itself allowing "fluent" like uniform updates
  16106. */
  16107. setFloats(name: string, value: number[]): ProceduralTexture;
  16108. /**
  16109. * Set a vec3 in the shader from a Color3.
  16110. * @param name Define the name of the uniform as defined in the shader
  16111. * @param value Define the value to give to the uniform
  16112. * @return the texture itself allowing "fluent" like uniform updates
  16113. */
  16114. setColor3(name: string, value: Color3): ProceduralTexture;
  16115. /**
  16116. * Set a vec4 in the shader from a Color4.
  16117. * @param name Define the name of the uniform as defined in the shader
  16118. * @param value Define the value to give to the uniform
  16119. * @return the texture itself allowing "fluent" like uniform updates
  16120. */
  16121. setColor4(name: string, value: Color4): ProceduralTexture;
  16122. /**
  16123. * Set a vec2 in the shader from a Vector2.
  16124. * @param name Define the name of the uniform as defined in the shader
  16125. * @param value Define the value to give to the uniform
  16126. * @return the texture itself allowing "fluent" like uniform updates
  16127. */
  16128. setVector2(name: string, value: Vector2): ProceduralTexture;
  16129. /**
  16130. * Set a vec3 in the shader from a Vector3.
  16131. * @param name Define the name of the uniform as defined in the shader
  16132. * @param value Define the value to give to the uniform
  16133. * @return the texture itself allowing "fluent" like uniform updates
  16134. */
  16135. setVector3(name: string, value: Vector3): ProceduralTexture;
  16136. /**
  16137. * Set a mat4 in the shader from a MAtrix.
  16138. * @param name Define the name of the uniform as defined in the shader
  16139. * @param value Define the value to give to the uniform
  16140. * @return the texture itself allowing "fluent" like uniform updates
  16141. */
  16142. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16143. /**
  16144. * Render the texture to its associated render target.
  16145. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16146. */
  16147. render(useCameraPostProcess?: boolean): void;
  16148. /**
  16149. * Clone the texture.
  16150. * @returns the cloned texture
  16151. */
  16152. clone(): ProceduralTexture;
  16153. /**
  16154. * Dispose the texture and release its asoociated resources.
  16155. */
  16156. dispose(): void;
  16157. }
  16158. }
  16159. declare module BABYLON {
  16160. /**
  16161. * This represents the base class for particle system in Babylon.
  16162. * 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.
  16163. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16164. * @example https://doc.babylonjs.com/babylon101/particles
  16165. */
  16166. export class BaseParticleSystem {
  16167. /**
  16168. * Source color is added to the destination color without alpha affecting the result
  16169. */
  16170. static BLENDMODE_ONEONE: number;
  16171. /**
  16172. * Blend current color and particle color using particle’s alpha
  16173. */
  16174. static BLENDMODE_STANDARD: number;
  16175. /**
  16176. * Add current color and particle color multiplied by particle’s alpha
  16177. */
  16178. static BLENDMODE_ADD: number;
  16179. /**
  16180. * Multiply current color with particle color
  16181. */
  16182. static BLENDMODE_MULTIPLY: number;
  16183. /**
  16184. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16185. */
  16186. static BLENDMODE_MULTIPLYADD: number;
  16187. /**
  16188. * List of animations used by the particle system.
  16189. */
  16190. animations: Animation[];
  16191. /**
  16192. * The id of the Particle system.
  16193. */
  16194. id: string;
  16195. /**
  16196. * The friendly name of the Particle system.
  16197. */
  16198. name: string;
  16199. /**
  16200. * The rendering group used by the Particle system to chose when to render.
  16201. */
  16202. renderingGroupId: number;
  16203. /**
  16204. * The emitter represents the Mesh or position we are attaching the particle system to.
  16205. */
  16206. emitter: Nullable<AbstractMesh | Vector3>;
  16207. /**
  16208. * The maximum number of particles to emit per frame
  16209. */
  16210. emitRate: number;
  16211. /**
  16212. * If you want to launch only a few particles at once, that can be done, as well.
  16213. */
  16214. manualEmitCount: number;
  16215. /**
  16216. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16217. */
  16218. updateSpeed: number;
  16219. /**
  16220. * The amount of time the particle system is running (depends of the overall update speed).
  16221. */
  16222. targetStopDuration: number;
  16223. /**
  16224. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16225. */
  16226. disposeOnStop: boolean;
  16227. /**
  16228. * Minimum power of emitting particles.
  16229. */
  16230. minEmitPower: number;
  16231. /**
  16232. * Maximum power of emitting particles.
  16233. */
  16234. maxEmitPower: number;
  16235. /**
  16236. * Minimum life time of emitting particles.
  16237. */
  16238. minLifeTime: number;
  16239. /**
  16240. * Maximum life time of emitting particles.
  16241. */
  16242. maxLifeTime: number;
  16243. /**
  16244. * Minimum Size of emitting particles.
  16245. */
  16246. minSize: number;
  16247. /**
  16248. * Maximum Size of emitting particles.
  16249. */
  16250. maxSize: number;
  16251. /**
  16252. * Minimum scale of emitting particles on X axis.
  16253. */
  16254. minScaleX: number;
  16255. /**
  16256. * Maximum scale of emitting particles on X axis.
  16257. */
  16258. maxScaleX: number;
  16259. /**
  16260. * Minimum scale of emitting particles on Y axis.
  16261. */
  16262. minScaleY: number;
  16263. /**
  16264. * Maximum scale of emitting particles on Y axis.
  16265. */
  16266. maxScaleY: number;
  16267. /**
  16268. * Gets or sets the minimal initial rotation in radians.
  16269. */
  16270. minInitialRotation: number;
  16271. /**
  16272. * Gets or sets the maximal initial rotation in radians.
  16273. */
  16274. maxInitialRotation: number;
  16275. /**
  16276. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16277. */
  16278. minAngularSpeed: number;
  16279. /**
  16280. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16281. */
  16282. maxAngularSpeed: number;
  16283. /**
  16284. * The texture used to render each particle. (this can be a spritesheet)
  16285. */
  16286. particleTexture: Nullable<Texture>;
  16287. /**
  16288. * The layer mask we are rendering the particles through.
  16289. */
  16290. layerMask: number;
  16291. /**
  16292. * This can help using your own shader to render the particle system.
  16293. * The according effect will be created
  16294. */
  16295. customShader: any;
  16296. /**
  16297. * By default particle system starts as soon as they are created. This prevents the
  16298. * automatic start to happen and let you decide when to start emitting particles.
  16299. */
  16300. preventAutoStart: boolean;
  16301. private _noiseTexture;
  16302. /**
  16303. * Gets or sets a texture used to add random noise to particle positions
  16304. */
  16305. noiseTexture: Nullable<ProceduralTexture>;
  16306. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16307. noiseStrength: Vector3;
  16308. /**
  16309. * Callback triggered when the particle animation is ending.
  16310. */
  16311. onAnimationEnd: Nullable<() => void>;
  16312. /**
  16313. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16314. */
  16315. blendMode: number;
  16316. /**
  16317. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16318. * to override the particles.
  16319. */
  16320. forceDepthWrite: boolean;
  16321. /** 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 */
  16322. preWarmCycles: number;
  16323. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16324. preWarmStepOffset: number;
  16325. /**
  16326. * 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)
  16327. */
  16328. spriteCellChangeSpeed: number;
  16329. /**
  16330. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16331. */
  16332. startSpriteCellID: number;
  16333. /**
  16334. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16335. */
  16336. endSpriteCellID: number;
  16337. /**
  16338. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16339. */
  16340. spriteCellWidth: number;
  16341. /**
  16342. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16343. */
  16344. spriteCellHeight: number;
  16345. /**
  16346. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16347. */
  16348. spriteRandomStartCell: boolean;
  16349. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16350. translationPivot: Vector2;
  16351. /** @hidden */
  16352. protected _isAnimationSheetEnabled: boolean;
  16353. /**
  16354. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16355. */
  16356. beginAnimationOnStart: boolean;
  16357. /**
  16358. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16359. */
  16360. beginAnimationFrom: number;
  16361. /**
  16362. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16363. */
  16364. beginAnimationTo: number;
  16365. /**
  16366. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16367. */
  16368. beginAnimationLoop: boolean;
  16369. /**
  16370. * Gets or sets a world offset applied to all particles
  16371. */
  16372. worldOffset: Vector3;
  16373. /**
  16374. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16375. */
  16376. isAnimationSheetEnabled: boolean;
  16377. /**
  16378. * Get hosting scene
  16379. * @returns the scene
  16380. */
  16381. getScene(): Scene;
  16382. /**
  16383. * You can use gravity if you want to give an orientation to your particles.
  16384. */
  16385. gravity: Vector3;
  16386. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16387. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16388. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16389. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16390. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16391. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16392. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16393. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16394. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16395. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16396. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16397. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16398. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16399. /**
  16400. * Defines the delay in milliseconds before starting the system (0 by default)
  16401. */
  16402. startDelay: number;
  16403. /**
  16404. * Gets the current list of drag gradients.
  16405. * You must use addDragGradient and removeDragGradient to udpate this list
  16406. * @returns the list of drag gradients
  16407. */
  16408. getDragGradients(): Nullable<Array<FactorGradient>>;
  16409. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16410. limitVelocityDamping: number;
  16411. /**
  16412. * Gets the current list of limit velocity gradients.
  16413. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16414. * @returns the list of limit velocity gradients
  16415. */
  16416. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16417. /**
  16418. * Gets the current list of color gradients.
  16419. * You must use addColorGradient and removeColorGradient to udpate this list
  16420. * @returns the list of color gradients
  16421. */
  16422. getColorGradients(): Nullable<Array<ColorGradient>>;
  16423. /**
  16424. * Gets the current list of size gradients.
  16425. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16426. * @returns the list of size gradients
  16427. */
  16428. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16429. /**
  16430. * Gets the current list of color remap gradients.
  16431. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16432. * @returns the list of color remap gradients
  16433. */
  16434. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16435. /**
  16436. * Gets the current list of alpha remap gradients.
  16437. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16438. * @returns the list of alpha remap gradients
  16439. */
  16440. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16441. /**
  16442. * Gets the current list of life time gradients.
  16443. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16444. * @returns the list of life time gradients
  16445. */
  16446. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16447. /**
  16448. * Gets the current list of angular speed gradients.
  16449. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16450. * @returns the list of angular speed gradients
  16451. */
  16452. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16453. /**
  16454. * Gets the current list of velocity gradients.
  16455. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16456. * @returns the list of velocity gradients
  16457. */
  16458. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16459. /**
  16460. * Gets the current list of start size gradients.
  16461. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16462. * @returns the list of start size gradients
  16463. */
  16464. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16465. /**
  16466. * Gets the current list of emit rate gradients.
  16467. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16468. * @returns the list of emit rate gradients
  16469. */
  16470. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16471. /**
  16472. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16473. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16474. */
  16475. direction1: Vector3;
  16476. /**
  16477. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16478. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16479. */
  16480. direction2: Vector3;
  16481. /**
  16482. * 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.
  16483. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16484. */
  16485. minEmitBox: Vector3;
  16486. /**
  16487. * 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.
  16488. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16489. */
  16490. maxEmitBox: Vector3;
  16491. /**
  16492. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16493. */
  16494. color1: Color4;
  16495. /**
  16496. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16497. */
  16498. color2: Color4;
  16499. /**
  16500. * Color the particle will have at the end of its lifetime
  16501. */
  16502. colorDead: Color4;
  16503. /**
  16504. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16505. */
  16506. textureMask: Color4;
  16507. /**
  16508. * The particle emitter type defines the emitter used by the particle system.
  16509. * It can be for example box, sphere, or cone...
  16510. */
  16511. particleEmitterType: IParticleEmitterType;
  16512. /** @hidden */
  16513. _isSubEmitter: boolean;
  16514. /**
  16515. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16516. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16517. */
  16518. billboardMode: number;
  16519. protected _isBillboardBased: boolean;
  16520. /**
  16521. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16522. */
  16523. isBillboardBased: boolean;
  16524. /**
  16525. * The scene the particle system belongs to.
  16526. */
  16527. protected _scene: Scene;
  16528. /**
  16529. * Local cache of defines for image processing.
  16530. */
  16531. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16532. /**
  16533. * Default configuration related to image processing available in the standard Material.
  16534. */
  16535. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16536. /**
  16537. * Gets the image processing configuration used either in this material.
  16538. */
  16539. /**
  16540. * Sets the Default image processing configuration used either in the this material.
  16541. *
  16542. * If sets to null, the scene one is in use.
  16543. */
  16544. imageProcessingConfiguration: ImageProcessingConfiguration;
  16545. /**
  16546. * Attaches a new image processing configuration to the Standard Material.
  16547. * @param configuration
  16548. */
  16549. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16550. /** @hidden */
  16551. protected _reset(): void;
  16552. /** @hidden */
  16553. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16554. /**
  16555. * Instantiates a particle system.
  16556. * 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.
  16557. * @param name The name of the particle system
  16558. */
  16559. constructor(name: string);
  16560. /**
  16561. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16562. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16563. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16564. * @returns the emitter
  16565. */
  16566. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16567. /**
  16568. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16569. * @param radius The radius of the hemisphere to emit from
  16570. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16571. * @returns the emitter
  16572. */
  16573. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16574. /**
  16575. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16576. * @param radius The radius of the sphere to emit from
  16577. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16578. * @returns the emitter
  16579. */
  16580. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16581. /**
  16582. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16583. * @param radius The radius of the sphere to emit from
  16584. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16585. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16586. * @returns the emitter
  16587. */
  16588. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16589. /**
  16590. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16591. * @param radius The radius of the emission cylinder
  16592. * @param height The height of the emission cylinder
  16593. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16594. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16595. * @returns the emitter
  16596. */
  16597. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16598. /**
  16599. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16600. * @param radius The radius of the cylinder to emit from
  16601. * @param height The height of the emission cylinder
  16602. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16603. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16604. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16605. * @returns the emitter
  16606. */
  16607. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16608. /**
  16609. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16610. * @param radius The radius of the cone to emit from
  16611. * @param angle The base angle of the cone
  16612. * @returns the emitter
  16613. */
  16614. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16615. /**
  16616. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16617. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16618. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16619. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16620. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16621. * @returns the emitter
  16622. */
  16623. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16624. }
  16625. }
  16626. declare module BABYLON {
  16627. /**
  16628. * Type of sub emitter
  16629. */
  16630. export enum SubEmitterType {
  16631. /**
  16632. * Attached to the particle over it's lifetime
  16633. */
  16634. ATTACHED = 0,
  16635. /**
  16636. * Created when the particle dies
  16637. */
  16638. END = 1
  16639. }
  16640. /**
  16641. * Sub emitter class used to emit particles from an existing particle
  16642. */
  16643. export class SubEmitter {
  16644. /**
  16645. * the particle system to be used by the sub emitter
  16646. */
  16647. particleSystem: ParticleSystem;
  16648. /**
  16649. * Type of the submitter (Default: END)
  16650. */
  16651. type: SubEmitterType;
  16652. /**
  16653. * 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)
  16654. * Note: This only is supported when using an emitter of type Mesh
  16655. */
  16656. inheritDirection: boolean;
  16657. /**
  16658. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16659. */
  16660. inheritedVelocityAmount: number;
  16661. /**
  16662. * Creates a sub emitter
  16663. * @param particleSystem the particle system to be used by the sub emitter
  16664. */
  16665. constructor(
  16666. /**
  16667. * the particle system to be used by the sub emitter
  16668. */
  16669. particleSystem: ParticleSystem);
  16670. /**
  16671. * Clones the sub emitter
  16672. * @returns the cloned sub emitter
  16673. */
  16674. clone(): SubEmitter;
  16675. /**
  16676. * Serialize current object to a JSON object
  16677. * @returns the serialized object
  16678. */
  16679. serialize(): any;
  16680. /** @hidden */
  16681. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16682. /**
  16683. * Creates a new SubEmitter from a serialized JSON version
  16684. * @param serializationObject defines the JSON object to read from
  16685. * @param scene defines the hosting scene
  16686. * @param rootUrl defines the rootUrl for data loading
  16687. * @returns a new SubEmitter
  16688. */
  16689. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16690. /** Release associated resources */
  16691. dispose(): void;
  16692. }
  16693. }
  16694. declare module BABYLON {
  16695. /** @hidden */
  16696. export var clipPlaneFragmentDeclaration: {
  16697. name: string;
  16698. shader: string;
  16699. };
  16700. }
  16701. declare module BABYLON {
  16702. /** @hidden */
  16703. export var imageProcessingDeclaration: {
  16704. name: string;
  16705. shader: string;
  16706. };
  16707. }
  16708. declare module BABYLON {
  16709. /** @hidden */
  16710. export var imageProcessingFunctions: {
  16711. name: string;
  16712. shader: string;
  16713. };
  16714. }
  16715. declare module BABYLON {
  16716. /** @hidden */
  16717. export var clipPlaneFragment: {
  16718. name: string;
  16719. shader: string;
  16720. };
  16721. }
  16722. declare module BABYLON {
  16723. /** @hidden */
  16724. export var particlesPixelShader: {
  16725. name: string;
  16726. shader: string;
  16727. };
  16728. }
  16729. declare module BABYLON {
  16730. /** @hidden */
  16731. export var clipPlaneVertexDeclaration: {
  16732. name: string;
  16733. shader: string;
  16734. };
  16735. }
  16736. declare module BABYLON {
  16737. /** @hidden */
  16738. export var clipPlaneVertex: {
  16739. name: string;
  16740. shader: string;
  16741. };
  16742. }
  16743. declare module BABYLON {
  16744. /** @hidden */
  16745. export var particlesVertexShader: {
  16746. name: string;
  16747. shader: string;
  16748. };
  16749. }
  16750. declare module BABYLON {
  16751. /**
  16752. * This represents a particle system in Babylon.
  16753. * 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.
  16754. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16755. * @example https://doc.babylonjs.com/babylon101/particles
  16756. */
  16757. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16758. /**
  16759. * Billboard mode will only apply to Y axis
  16760. */
  16761. static readonly BILLBOARDMODE_Y: number;
  16762. /**
  16763. * Billboard mode will apply to all axes
  16764. */
  16765. static readonly BILLBOARDMODE_ALL: number;
  16766. /**
  16767. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16768. */
  16769. static readonly BILLBOARDMODE_STRETCHED: number;
  16770. /**
  16771. * This function can be defined to provide custom update for active particles.
  16772. * This function will be called instead of regular update (age, position, color, etc.).
  16773. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16774. */
  16775. updateFunction: (particles: Particle[]) => void;
  16776. private _emitterWorldMatrix;
  16777. /**
  16778. * This function can be defined to specify initial direction for every new particle.
  16779. * It by default use the emitterType defined function
  16780. */
  16781. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16782. /**
  16783. * This function can be defined to specify initial position for every new particle.
  16784. * It by default use the emitterType defined function
  16785. */
  16786. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16787. /**
  16788. * @hidden
  16789. */
  16790. _inheritedVelocityOffset: Vector3;
  16791. /**
  16792. * An event triggered when the system is disposed
  16793. */
  16794. onDisposeObservable: Observable<ParticleSystem>;
  16795. private _onDisposeObserver;
  16796. /**
  16797. * Sets a callback that will be triggered when the system is disposed
  16798. */
  16799. onDispose: () => void;
  16800. private _particles;
  16801. private _epsilon;
  16802. private _capacity;
  16803. private _stockParticles;
  16804. private _newPartsExcess;
  16805. private _vertexData;
  16806. private _vertexBuffer;
  16807. private _vertexBuffers;
  16808. private _spriteBuffer;
  16809. private _indexBuffer;
  16810. private _effect;
  16811. private _customEffect;
  16812. private _cachedDefines;
  16813. private _scaledColorStep;
  16814. private _colorDiff;
  16815. private _scaledDirection;
  16816. private _scaledGravity;
  16817. private _currentRenderId;
  16818. private _alive;
  16819. private _useInstancing;
  16820. private _started;
  16821. private _stopped;
  16822. private _actualFrame;
  16823. private _scaledUpdateSpeed;
  16824. private _vertexBufferSize;
  16825. /** @hidden */
  16826. _currentEmitRateGradient: Nullable<FactorGradient>;
  16827. /** @hidden */
  16828. _currentEmitRate1: number;
  16829. /** @hidden */
  16830. _currentEmitRate2: number;
  16831. /** @hidden */
  16832. _currentStartSizeGradient: Nullable<FactorGradient>;
  16833. /** @hidden */
  16834. _currentStartSize1: number;
  16835. /** @hidden */
  16836. _currentStartSize2: number;
  16837. private readonly _rawTextureWidth;
  16838. private _rampGradientsTexture;
  16839. private _useRampGradients;
  16840. /** Gets or sets a boolean indicating that ramp gradients must be used
  16841. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16842. */
  16843. useRampGradients: boolean;
  16844. /**
  16845. * 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.
  16846. * 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: [])
  16847. */
  16848. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16849. private _subEmitters;
  16850. /**
  16851. * @hidden
  16852. * If the particle systems emitter should be disposed when the particle system is disposed
  16853. */
  16854. _disposeEmitterOnDispose: boolean;
  16855. /**
  16856. * The current active Sub-systems, this property is used by the root particle system only.
  16857. */
  16858. activeSubSystems: Array<ParticleSystem>;
  16859. private _rootParticleSystem;
  16860. /**
  16861. * Gets the current list of active particles
  16862. */
  16863. readonly particles: Particle[];
  16864. /**
  16865. * Returns the string "ParticleSystem"
  16866. * @returns a string containing the class name
  16867. */
  16868. getClassName(): string;
  16869. /**
  16870. * Instantiates a particle system.
  16871. * 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.
  16872. * @param name The name of the particle system
  16873. * @param capacity The max number of particles alive at the same time
  16874. * @param scene The scene the particle system belongs to
  16875. * @param customEffect a custom effect used to change the way particles are rendered by default
  16876. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16877. * @param epsilon Offset used to render the particles
  16878. */
  16879. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16880. private _addFactorGradient;
  16881. private _removeFactorGradient;
  16882. /**
  16883. * Adds a new life time gradient
  16884. * @param gradient defines the gradient to use (between 0 and 1)
  16885. * @param factor defines the life time factor to affect to the specified gradient
  16886. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16887. * @returns the current particle system
  16888. */
  16889. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16890. /**
  16891. * Remove a specific life time gradient
  16892. * @param gradient defines the gradient to remove
  16893. * @returns the current particle system
  16894. */
  16895. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16896. /**
  16897. * Adds a new size gradient
  16898. * @param gradient defines the gradient to use (between 0 and 1)
  16899. * @param factor defines the size factor to affect to the specified gradient
  16900. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16901. * @returns the current particle system
  16902. */
  16903. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16904. /**
  16905. * Remove a specific size gradient
  16906. * @param gradient defines the gradient to remove
  16907. * @returns the current particle system
  16908. */
  16909. removeSizeGradient(gradient: number): IParticleSystem;
  16910. /**
  16911. * Adds a new color remap gradient
  16912. * @param gradient defines the gradient to use (between 0 and 1)
  16913. * @param min defines the color remap minimal range
  16914. * @param max defines the color remap maximal range
  16915. * @returns the current particle system
  16916. */
  16917. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16918. /**
  16919. * Remove a specific color remap gradient
  16920. * @param gradient defines the gradient to remove
  16921. * @returns the current particle system
  16922. */
  16923. removeColorRemapGradient(gradient: number): IParticleSystem;
  16924. /**
  16925. * Adds a new alpha remap gradient
  16926. * @param gradient defines the gradient to use (between 0 and 1)
  16927. * @param min defines the alpha remap minimal range
  16928. * @param max defines the alpha remap maximal range
  16929. * @returns the current particle system
  16930. */
  16931. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16932. /**
  16933. * Remove a specific alpha remap gradient
  16934. * @param gradient defines the gradient to remove
  16935. * @returns the current particle system
  16936. */
  16937. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  16938. /**
  16939. * Adds a new angular speed gradient
  16940. * @param gradient defines the gradient to use (between 0 and 1)
  16941. * @param factor defines the angular speed to affect to the specified gradient
  16942. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16943. * @returns the current particle system
  16944. */
  16945. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16946. /**
  16947. * Remove a specific angular speed gradient
  16948. * @param gradient defines the gradient to remove
  16949. * @returns the current particle system
  16950. */
  16951. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16952. /**
  16953. * Adds a new velocity gradient
  16954. * @param gradient defines the gradient to use (between 0 and 1)
  16955. * @param factor defines the velocity to affect to the specified gradient
  16956. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16957. * @returns the current particle system
  16958. */
  16959. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16960. /**
  16961. * Remove a specific velocity gradient
  16962. * @param gradient defines the gradient to remove
  16963. * @returns the current particle system
  16964. */
  16965. removeVelocityGradient(gradient: number): IParticleSystem;
  16966. /**
  16967. * Adds a new limit velocity gradient
  16968. * @param gradient defines the gradient to use (between 0 and 1)
  16969. * @param factor defines the limit velocity value to affect to the specified gradient
  16970. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16971. * @returns the current particle system
  16972. */
  16973. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16974. /**
  16975. * Remove a specific limit velocity gradient
  16976. * @param gradient defines the gradient to remove
  16977. * @returns the current particle system
  16978. */
  16979. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16980. /**
  16981. * Adds a new drag gradient
  16982. * @param gradient defines the gradient to use (between 0 and 1)
  16983. * @param factor defines the drag value to affect to the specified gradient
  16984. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16985. * @returns the current particle system
  16986. */
  16987. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16988. /**
  16989. * Remove a specific drag gradient
  16990. * @param gradient defines the gradient to remove
  16991. * @returns the current particle system
  16992. */
  16993. removeDragGradient(gradient: number): IParticleSystem;
  16994. /**
  16995. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16996. * @param gradient defines the gradient to use (between 0 and 1)
  16997. * @param factor defines the emit rate value to affect to the specified gradient
  16998. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16999. * @returns the current particle system
  17000. */
  17001. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17002. /**
  17003. * Remove a specific emit rate gradient
  17004. * @param gradient defines the gradient to remove
  17005. * @returns the current particle system
  17006. */
  17007. removeEmitRateGradient(gradient: number): IParticleSystem;
  17008. /**
  17009. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17010. * @param gradient defines the gradient to use (between 0 and 1)
  17011. * @param factor defines the start size value to affect to the specified gradient
  17012. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17013. * @returns the current particle system
  17014. */
  17015. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17016. /**
  17017. * Remove a specific start size gradient
  17018. * @param gradient defines the gradient to remove
  17019. * @returns the current particle system
  17020. */
  17021. removeStartSizeGradient(gradient: number): IParticleSystem;
  17022. private _createRampGradientTexture;
  17023. /**
  17024. * Gets the current list of ramp gradients.
  17025. * You must use addRampGradient and removeRampGradient to udpate this list
  17026. * @returns the list of ramp gradients
  17027. */
  17028. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17029. /**
  17030. * Adds a new ramp gradient used to remap particle colors
  17031. * @param gradient defines the gradient to use (between 0 and 1)
  17032. * @param color defines the color to affect to the specified gradient
  17033. * @returns the current particle system
  17034. */
  17035. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17036. /**
  17037. * Remove a specific ramp gradient
  17038. * @param gradient defines the gradient to remove
  17039. * @returns the current particle system
  17040. */
  17041. removeRampGradient(gradient: number): ParticleSystem;
  17042. /**
  17043. * Adds a new color gradient
  17044. * @param gradient defines the gradient to use (between 0 and 1)
  17045. * @param color1 defines the color to affect to the specified gradient
  17046. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17047. * @returns this particle system
  17048. */
  17049. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17050. /**
  17051. * Remove a specific color gradient
  17052. * @param gradient defines the gradient to remove
  17053. * @returns this particle system
  17054. */
  17055. removeColorGradient(gradient: number): IParticleSystem;
  17056. private _fetchR;
  17057. protected _reset(): void;
  17058. private _resetEffect;
  17059. private _createVertexBuffers;
  17060. private _createIndexBuffer;
  17061. /**
  17062. * Gets the maximum number of particles active at the same time.
  17063. * @returns The max number of active particles.
  17064. */
  17065. getCapacity(): number;
  17066. /**
  17067. * Gets whether there are still active particles in the system.
  17068. * @returns True if it is alive, otherwise false.
  17069. */
  17070. isAlive(): boolean;
  17071. /**
  17072. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17073. * @returns True if it has been started, otherwise false.
  17074. */
  17075. isStarted(): boolean;
  17076. private _prepareSubEmitterInternalArray;
  17077. /**
  17078. * Starts the particle system and begins to emit
  17079. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17080. */
  17081. start(delay?: number): void;
  17082. /**
  17083. * Stops the particle system.
  17084. * @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.
  17085. */
  17086. stop(stopSubEmitters?: boolean): void;
  17087. /**
  17088. * Remove all active particles
  17089. */
  17090. reset(): void;
  17091. /**
  17092. * @hidden (for internal use only)
  17093. */
  17094. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17095. /**
  17096. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17097. * Its lifetime will start back at 0.
  17098. */
  17099. recycleParticle: (particle: Particle) => void;
  17100. private _stopSubEmitters;
  17101. private _createParticle;
  17102. private _removeFromRoot;
  17103. private _emitFromParticle;
  17104. private _update;
  17105. /** @hidden */
  17106. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17107. /** @hidden */
  17108. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17109. /** @hidden */
  17110. private _getEffect;
  17111. /**
  17112. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17113. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17114. */
  17115. animate(preWarmOnly?: boolean): void;
  17116. private _appendParticleVertices;
  17117. /**
  17118. * Rebuilds the particle system.
  17119. */
  17120. rebuild(): void;
  17121. /**
  17122. * Is this system ready to be used/rendered
  17123. * @return true if the system is ready
  17124. */
  17125. isReady(): boolean;
  17126. private _render;
  17127. /**
  17128. * Renders the particle system in its current state.
  17129. * @returns the current number of particles
  17130. */
  17131. render(): number;
  17132. /**
  17133. * Disposes the particle system and free the associated resources
  17134. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17135. */
  17136. dispose(disposeTexture?: boolean): void;
  17137. /**
  17138. * Clones the particle system.
  17139. * @param name The name of the cloned object
  17140. * @param newEmitter The new emitter to use
  17141. * @returns the cloned particle system
  17142. */
  17143. clone(name: string, newEmitter: any): ParticleSystem;
  17144. /**
  17145. * Serializes the particle system to a JSON object.
  17146. * @returns the JSON object
  17147. */
  17148. serialize(): any;
  17149. /** @hidden */
  17150. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17151. /** @hidden */
  17152. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17153. /**
  17154. * Parses a JSON object to create a particle system.
  17155. * @param parsedParticleSystem The JSON object to parse
  17156. * @param scene The scene to create the particle system in
  17157. * @param rootUrl The root url to use to load external dependencies like texture
  17158. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17159. * @returns the Parsed particle system
  17160. */
  17161. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17162. }
  17163. }
  17164. declare module BABYLON {
  17165. /**
  17166. * A particle represents one of the element emitted by a particle system.
  17167. * This is mainly define by its coordinates, direction, velocity and age.
  17168. */
  17169. export class Particle {
  17170. /**
  17171. * The particle system the particle belongs to.
  17172. */
  17173. particleSystem: ParticleSystem;
  17174. private static _Count;
  17175. /**
  17176. * Unique ID of the particle
  17177. */
  17178. id: number;
  17179. /**
  17180. * The world position of the particle in the scene.
  17181. */
  17182. position: Vector3;
  17183. /**
  17184. * The world direction of the particle in the scene.
  17185. */
  17186. direction: Vector3;
  17187. /**
  17188. * The color of the particle.
  17189. */
  17190. color: Color4;
  17191. /**
  17192. * The color change of the particle per step.
  17193. */
  17194. colorStep: Color4;
  17195. /**
  17196. * Defines how long will the life of the particle be.
  17197. */
  17198. lifeTime: number;
  17199. /**
  17200. * The current age of the particle.
  17201. */
  17202. age: number;
  17203. /**
  17204. * The current size of the particle.
  17205. */
  17206. size: number;
  17207. /**
  17208. * The current scale of the particle.
  17209. */
  17210. scale: Vector2;
  17211. /**
  17212. * The current angle of the particle.
  17213. */
  17214. angle: number;
  17215. /**
  17216. * Defines how fast is the angle changing.
  17217. */
  17218. angularSpeed: number;
  17219. /**
  17220. * Defines the cell index used by the particle to be rendered from a sprite.
  17221. */
  17222. cellIndex: number;
  17223. /**
  17224. * The information required to support color remapping
  17225. */
  17226. remapData: Vector4;
  17227. /** @hidden */
  17228. _randomCellOffset?: number;
  17229. /** @hidden */
  17230. _initialDirection: Nullable<Vector3>;
  17231. /** @hidden */
  17232. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17233. /** @hidden */
  17234. _initialStartSpriteCellID: number;
  17235. /** @hidden */
  17236. _initialEndSpriteCellID: number;
  17237. /** @hidden */
  17238. _currentColorGradient: Nullable<ColorGradient>;
  17239. /** @hidden */
  17240. _currentColor1: Color4;
  17241. /** @hidden */
  17242. _currentColor2: Color4;
  17243. /** @hidden */
  17244. _currentSizeGradient: Nullable<FactorGradient>;
  17245. /** @hidden */
  17246. _currentSize1: number;
  17247. /** @hidden */
  17248. _currentSize2: number;
  17249. /** @hidden */
  17250. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17251. /** @hidden */
  17252. _currentAngularSpeed1: number;
  17253. /** @hidden */
  17254. _currentAngularSpeed2: number;
  17255. /** @hidden */
  17256. _currentVelocityGradient: Nullable<FactorGradient>;
  17257. /** @hidden */
  17258. _currentVelocity1: number;
  17259. /** @hidden */
  17260. _currentVelocity2: number;
  17261. /** @hidden */
  17262. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17263. /** @hidden */
  17264. _currentLimitVelocity1: number;
  17265. /** @hidden */
  17266. _currentLimitVelocity2: number;
  17267. /** @hidden */
  17268. _currentDragGradient: Nullable<FactorGradient>;
  17269. /** @hidden */
  17270. _currentDrag1: number;
  17271. /** @hidden */
  17272. _currentDrag2: number;
  17273. /** @hidden */
  17274. _randomNoiseCoordinates1: Vector3;
  17275. /** @hidden */
  17276. _randomNoiseCoordinates2: Vector3;
  17277. /**
  17278. * Creates a new instance Particle
  17279. * @param particleSystem the particle system the particle belongs to
  17280. */
  17281. constructor(
  17282. /**
  17283. * The particle system the particle belongs to.
  17284. */
  17285. particleSystem: ParticleSystem);
  17286. private updateCellInfoFromSystem;
  17287. /**
  17288. * Defines how the sprite cell index is updated for the particle
  17289. */
  17290. updateCellIndex(): void;
  17291. /** @hidden */
  17292. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17293. /** @hidden */
  17294. _inheritParticleInfoToSubEmitters(): void;
  17295. /** @hidden */
  17296. _reset(): void;
  17297. /**
  17298. * Copy the properties of particle to another one.
  17299. * @param other the particle to copy the information to.
  17300. */
  17301. copyTo(other: Particle): void;
  17302. }
  17303. }
  17304. declare module BABYLON {
  17305. /**
  17306. * Particle emitter represents a volume emitting particles.
  17307. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17308. */
  17309. export interface IParticleEmitterType {
  17310. /**
  17311. * Called by the particle System when the direction is computed for the created particle.
  17312. * @param worldMatrix is the world matrix of the particle system
  17313. * @param directionToUpdate is the direction vector to update with the result
  17314. * @param particle is the particle we are computed the direction for
  17315. */
  17316. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17317. /**
  17318. * Called by the particle System when the position is computed for the created particle.
  17319. * @param worldMatrix is the world matrix of the particle system
  17320. * @param positionToUpdate is the position vector to update with the result
  17321. * @param particle is the particle we are computed the position for
  17322. */
  17323. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17324. /**
  17325. * Clones the current emitter and returns a copy of it
  17326. * @returns the new emitter
  17327. */
  17328. clone(): IParticleEmitterType;
  17329. /**
  17330. * Called by the GPUParticleSystem to setup the update shader
  17331. * @param effect defines the update shader
  17332. */
  17333. applyToShader(effect: Effect): void;
  17334. /**
  17335. * Returns a string to use to update the GPU particles update shader
  17336. * @returns the effect defines string
  17337. */
  17338. getEffectDefines(): string;
  17339. /**
  17340. * Returns a string representing the class name
  17341. * @returns a string containing the class name
  17342. */
  17343. getClassName(): string;
  17344. /**
  17345. * Serializes the particle system to a JSON object.
  17346. * @returns the JSON object
  17347. */
  17348. serialize(): any;
  17349. /**
  17350. * Parse properties from a JSON object
  17351. * @param serializationObject defines the JSON object
  17352. */
  17353. parse(serializationObject: any): void;
  17354. }
  17355. }
  17356. declare module BABYLON {
  17357. /**
  17358. * Particle emitter emitting particles from the inside of a box.
  17359. * It emits the particles randomly between 2 given directions.
  17360. */
  17361. export class BoxParticleEmitter implements IParticleEmitterType {
  17362. /**
  17363. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17364. */
  17365. direction1: Vector3;
  17366. /**
  17367. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17368. */
  17369. direction2: Vector3;
  17370. /**
  17371. * 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.
  17372. */
  17373. minEmitBox: Vector3;
  17374. /**
  17375. * 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.
  17376. */
  17377. maxEmitBox: Vector3;
  17378. /**
  17379. * Creates a new instance BoxParticleEmitter
  17380. */
  17381. constructor();
  17382. /**
  17383. * Called by the particle System when the direction is computed for the created particle.
  17384. * @param worldMatrix is the world matrix of the particle system
  17385. * @param directionToUpdate is the direction vector to update with the result
  17386. * @param particle is the particle we are computed the direction for
  17387. */
  17388. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17389. /**
  17390. * Called by the particle System when the position is computed for the created particle.
  17391. * @param worldMatrix is the world matrix of the particle system
  17392. * @param positionToUpdate is the position vector to update with the result
  17393. * @param particle is the particle we are computed the position for
  17394. */
  17395. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17396. /**
  17397. * Clones the current emitter and returns a copy of it
  17398. * @returns the new emitter
  17399. */
  17400. clone(): BoxParticleEmitter;
  17401. /**
  17402. * Called by the GPUParticleSystem to setup the update shader
  17403. * @param effect defines the update shader
  17404. */
  17405. applyToShader(effect: Effect): void;
  17406. /**
  17407. * Returns a string to use to update the GPU particles update shader
  17408. * @returns a string containng the defines string
  17409. */
  17410. getEffectDefines(): string;
  17411. /**
  17412. * Returns the string "BoxParticleEmitter"
  17413. * @returns a string containing the class name
  17414. */
  17415. getClassName(): string;
  17416. /**
  17417. * Serializes the particle system to a JSON object.
  17418. * @returns the JSON object
  17419. */
  17420. serialize(): any;
  17421. /**
  17422. * Parse properties from a JSON object
  17423. * @param serializationObject defines the JSON object
  17424. */
  17425. parse(serializationObject: any): void;
  17426. }
  17427. }
  17428. declare module BABYLON {
  17429. /**
  17430. * Particle emitter emitting particles from the inside of a cone.
  17431. * It emits the particles alongside the cone volume from the base to the particle.
  17432. * The emission direction might be randomized.
  17433. */
  17434. export class ConeParticleEmitter implements IParticleEmitterType {
  17435. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17436. directionRandomizer: number;
  17437. private _radius;
  17438. private _angle;
  17439. private _height;
  17440. /**
  17441. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17442. */
  17443. radiusRange: number;
  17444. /**
  17445. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17446. */
  17447. heightRange: number;
  17448. /**
  17449. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17450. */
  17451. emitFromSpawnPointOnly: boolean;
  17452. /**
  17453. * Gets or sets the radius of the emission cone
  17454. */
  17455. radius: number;
  17456. /**
  17457. * Gets or sets the angle of the emission cone
  17458. */
  17459. angle: number;
  17460. private _buildHeight;
  17461. /**
  17462. * Creates a new instance ConeParticleEmitter
  17463. * @param radius the radius of the emission cone (1 by default)
  17464. * @param angle the cone base angle (PI by default)
  17465. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17466. */
  17467. constructor(radius?: number, angle?: number,
  17468. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17469. directionRandomizer?: number);
  17470. /**
  17471. * Called by the particle System when the direction is computed for the created particle.
  17472. * @param worldMatrix is the world matrix of the particle system
  17473. * @param directionToUpdate is the direction vector to update with the result
  17474. * @param particle is the particle we are computed the direction for
  17475. */
  17476. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17477. /**
  17478. * Called by the particle System when the position is computed for the created particle.
  17479. * @param worldMatrix is the world matrix of the particle system
  17480. * @param positionToUpdate is the position vector to update with the result
  17481. * @param particle is the particle we are computed the position for
  17482. */
  17483. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17484. /**
  17485. * Clones the current emitter and returns a copy of it
  17486. * @returns the new emitter
  17487. */
  17488. clone(): ConeParticleEmitter;
  17489. /**
  17490. * Called by the GPUParticleSystem to setup the update shader
  17491. * @param effect defines the update shader
  17492. */
  17493. applyToShader(effect: Effect): void;
  17494. /**
  17495. * Returns a string to use to update the GPU particles update shader
  17496. * @returns a string containng the defines string
  17497. */
  17498. getEffectDefines(): string;
  17499. /**
  17500. * Returns the string "ConeParticleEmitter"
  17501. * @returns a string containing the class name
  17502. */
  17503. getClassName(): string;
  17504. /**
  17505. * Serializes the particle system to a JSON object.
  17506. * @returns the JSON object
  17507. */
  17508. serialize(): any;
  17509. /**
  17510. * Parse properties from a JSON object
  17511. * @param serializationObject defines the JSON object
  17512. */
  17513. parse(serializationObject: any): void;
  17514. }
  17515. }
  17516. declare module BABYLON {
  17517. /**
  17518. * Particle emitter emitting particles from the inside of a cylinder.
  17519. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17520. */
  17521. export class CylinderParticleEmitter implements IParticleEmitterType {
  17522. /**
  17523. * The radius of the emission cylinder.
  17524. */
  17525. radius: number;
  17526. /**
  17527. * The height of the emission cylinder.
  17528. */
  17529. height: number;
  17530. /**
  17531. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17532. */
  17533. radiusRange: number;
  17534. /**
  17535. * How much to randomize the particle direction [0-1].
  17536. */
  17537. directionRandomizer: number;
  17538. /**
  17539. * Creates a new instance CylinderParticleEmitter
  17540. * @param radius the radius of the emission cylinder (1 by default)
  17541. * @param height the height of the emission cylinder (1 by default)
  17542. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17543. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17544. */
  17545. constructor(
  17546. /**
  17547. * The radius of the emission cylinder.
  17548. */
  17549. radius?: number,
  17550. /**
  17551. * The height of the emission cylinder.
  17552. */
  17553. height?: number,
  17554. /**
  17555. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17556. */
  17557. radiusRange?: number,
  17558. /**
  17559. * How much to randomize the particle direction [0-1].
  17560. */
  17561. directionRandomizer?: number);
  17562. /**
  17563. * Called by the particle System when the direction is computed for the created particle.
  17564. * @param worldMatrix is the world matrix of the particle system
  17565. * @param directionToUpdate is the direction vector to update with the result
  17566. * @param particle is the particle we are computed the direction for
  17567. */
  17568. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17569. /**
  17570. * Called by the particle System when the position is computed for the created particle.
  17571. * @param worldMatrix is the world matrix of the particle system
  17572. * @param positionToUpdate is the position vector to update with the result
  17573. * @param particle is the particle we are computed the position for
  17574. */
  17575. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17576. /**
  17577. * Clones the current emitter and returns a copy of it
  17578. * @returns the new emitter
  17579. */
  17580. clone(): CylinderParticleEmitter;
  17581. /**
  17582. * Called by the GPUParticleSystem to setup the update shader
  17583. * @param effect defines the update shader
  17584. */
  17585. applyToShader(effect: Effect): void;
  17586. /**
  17587. * Returns a string to use to update the GPU particles update shader
  17588. * @returns a string containng the defines string
  17589. */
  17590. getEffectDefines(): string;
  17591. /**
  17592. * Returns the string "CylinderParticleEmitter"
  17593. * @returns a string containing the class name
  17594. */
  17595. getClassName(): string;
  17596. /**
  17597. * Serializes the particle system to a JSON object.
  17598. * @returns the JSON object
  17599. */
  17600. serialize(): any;
  17601. /**
  17602. * Parse properties from a JSON object
  17603. * @param serializationObject defines the JSON object
  17604. */
  17605. parse(serializationObject: any): void;
  17606. }
  17607. /**
  17608. * Particle emitter emitting particles from the inside of a cylinder.
  17609. * It emits the particles randomly between two vectors.
  17610. */
  17611. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17612. /**
  17613. * The min limit of the emission direction.
  17614. */
  17615. direction1: Vector3;
  17616. /**
  17617. * The max limit of the emission direction.
  17618. */
  17619. direction2: Vector3;
  17620. /**
  17621. * Creates a new instance CylinderDirectedParticleEmitter
  17622. * @param radius the radius of the emission cylinder (1 by default)
  17623. * @param height the height of the emission cylinder (1 by default)
  17624. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17625. * @param direction1 the min limit of the emission direction (up vector by default)
  17626. * @param direction2 the max limit of the emission direction (up vector by default)
  17627. */
  17628. constructor(radius?: number, height?: number, radiusRange?: number,
  17629. /**
  17630. * The min limit of the emission direction.
  17631. */
  17632. direction1?: Vector3,
  17633. /**
  17634. * The max limit of the emission direction.
  17635. */
  17636. direction2?: Vector3);
  17637. /**
  17638. * Called by the particle System when the direction is computed for the created particle.
  17639. * @param worldMatrix is the world matrix of the particle system
  17640. * @param directionToUpdate is the direction vector to update with the result
  17641. * @param particle is the particle we are computed the direction for
  17642. */
  17643. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17644. /**
  17645. * Clones the current emitter and returns a copy of it
  17646. * @returns the new emitter
  17647. */
  17648. clone(): CylinderDirectedParticleEmitter;
  17649. /**
  17650. * Called by the GPUParticleSystem to setup the update shader
  17651. * @param effect defines the update shader
  17652. */
  17653. applyToShader(effect: Effect): void;
  17654. /**
  17655. * Returns a string to use to update the GPU particles update shader
  17656. * @returns a string containng the defines string
  17657. */
  17658. getEffectDefines(): string;
  17659. /**
  17660. * Returns the string "CylinderDirectedParticleEmitter"
  17661. * @returns a string containing the class name
  17662. */
  17663. getClassName(): string;
  17664. /**
  17665. * Serializes the particle system to a JSON object.
  17666. * @returns the JSON object
  17667. */
  17668. serialize(): any;
  17669. /**
  17670. * Parse properties from a JSON object
  17671. * @param serializationObject defines the JSON object
  17672. */
  17673. parse(serializationObject: any): void;
  17674. }
  17675. }
  17676. declare module BABYLON {
  17677. /**
  17678. * Particle emitter emitting particles from the inside of a hemisphere.
  17679. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17680. */
  17681. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17682. /**
  17683. * The radius of the emission hemisphere.
  17684. */
  17685. radius: number;
  17686. /**
  17687. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17688. */
  17689. radiusRange: number;
  17690. /**
  17691. * How much to randomize the particle direction [0-1].
  17692. */
  17693. directionRandomizer: number;
  17694. /**
  17695. * Creates a new instance HemisphericParticleEmitter
  17696. * @param radius the radius of the emission hemisphere (1 by default)
  17697. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17698. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17699. */
  17700. constructor(
  17701. /**
  17702. * The radius of the emission hemisphere.
  17703. */
  17704. radius?: number,
  17705. /**
  17706. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17707. */
  17708. radiusRange?: number,
  17709. /**
  17710. * How much to randomize the particle direction [0-1].
  17711. */
  17712. directionRandomizer?: number);
  17713. /**
  17714. * Called by the particle System when the direction is computed for the created particle.
  17715. * @param worldMatrix is the world matrix of the particle system
  17716. * @param directionToUpdate is the direction vector to update with the result
  17717. * @param particle is the particle we are computed the direction for
  17718. */
  17719. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17720. /**
  17721. * Called by the particle System when the position is computed for the created particle.
  17722. * @param worldMatrix is the world matrix of the particle system
  17723. * @param positionToUpdate is the position vector to update with the result
  17724. * @param particle is the particle we are computed the position for
  17725. */
  17726. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17727. /**
  17728. * Clones the current emitter and returns a copy of it
  17729. * @returns the new emitter
  17730. */
  17731. clone(): HemisphericParticleEmitter;
  17732. /**
  17733. * Called by the GPUParticleSystem to setup the update shader
  17734. * @param effect defines the update shader
  17735. */
  17736. applyToShader(effect: Effect): void;
  17737. /**
  17738. * Returns a string to use to update the GPU particles update shader
  17739. * @returns a string containng the defines string
  17740. */
  17741. getEffectDefines(): string;
  17742. /**
  17743. * Returns the string "HemisphericParticleEmitter"
  17744. * @returns a string containing the class name
  17745. */
  17746. getClassName(): string;
  17747. /**
  17748. * Serializes the particle system to a JSON object.
  17749. * @returns the JSON object
  17750. */
  17751. serialize(): any;
  17752. /**
  17753. * Parse properties from a JSON object
  17754. * @param serializationObject defines the JSON object
  17755. */
  17756. parse(serializationObject: any): void;
  17757. }
  17758. }
  17759. declare module BABYLON {
  17760. /**
  17761. * Particle emitter emitting particles from a point.
  17762. * It emits the particles randomly between 2 given directions.
  17763. */
  17764. export class PointParticleEmitter implements IParticleEmitterType {
  17765. /**
  17766. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17767. */
  17768. direction1: Vector3;
  17769. /**
  17770. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17771. */
  17772. direction2: Vector3;
  17773. /**
  17774. * Creates a new instance PointParticleEmitter
  17775. */
  17776. constructor();
  17777. /**
  17778. * Called by the particle System when the direction is computed for the created particle.
  17779. * @param worldMatrix is the world matrix of the particle system
  17780. * @param directionToUpdate is the direction vector to update with the result
  17781. * @param particle is the particle we are computed the direction for
  17782. */
  17783. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17784. /**
  17785. * Called by the particle System when the position is computed for the created particle.
  17786. * @param worldMatrix is the world matrix of the particle system
  17787. * @param positionToUpdate is the position vector to update with the result
  17788. * @param particle is the particle we are computed the position for
  17789. */
  17790. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17791. /**
  17792. * Clones the current emitter and returns a copy of it
  17793. * @returns the new emitter
  17794. */
  17795. clone(): PointParticleEmitter;
  17796. /**
  17797. * Called by the GPUParticleSystem to setup the update shader
  17798. * @param effect defines the update shader
  17799. */
  17800. applyToShader(effect: Effect): void;
  17801. /**
  17802. * Returns a string to use to update the GPU particles update shader
  17803. * @returns a string containng the defines string
  17804. */
  17805. getEffectDefines(): string;
  17806. /**
  17807. * Returns the string "PointParticleEmitter"
  17808. * @returns a string containing the class name
  17809. */
  17810. getClassName(): string;
  17811. /**
  17812. * Serializes the particle system to a JSON object.
  17813. * @returns the JSON object
  17814. */
  17815. serialize(): any;
  17816. /**
  17817. * Parse properties from a JSON object
  17818. * @param serializationObject defines the JSON object
  17819. */
  17820. parse(serializationObject: any): void;
  17821. }
  17822. }
  17823. declare module BABYLON {
  17824. /**
  17825. * Particle emitter emitting particles from the inside of a sphere.
  17826. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17827. */
  17828. export class SphereParticleEmitter implements IParticleEmitterType {
  17829. /**
  17830. * The radius of the emission sphere.
  17831. */
  17832. radius: number;
  17833. /**
  17834. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17835. */
  17836. radiusRange: number;
  17837. /**
  17838. * How much to randomize the particle direction [0-1].
  17839. */
  17840. directionRandomizer: number;
  17841. /**
  17842. * Creates a new instance SphereParticleEmitter
  17843. * @param radius the radius of the emission sphere (1 by default)
  17844. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17845. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17846. */
  17847. constructor(
  17848. /**
  17849. * The radius of the emission sphere.
  17850. */
  17851. radius?: number,
  17852. /**
  17853. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17854. */
  17855. radiusRange?: number,
  17856. /**
  17857. * How much to randomize the particle direction [0-1].
  17858. */
  17859. directionRandomizer?: number);
  17860. /**
  17861. * Called by the particle System when the direction is computed for the created particle.
  17862. * @param worldMatrix is the world matrix of the particle system
  17863. * @param directionToUpdate is the direction vector to update with the result
  17864. * @param particle is the particle we are computed the direction for
  17865. */
  17866. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17867. /**
  17868. * Called by the particle System when the position is computed for the created particle.
  17869. * @param worldMatrix is the world matrix of the particle system
  17870. * @param positionToUpdate is the position vector to update with the result
  17871. * @param particle is the particle we are computed the position for
  17872. */
  17873. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17874. /**
  17875. * Clones the current emitter and returns a copy of it
  17876. * @returns the new emitter
  17877. */
  17878. clone(): SphereParticleEmitter;
  17879. /**
  17880. * Called by the GPUParticleSystem to setup the update shader
  17881. * @param effect defines the update shader
  17882. */
  17883. applyToShader(effect: Effect): void;
  17884. /**
  17885. * Returns a string to use to update the GPU particles update shader
  17886. * @returns a string containng the defines string
  17887. */
  17888. getEffectDefines(): string;
  17889. /**
  17890. * Returns the string "SphereParticleEmitter"
  17891. * @returns a string containing the class name
  17892. */
  17893. getClassName(): string;
  17894. /**
  17895. * Serializes the particle system to a JSON object.
  17896. * @returns the JSON object
  17897. */
  17898. serialize(): any;
  17899. /**
  17900. * Parse properties from a JSON object
  17901. * @param serializationObject defines the JSON object
  17902. */
  17903. parse(serializationObject: any): void;
  17904. }
  17905. /**
  17906. * Particle emitter emitting particles from the inside of a sphere.
  17907. * It emits the particles randomly between two vectors.
  17908. */
  17909. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17910. /**
  17911. * The min limit of the emission direction.
  17912. */
  17913. direction1: Vector3;
  17914. /**
  17915. * The max limit of the emission direction.
  17916. */
  17917. direction2: Vector3;
  17918. /**
  17919. * Creates a new instance SphereDirectedParticleEmitter
  17920. * @param radius the radius of the emission sphere (1 by default)
  17921. * @param direction1 the min limit of the emission direction (up vector by default)
  17922. * @param direction2 the max limit of the emission direction (up vector by default)
  17923. */
  17924. constructor(radius?: number,
  17925. /**
  17926. * The min limit of the emission direction.
  17927. */
  17928. direction1?: Vector3,
  17929. /**
  17930. * The max limit of the emission direction.
  17931. */
  17932. direction2?: Vector3);
  17933. /**
  17934. * Called by the particle System when the direction is computed for the created particle.
  17935. * @param worldMatrix is the world matrix of the particle system
  17936. * @param directionToUpdate is the direction vector to update with the result
  17937. * @param particle is the particle we are computed the direction for
  17938. */
  17939. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17940. /**
  17941. * Clones the current emitter and returns a copy of it
  17942. * @returns the new emitter
  17943. */
  17944. clone(): SphereDirectedParticleEmitter;
  17945. /**
  17946. * Called by the GPUParticleSystem to setup the update shader
  17947. * @param effect defines the update shader
  17948. */
  17949. applyToShader(effect: Effect): void;
  17950. /**
  17951. * Returns a string to use to update the GPU particles update shader
  17952. * @returns a string containng the defines string
  17953. */
  17954. getEffectDefines(): string;
  17955. /**
  17956. * Returns the string "SphereDirectedParticleEmitter"
  17957. * @returns a string containing the class name
  17958. */
  17959. getClassName(): string;
  17960. /**
  17961. * Serializes the particle system to a JSON object.
  17962. * @returns the JSON object
  17963. */
  17964. serialize(): any;
  17965. /**
  17966. * Parse properties from a JSON object
  17967. * @param serializationObject defines the JSON object
  17968. */
  17969. parse(serializationObject: any): void;
  17970. }
  17971. }
  17972. declare module BABYLON {
  17973. /**
  17974. * Interface representing a particle system in Babylon.js.
  17975. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17976. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17977. */
  17978. export interface IParticleSystem {
  17979. /**
  17980. * List of animations used by the particle system.
  17981. */
  17982. animations: Animation[];
  17983. /**
  17984. * The id of the Particle system.
  17985. */
  17986. id: string;
  17987. /**
  17988. * The name of the Particle system.
  17989. */
  17990. name: string;
  17991. /**
  17992. * The emitter represents the Mesh or position we are attaching the particle system to.
  17993. */
  17994. emitter: Nullable<AbstractMesh | Vector3>;
  17995. /**
  17996. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17997. */
  17998. isBillboardBased: boolean;
  17999. /**
  18000. * The rendering group used by the Particle system to chose when to render.
  18001. */
  18002. renderingGroupId: number;
  18003. /**
  18004. * The layer mask we are rendering the particles through.
  18005. */
  18006. layerMask: number;
  18007. /**
  18008. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18009. */
  18010. updateSpeed: number;
  18011. /**
  18012. * The amount of time the particle system is running (depends of the overall update speed).
  18013. */
  18014. targetStopDuration: number;
  18015. /**
  18016. * The texture used to render each particle. (this can be a spritesheet)
  18017. */
  18018. particleTexture: Nullable<Texture>;
  18019. /**
  18020. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18021. */
  18022. blendMode: number;
  18023. /**
  18024. * Minimum life time of emitting particles.
  18025. */
  18026. minLifeTime: number;
  18027. /**
  18028. * Maximum life time of emitting particles.
  18029. */
  18030. maxLifeTime: number;
  18031. /**
  18032. * Minimum Size of emitting particles.
  18033. */
  18034. minSize: number;
  18035. /**
  18036. * Maximum Size of emitting particles.
  18037. */
  18038. maxSize: number;
  18039. /**
  18040. * Minimum scale of emitting particles on X axis.
  18041. */
  18042. minScaleX: number;
  18043. /**
  18044. * Maximum scale of emitting particles on X axis.
  18045. */
  18046. maxScaleX: number;
  18047. /**
  18048. * Minimum scale of emitting particles on Y axis.
  18049. */
  18050. minScaleY: number;
  18051. /**
  18052. * Maximum scale of emitting particles on Y axis.
  18053. */
  18054. maxScaleY: number;
  18055. /**
  18056. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18057. */
  18058. color1: Color4;
  18059. /**
  18060. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18061. */
  18062. color2: Color4;
  18063. /**
  18064. * Color the particle will have at the end of its lifetime.
  18065. */
  18066. colorDead: Color4;
  18067. /**
  18068. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18069. */
  18070. emitRate: number;
  18071. /**
  18072. * You can use gravity if you want to give an orientation to your particles.
  18073. */
  18074. gravity: Vector3;
  18075. /**
  18076. * Minimum power of emitting particles.
  18077. */
  18078. minEmitPower: number;
  18079. /**
  18080. * Maximum power of emitting particles.
  18081. */
  18082. maxEmitPower: number;
  18083. /**
  18084. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18085. */
  18086. minAngularSpeed: number;
  18087. /**
  18088. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18089. */
  18090. maxAngularSpeed: number;
  18091. /**
  18092. * Gets or sets the minimal initial rotation in radians.
  18093. */
  18094. minInitialRotation: number;
  18095. /**
  18096. * Gets or sets the maximal initial rotation in radians.
  18097. */
  18098. maxInitialRotation: number;
  18099. /**
  18100. * The particle emitter type defines the emitter used by the particle system.
  18101. * It can be for example box, sphere, or cone...
  18102. */
  18103. particleEmitterType: Nullable<IParticleEmitterType>;
  18104. /**
  18105. * Defines the delay in milliseconds before starting the system (0 by default)
  18106. */
  18107. startDelay: number;
  18108. /**
  18109. * 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
  18110. */
  18111. preWarmCycles: number;
  18112. /**
  18113. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18114. */
  18115. preWarmStepOffset: number;
  18116. /**
  18117. * 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)
  18118. */
  18119. spriteCellChangeSpeed: number;
  18120. /**
  18121. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18122. */
  18123. startSpriteCellID: number;
  18124. /**
  18125. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18126. */
  18127. endSpriteCellID: number;
  18128. /**
  18129. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18130. */
  18131. spriteCellWidth: number;
  18132. /**
  18133. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18134. */
  18135. spriteCellHeight: number;
  18136. /**
  18137. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18138. */
  18139. spriteRandomStartCell: boolean;
  18140. /**
  18141. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18142. */
  18143. isAnimationSheetEnabled: boolean;
  18144. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18145. translationPivot: Vector2;
  18146. /**
  18147. * Gets or sets a texture used to add random noise to particle positions
  18148. */
  18149. noiseTexture: Nullable<BaseTexture>;
  18150. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18151. noiseStrength: Vector3;
  18152. /**
  18153. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18154. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18155. */
  18156. billboardMode: number;
  18157. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18158. limitVelocityDamping: number;
  18159. /**
  18160. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18161. */
  18162. beginAnimationOnStart: boolean;
  18163. /**
  18164. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18165. */
  18166. beginAnimationFrom: number;
  18167. /**
  18168. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18169. */
  18170. beginAnimationTo: number;
  18171. /**
  18172. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18173. */
  18174. beginAnimationLoop: boolean;
  18175. /**
  18176. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18177. */
  18178. disposeOnStop: boolean;
  18179. /**
  18180. * Gets the maximum number of particles active at the same time.
  18181. * @returns The max number of active particles.
  18182. */
  18183. getCapacity(): number;
  18184. /**
  18185. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18186. * @returns True if it has been started, otherwise false.
  18187. */
  18188. isStarted(): boolean;
  18189. /**
  18190. * Animates the particle system for this frame.
  18191. */
  18192. animate(): void;
  18193. /**
  18194. * Renders the particle system in its current state.
  18195. * @returns the current number of particles
  18196. */
  18197. render(): number;
  18198. /**
  18199. * Dispose the particle system and frees its associated resources.
  18200. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18201. */
  18202. dispose(disposeTexture?: boolean): void;
  18203. /**
  18204. * Clones the particle system.
  18205. * @param name The name of the cloned object
  18206. * @param newEmitter The new emitter to use
  18207. * @returns the cloned particle system
  18208. */
  18209. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18210. /**
  18211. * Serializes the particle system to a JSON object.
  18212. * @returns the JSON object
  18213. */
  18214. serialize(): any;
  18215. /**
  18216. * Rebuild the particle system
  18217. */
  18218. rebuild(): void;
  18219. /**
  18220. * Starts the particle system and begins to emit
  18221. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18222. */
  18223. start(delay?: number): void;
  18224. /**
  18225. * Stops the particle system.
  18226. */
  18227. stop(): void;
  18228. /**
  18229. * Remove all active particles
  18230. */
  18231. reset(): void;
  18232. /**
  18233. * Is this system ready to be used/rendered
  18234. * @return true if the system is ready
  18235. */
  18236. isReady(): boolean;
  18237. /**
  18238. * Adds a new color gradient
  18239. * @param gradient defines the gradient to use (between 0 and 1)
  18240. * @param color1 defines the color to affect to the specified gradient
  18241. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18242. * @returns the current particle system
  18243. */
  18244. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18245. /**
  18246. * Remove a specific color gradient
  18247. * @param gradient defines the gradient to remove
  18248. * @returns the current particle system
  18249. */
  18250. removeColorGradient(gradient: number): IParticleSystem;
  18251. /**
  18252. * Adds a new size gradient
  18253. * @param gradient defines the gradient to use (between 0 and 1)
  18254. * @param factor defines the size factor to affect to the specified gradient
  18255. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18256. * @returns the current particle system
  18257. */
  18258. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18259. /**
  18260. * Remove a specific size gradient
  18261. * @param gradient defines the gradient to remove
  18262. * @returns the current particle system
  18263. */
  18264. removeSizeGradient(gradient: number): IParticleSystem;
  18265. /**
  18266. * Gets the current list of color gradients.
  18267. * You must use addColorGradient and removeColorGradient to udpate this list
  18268. * @returns the list of color gradients
  18269. */
  18270. getColorGradients(): Nullable<Array<ColorGradient>>;
  18271. /**
  18272. * Gets the current list of size gradients.
  18273. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18274. * @returns the list of size gradients
  18275. */
  18276. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18277. /**
  18278. * Gets the current list of angular speed gradients.
  18279. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18280. * @returns the list of angular speed gradients
  18281. */
  18282. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18283. /**
  18284. * Adds a new angular speed gradient
  18285. * @param gradient defines the gradient to use (between 0 and 1)
  18286. * @param factor defines the angular speed to affect to the specified gradient
  18287. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18288. * @returns the current particle system
  18289. */
  18290. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18291. /**
  18292. * Remove a specific angular speed gradient
  18293. * @param gradient defines the gradient to remove
  18294. * @returns the current particle system
  18295. */
  18296. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18297. /**
  18298. * Gets the current list of velocity gradients.
  18299. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18300. * @returns the list of velocity gradients
  18301. */
  18302. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18303. /**
  18304. * Adds a new velocity gradient
  18305. * @param gradient defines the gradient to use (between 0 and 1)
  18306. * @param factor defines the velocity to affect to the specified gradient
  18307. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18308. * @returns the current particle system
  18309. */
  18310. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18311. /**
  18312. * Remove a specific velocity gradient
  18313. * @param gradient defines the gradient to remove
  18314. * @returns the current particle system
  18315. */
  18316. removeVelocityGradient(gradient: number): IParticleSystem;
  18317. /**
  18318. * Gets the current list of limit velocity gradients.
  18319. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18320. * @returns the list of limit velocity gradients
  18321. */
  18322. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18323. /**
  18324. * Adds a new limit velocity gradient
  18325. * @param gradient defines the gradient to use (between 0 and 1)
  18326. * @param factor defines the limit velocity to affect to the specified gradient
  18327. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18328. * @returns the current particle system
  18329. */
  18330. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18331. /**
  18332. * Remove a specific limit velocity gradient
  18333. * @param gradient defines the gradient to remove
  18334. * @returns the current particle system
  18335. */
  18336. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18337. /**
  18338. * Adds a new drag gradient
  18339. * @param gradient defines the gradient to use (between 0 and 1)
  18340. * @param factor defines the drag to affect to the specified gradient
  18341. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18342. * @returns the current particle system
  18343. */
  18344. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18345. /**
  18346. * Remove a specific drag gradient
  18347. * @param gradient defines the gradient to remove
  18348. * @returns the current particle system
  18349. */
  18350. removeDragGradient(gradient: number): IParticleSystem;
  18351. /**
  18352. * Gets the current list of drag gradients.
  18353. * You must use addDragGradient and removeDragGradient to udpate this list
  18354. * @returns the list of drag gradients
  18355. */
  18356. getDragGradients(): Nullable<Array<FactorGradient>>;
  18357. /**
  18358. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18359. * @param gradient defines the gradient to use (between 0 and 1)
  18360. * @param factor defines the emit rate to affect to the specified gradient
  18361. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18362. * @returns the current particle system
  18363. */
  18364. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18365. /**
  18366. * Remove a specific emit rate gradient
  18367. * @param gradient defines the gradient to remove
  18368. * @returns the current particle system
  18369. */
  18370. removeEmitRateGradient(gradient: number): IParticleSystem;
  18371. /**
  18372. * Gets the current list of emit rate gradients.
  18373. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18374. * @returns the list of emit rate gradients
  18375. */
  18376. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18377. /**
  18378. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18379. * @param gradient defines the gradient to use (between 0 and 1)
  18380. * @param factor defines the start size to affect to the specified gradient
  18381. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18382. * @returns the current particle system
  18383. */
  18384. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18385. /**
  18386. * Remove a specific start size gradient
  18387. * @param gradient defines the gradient to remove
  18388. * @returns the current particle system
  18389. */
  18390. removeStartSizeGradient(gradient: number): IParticleSystem;
  18391. /**
  18392. * Gets the current list of start size gradients.
  18393. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18394. * @returns the list of start size gradients
  18395. */
  18396. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18397. /**
  18398. * Adds a new life time gradient
  18399. * @param gradient defines the gradient to use (between 0 and 1)
  18400. * @param factor defines the life time factor to affect to the specified gradient
  18401. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18402. * @returns the current particle system
  18403. */
  18404. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18405. /**
  18406. * Remove a specific life time gradient
  18407. * @param gradient defines the gradient to remove
  18408. * @returns the current particle system
  18409. */
  18410. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18411. /**
  18412. * Gets the current list of life time gradients.
  18413. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18414. * @returns the list of life time gradients
  18415. */
  18416. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18417. /**
  18418. * Gets the current list of color gradients.
  18419. * You must use addColorGradient and removeColorGradient to udpate this list
  18420. * @returns the list of color gradients
  18421. */
  18422. getColorGradients(): Nullable<Array<ColorGradient>>;
  18423. /**
  18424. * Adds a new ramp gradient used to remap particle colors
  18425. * @param gradient defines the gradient to use (between 0 and 1)
  18426. * @param color defines the color to affect to the specified gradient
  18427. * @returns the current particle system
  18428. */
  18429. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18430. /**
  18431. * Gets the current list of ramp gradients.
  18432. * You must use addRampGradient and removeRampGradient to udpate this list
  18433. * @returns the list of ramp gradients
  18434. */
  18435. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18436. /** Gets or sets a boolean indicating that ramp gradients must be used
  18437. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18438. */
  18439. useRampGradients: boolean;
  18440. /**
  18441. * Adds a new color remap gradient
  18442. * @param gradient defines the gradient to use (between 0 and 1)
  18443. * @param min defines the color remap minimal range
  18444. * @param max defines the color remap maximal range
  18445. * @returns the current particle system
  18446. */
  18447. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18448. /**
  18449. * Gets the current list of color remap gradients.
  18450. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18451. * @returns the list of color remap gradients
  18452. */
  18453. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18454. /**
  18455. * Adds a new alpha remap gradient
  18456. * @param gradient defines the gradient to use (between 0 and 1)
  18457. * @param min defines the alpha remap minimal range
  18458. * @param max defines the alpha remap maximal range
  18459. * @returns the current particle system
  18460. */
  18461. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18462. /**
  18463. * Gets the current list of alpha remap gradients.
  18464. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18465. * @returns the list of alpha remap gradients
  18466. */
  18467. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18468. /**
  18469. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18470. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18471. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18472. * @returns the emitter
  18473. */
  18474. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18475. /**
  18476. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18477. * @param radius The radius of the hemisphere to emit from
  18478. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18479. * @returns the emitter
  18480. */
  18481. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18482. /**
  18483. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18484. * @param radius The radius of the sphere to emit from
  18485. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18486. * @returns the emitter
  18487. */
  18488. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18489. /**
  18490. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18491. * @param radius The radius of the sphere to emit from
  18492. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18493. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18494. * @returns the emitter
  18495. */
  18496. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18497. /**
  18498. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18499. * @param radius The radius of the emission cylinder
  18500. * @param height The height of the emission cylinder
  18501. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18502. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18503. * @returns the emitter
  18504. */
  18505. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18506. /**
  18507. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18508. * @param radius The radius of the cylinder to emit from
  18509. * @param height The height of the emission cylinder
  18510. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18511. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18512. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18513. * @returns the emitter
  18514. */
  18515. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18516. /**
  18517. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18518. * @param radius The radius of the cone to emit from
  18519. * @param angle The base angle of the cone
  18520. * @returns the emitter
  18521. */
  18522. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18523. /**
  18524. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18525. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18526. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18527. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18528. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18529. * @returns the emitter
  18530. */
  18531. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18532. /**
  18533. * Get hosting scene
  18534. * @returns the scene
  18535. */
  18536. getScene(): Scene;
  18537. }
  18538. }
  18539. declare module BABYLON {
  18540. /**
  18541. * Creates an instance based on a source mesh.
  18542. */
  18543. export class InstancedMesh extends AbstractMesh {
  18544. private _sourceMesh;
  18545. private _currentLOD;
  18546. /** @hidden */
  18547. _indexInSourceMeshInstanceArray: number;
  18548. constructor(name: string, source: Mesh);
  18549. /**
  18550. * Returns the string "InstancedMesh".
  18551. */
  18552. getClassName(): string;
  18553. /** Gets the list of lights affecting that mesh */
  18554. readonly lightSources: Light[];
  18555. _resyncLightSources(): void;
  18556. _resyncLighSource(light: Light): void;
  18557. _removeLightSource(light: Light): void;
  18558. /**
  18559. * If the source mesh receives shadows
  18560. */
  18561. readonly receiveShadows: boolean;
  18562. /**
  18563. * The material of the source mesh
  18564. */
  18565. readonly material: Nullable<Material>;
  18566. /**
  18567. * Visibility of the source mesh
  18568. */
  18569. readonly visibility: number;
  18570. /**
  18571. * Skeleton of the source mesh
  18572. */
  18573. readonly skeleton: Nullable<Skeleton>;
  18574. /**
  18575. * Rendering ground id of the source mesh
  18576. */
  18577. renderingGroupId: number;
  18578. /**
  18579. * Returns the total number of vertices (integer).
  18580. */
  18581. getTotalVertices(): number;
  18582. /**
  18583. * Returns a positive integer : the total number of indices in this mesh geometry.
  18584. * @returns the numner of indices or zero if the mesh has no geometry.
  18585. */
  18586. getTotalIndices(): number;
  18587. /**
  18588. * The source mesh of the instance
  18589. */
  18590. readonly sourceMesh: Mesh;
  18591. /**
  18592. * Is this node ready to be used/rendered
  18593. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18594. * @return {boolean} is it ready
  18595. */
  18596. isReady(completeCheck?: boolean): boolean;
  18597. /**
  18598. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18599. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18600. * @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.
  18601. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18602. */
  18603. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18604. /**
  18605. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18606. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18607. * The `data` are either a numeric array either a Float32Array.
  18608. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18609. * 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).
  18610. * Note that a new underlying VertexBuffer object is created each call.
  18611. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18612. *
  18613. * Possible `kind` values :
  18614. * - VertexBuffer.PositionKind
  18615. * - VertexBuffer.UVKind
  18616. * - VertexBuffer.UV2Kind
  18617. * - VertexBuffer.UV3Kind
  18618. * - VertexBuffer.UV4Kind
  18619. * - VertexBuffer.UV5Kind
  18620. * - VertexBuffer.UV6Kind
  18621. * - VertexBuffer.ColorKind
  18622. * - VertexBuffer.MatricesIndicesKind
  18623. * - VertexBuffer.MatricesIndicesExtraKind
  18624. * - VertexBuffer.MatricesWeightsKind
  18625. * - VertexBuffer.MatricesWeightsExtraKind
  18626. *
  18627. * Returns the Mesh.
  18628. */
  18629. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18630. /**
  18631. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18632. * If the mesh has no geometry, it is simply returned as it is.
  18633. * The `data` are either a numeric array either a Float32Array.
  18634. * No new underlying VertexBuffer object is created.
  18635. * 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.
  18636. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18637. *
  18638. * Possible `kind` values :
  18639. * - VertexBuffer.PositionKind
  18640. * - VertexBuffer.UVKind
  18641. * - VertexBuffer.UV2Kind
  18642. * - VertexBuffer.UV3Kind
  18643. * - VertexBuffer.UV4Kind
  18644. * - VertexBuffer.UV5Kind
  18645. * - VertexBuffer.UV6Kind
  18646. * - VertexBuffer.ColorKind
  18647. * - VertexBuffer.MatricesIndicesKind
  18648. * - VertexBuffer.MatricesIndicesExtraKind
  18649. * - VertexBuffer.MatricesWeightsKind
  18650. * - VertexBuffer.MatricesWeightsExtraKind
  18651. *
  18652. * Returns the Mesh.
  18653. */
  18654. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18655. /**
  18656. * Sets the mesh indices.
  18657. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18658. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18659. * This method creates a new index buffer each call.
  18660. * Returns the Mesh.
  18661. */
  18662. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18663. /**
  18664. * Boolean : True if the mesh owns the requested kind of data.
  18665. */
  18666. isVerticesDataPresent(kind: string): boolean;
  18667. /**
  18668. * Returns an array of indices (IndicesArray).
  18669. */
  18670. getIndices(): Nullable<IndicesArray>;
  18671. readonly _positions: Nullable<Vector3[]>;
  18672. /**
  18673. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18674. * This means the mesh underlying bounding box and sphere are recomputed.
  18675. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18676. * @returns the current mesh
  18677. */
  18678. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18679. /** @hidden */
  18680. _preActivate(): InstancedMesh;
  18681. /** @hidden */
  18682. _activate(renderId: number, intermediateRendering: boolean): boolean;
  18683. /** @hidden */
  18684. _postActivate(): void;
  18685. getWorldMatrix(): Matrix;
  18686. readonly isAnInstance: boolean;
  18687. /**
  18688. * Returns the current associated LOD AbstractMesh.
  18689. */
  18690. getLOD(camera: Camera): AbstractMesh;
  18691. /** @hidden */
  18692. _syncSubMeshes(): InstancedMesh;
  18693. /** @hidden */
  18694. _generatePointsArray(): boolean;
  18695. /**
  18696. * Creates a new InstancedMesh from the current mesh.
  18697. * - name (string) : the cloned mesh name
  18698. * - newParent (optional Node) : the optional Node to parent the clone to.
  18699. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18700. *
  18701. * Returns the clone.
  18702. */
  18703. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18704. /**
  18705. * Disposes the InstancedMesh.
  18706. * Returns nothing.
  18707. */
  18708. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18709. }
  18710. }
  18711. declare module BABYLON {
  18712. /**
  18713. * Defines the options associated with the creation of a shader material.
  18714. */
  18715. export interface IShaderMaterialOptions {
  18716. /**
  18717. * Does the material work in alpha blend mode
  18718. */
  18719. needAlphaBlending: boolean;
  18720. /**
  18721. * Does the material work in alpha test mode
  18722. */
  18723. needAlphaTesting: boolean;
  18724. /**
  18725. * The list of attribute names used in the shader
  18726. */
  18727. attributes: string[];
  18728. /**
  18729. * The list of unifrom names used in the shader
  18730. */
  18731. uniforms: string[];
  18732. /**
  18733. * The list of UBO names used in the shader
  18734. */
  18735. uniformBuffers: string[];
  18736. /**
  18737. * The list of sampler names used in the shader
  18738. */
  18739. samplers: string[];
  18740. /**
  18741. * The list of defines used in the shader
  18742. */
  18743. defines: string[];
  18744. }
  18745. /**
  18746. * 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.
  18747. *
  18748. * This returned material effects how the mesh will look based on the code in the shaders.
  18749. *
  18750. * @see http://doc.babylonjs.com/how_to/shader_material
  18751. */
  18752. export class ShaderMaterial extends Material {
  18753. private _shaderPath;
  18754. private _options;
  18755. private _textures;
  18756. private _textureArrays;
  18757. private _floats;
  18758. private _ints;
  18759. private _floatsArrays;
  18760. private _colors3;
  18761. private _colors3Arrays;
  18762. private _colors4;
  18763. private _colors4Arrays;
  18764. private _vectors2;
  18765. private _vectors3;
  18766. private _vectors4;
  18767. private _matrices;
  18768. private _matrices3x3;
  18769. private _matrices2x2;
  18770. private _vectors2Arrays;
  18771. private _vectors3Arrays;
  18772. private _vectors4Arrays;
  18773. private _cachedWorldViewMatrix;
  18774. private _cachedWorldViewProjectionMatrix;
  18775. private _renderId;
  18776. /**
  18777. * Instantiate a new shader material.
  18778. * 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.
  18779. * This returned material effects how the mesh will look based on the code in the shaders.
  18780. * @see http://doc.babylonjs.com/how_to/shader_material
  18781. * @param name Define the name of the material in the scene
  18782. * @param scene Define the scene the material belongs to
  18783. * @param shaderPath Defines the route to the shader code in one of three ways:
  18784. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18785. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  18786. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18787. * @param options Define the options used to create the shader
  18788. */
  18789. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18790. /**
  18791. * Gets the options used to compile the shader.
  18792. * They can be modified to trigger a new compilation
  18793. */
  18794. readonly options: IShaderMaterialOptions;
  18795. /**
  18796. * Gets the current class name of the material e.g. "ShaderMaterial"
  18797. * Mainly use in serialization.
  18798. * @returns the class name
  18799. */
  18800. getClassName(): string;
  18801. /**
  18802. * Specifies if the material will require alpha blending
  18803. * @returns a boolean specifying if alpha blending is needed
  18804. */
  18805. needAlphaBlending(): boolean;
  18806. /**
  18807. * Specifies if this material should be rendered in alpha test mode
  18808. * @returns a boolean specifying if an alpha test is needed.
  18809. */
  18810. needAlphaTesting(): boolean;
  18811. private _checkUniform;
  18812. /**
  18813. * Set a texture in the shader.
  18814. * @param name Define the name of the uniform samplers as defined in the shader
  18815. * @param texture Define the texture to bind to this sampler
  18816. * @return the material itself allowing "fluent" like uniform updates
  18817. */
  18818. setTexture(name: string, texture: Texture): ShaderMaterial;
  18819. /**
  18820. * Set a texture array in the shader.
  18821. * @param name Define the name of the uniform sampler array as defined in the shader
  18822. * @param textures Define the list of textures to bind to this sampler
  18823. * @return the material itself allowing "fluent" like uniform updates
  18824. */
  18825. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18826. /**
  18827. * Set a float in the shader.
  18828. * @param name Define the name of the uniform as defined in the shader
  18829. * @param value Define the value to give to the uniform
  18830. * @return the material itself allowing "fluent" like uniform updates
  18831. */
  18832. setFloat(name: string, value: number): ShaderMaterial;
  18833. /**
  18834. * Set a int in the shader.
  18835. * @param name Define the name of the uniform as defined in the shader
  18836. * @param value Define the value to give to the uniform
  18837. * @return the material itself allowing "fluent" like uniform updates
  18838. */
  18839. setInt(name: string, value: number): ShaderMaterial;
  18840. /**
  18841. * Set an array of floats in the shader.
  18842. * @param name Define the name of the uniform as defined in the shader
  18843. * @param value Define the value to give to the uniform
  18844. * @return the material itself allowing "fluent" like uniform updates
  18845. */
  18846. setFloats(name: string, value: number[]): ShaderMaterial;
  18847. /**
  18848. * Set a vec3 in the shader from a Color3.
  18849. * @param name Define the name of the uniform as defined in the shader
  18850. * @param value Define the value to give to the uniform
  18851. * @return the material itself allowing "fluent" like uniform updates
  18852. */
  18853. setColor3(name: string, value: Color3): ShaderMaterial;
  18854. /**
  18855. * Set a vec3 array in the shader from a Color3 array.
  18856. * @param name Define the name of the uniform as defined in the shader
  18857. * @param value Define the value to give to the uniform
  18858. * @return the material itself allowing "fluent" like uniform updates
  18859. */
  18860. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18861. /**
  18862. * Set a vec4 in the shader from a Color4.
  18863. * @param name Define the name of the uniform as defined in the shader
  18864. * @param value Define the value to give to the uniform
  18865. * @return the material itself allowing "fluent" like uniform updates
  18866. */
  18867. setColor4(name: string, value: Color4): ShaderMaterial;
  18868. /**
  18869. * Set a vec4 array in the shader from a Color4 array.
  18870. * @param name Define the name of the uniform as defined in the shader
  18871. * @param value Define the value to give to the uniform
  18872. * @return the material itself allowing "fluent" like uniform updates
  18873. */
  18874. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  18875. /**
  18876. * Set a vec2 in the shader from a Vector2.
  18877. * @param name Define the name of the uniform as defined in the shader
  18878. * @param value Define the value to give to the uniform
  18879. * @return the material itself allowing "fluent" like uniform updates
  18880. */
  18881. setVector2(name: string, value: Vector2): ShaderMaterial;
  18882. /**
  18883. * Set a vec3 in the shader from a Vector3.
  18884. * @param name Define the name of the uniform as defined in the shader
  18885. * @param value Define the value to give to the uniform
  18886. * @return the material itself allowing "fluent" like uniform updates
  18887. */
  18888. setVector3(name: string, value: Vector3): ShaderMaterial;
  18889. /**
  18890. * Set a vec4 in the shader from a Vector4.
  18891. * @param name Define the name of the uniform as defined in the shader
  18892. * @param value Define the value to give to the uniform
  18893. * @return the material itself allowing "fluent" like uniform updates
  18894. */
  18895. setVector4(name: string, value: Vector4): ShaderMaterial;
  18896. /**
  18897. * Set a mat4 in the shader from a Matrix.
  18898. * @param name Define the name of the uniform as defined in the shader
  18899. * @param value Define the value to give to the uniform
  18900. * @return the material itself allowing "fluent" like uniform updates
  18901. */
  18902. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18903. /**
  18904. * Set a mat3 in the shader from a Float32Array.
  18905. * @param name Define the name of the uniform as defined in the shader
  18906. * @param value Define the value to give to the uniform
  18907. * @return the material itself allowing "fluent" like uniform updates
  18908. */
  18909. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18910. /**
  18911. * Set a mat2 in the shader from a Float32Array.
  18912. * @param name Define the name of the uniform as defined in the shader
  18913. * @param value Define the value to give to the uniform
  18914. * @return the material itself allowing "fluent" like uniform updates
  18915. */
  18916. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18917. /**
  18918. * Set a vec2 array in the shader from a number array.
  18919. * @param name Define the name of the uniform as defined in the shader
  18920. * @param value Define the value to give to the uniform
  18921. * @return the material itself allowing "fluent" like uniform updates
  18922. */
  18923. setArray2(name: string, value: number[]): ShaderMaterial;
  18924. /**
  18925. * Set a vec3 array in the shader from a number array.
  18926. * @param name Define the name of the uniform as defined in the shader
  18927. * @param value Define the value to give to the uniform
  18928. * @return the material itself allowing "fluent" like uniform updates
  18929. */
  18930. setArray3(name: string, value: number[]): ShaderMaterial;
  18931. /**
  18932. * Set a vec4 array in the shader from a number array.
  18933. * @param name Define the name of the uniform as defined in the shader
  18934. * @param value Define the value to give to the uniform
  18935. * @return the material itself allowing "fluent" like uniform updates
  18936. */
  18937. setArray4(name: string, value: number[]): ShaderMaterial;
  18938. private _checkCache;
  18939. /**
  18940. * Specifies that the submesh is ready to be used
  18941. * @param mesh defines the mesh to check
  18942. * @param subMesh defines which submesh to check
  18943. * @param useInstances specifies that instances should be used
  18944. * @returns a boolean indicating that the submesh is ready or not
  18945. */
  18946. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18947. /**
  18948. * Checks if the material is ready to render the requested mesh
  18949. * @param mesh Define the mesh to render
  18950. * @param useInstances Define whether or not the material is used with instances
  18951. * @returns true if ready, otherwise false
  18952. */
  18953. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18954. /**
  18955. * Binds the world matrix to the material
  18956. * @param world defines the world transformation matrix
  18957. */
  18958. bindOnlyWorldMatrix(world: Matrix): void;
  18959. /**
  18960. * Binds the material to the mesh
  18961. * @param world defines the world transformation matrix
  18962. * @param mesh defines the mesh to bind the material to
  18963. */
  18964. bind(world: Matrix, mesh?: Mesh): void;
  18965. /**
  18966. * Gets the active textures from the material
  18967. * @returns an array of textures
  18968. */
  18969. getActiveTextures(): BaseTexture[];
  18970. /**
  18971. * Specifies if the material uses a texture
  18972. * @param texture defines the texture to check against the material
  18973. * @returns a boolean specifying if the material uses the texture
  18974. */
  18975. hasTexture(texture: BaseTexture): boolean;
  18976. /**
  18977. * Makes a duplicate of the material, and gives it a new name
  18978. * @param name defines the new name for the duplicated material
  18979. * @returns the cloned material
  18980. */
  18981. clone(name: string): ShaderMaterial;
  18982. /**
  18983. * Disposes the material
  18984. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18985. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18986. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18987. */
  18988. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18989. /**
  18990. * Serializes this material in a JSON representation
  18991. * @returns the serialized material object
  18992. */
  18993. serialize(): any;
  18994. /**
  18995. * Creates a shader material from parsed shader material data
  18996. * @param source defines the JSON represnetation of the material
  18997. * @param scene defines the hosting scene
  18998. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18999. * @returns a new material
  19000. */
  19001. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19002. }
  19003. }
  19004. declare module BABYLON {
  19005. /** @hidden */
  19006. export var colorPixelShader: {
  19007. name: string;
  19008. shader: string;
  19009. };
  19010. }
  19011. declare module BABYLON {
  19012. /** @hidden */
  19013. export var colorVertexShader: {
  19014. name: string;
  19015. shader: string;
  19016. };
  19017. }
  19018. declare module BABYLON {
  19019. /**
  19020. * Line mesh
  19021. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19022. */
  19023. export class LinesMesh extends Mesh {
  19024. /**
  19025. * If vertex color should be applied to the mesh
  19026. */
  19027. readonly useVertexColor?: boolean | undefined;
  19028. /**
  19029. * If vertex alpha should be applied to the mesh
  19030. */
  19031. readonly useVertexAlpha?: boolean | undefined;
  19032. /**
  19033. * Color of the line (Default: White)
  19034. */
  19035. color: Color3;
  19036. /**
  19037. * Alpha of the line (Default: 1)
  19038. */
  19039. alpha: number;
  19040. /**
  19041. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19042. * This margin is expressed in world space coordinates, so its value may vary.
  19043. * Default value is 0.1
  19044. */
  19045. intersectionThreshold: number;
  19046. private _colorShader;
  19047. private color4;
  19048. /**
  19049. * Creates a new LinesMesh
  19050. * @param name defines the name
  19051. * @param scene defines the hosting scene
  19052. * @param parent defines the parent mesh if any
  19053. * @param source defines the optional source LinesMesh used to clone data from
  19054. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19055. * When false, achieved by calling a clone(), also passing False.
  19056. * This will make creation of children, recursive.
  19057. * @param useVertexColor defines if this LinesMesh supports vertex color
  19058. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19059. */
  19060. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19061. /**
  19062. * If vertex color should be applied to the mesh
  19063. */
  19064. useVertexColor?: boolean | undefined,
  19065. /**
  19066. * If vertex alpha should be applied to the mesh
  19067. */
  19068. useVertexAlpha?: boolean | undefined);
  19069. private _addClipPlaneDefine;
  19070. private _removeClipPlaneDefine;
  19071. isReady(): boolean;
  19072. /**
  19073. * Returns the string "LineMesh"
  19074. */
  19075. getClassName(): string;
  19076. /**
  19077. * @hidden
  19078. */
  19079. /**
  19080. * @hidden
  19081. */
  19082. material: Material;
  19083. /**
  19084. * @hidden
  19085. */
  19086. readonly checkCollisions: boolean;
  19087. /** @hidden */
  19088. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19089. /** @hidden */
  19090. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19091. /**
  19092. * Disposes of the line mesh
  19093. * @param doNotRecurse If children should be disposed
  19094. */
  19095. dispose(doNotRecurse?: boolean): void;
  19096. /**
  19097. * Returns a new LineMesh object cloned from the current one.
  19098. */
  19099. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19100. /**
  19101. * Creates a new InstancedLinesMesh object from the mesh model.
  19102. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19103. * @param name defines the name of the new instance
  19104. * @returns a new InstancedLinesMesh
  19105. */
  19106. createInstance(name: string): InstancedLinesMesh;
  19107. }
  19108. /**
  19109. * Creates an instance based on a source LinesMesh
  19110. */
  19111. export class InstancedLinesMesh extends InstancedMesh {
  19112. /**
  19113. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19114. * This margin is expressed in world space coordinates, so its value may vary.
  19115. * Initilized with the intersectionThreshold value of the source LinesMesh
  19116. */
  19117. intersectionThreshold: number;
  19118. constructor(name: string, source: LinesMesh);
  19119. /**
  19120. * Returns the string "InstancedLinesMesh".
  19121. */
  19122. getClassName(): string;
  19123. }
  19124. }
  19125. declare module BABYLON {
  19126. /** @hidden */
  19127. export var linePixelShader: {
  19128. name: string;
  19129. shader: string;
  19130. };
  19131. }
  19132. declare module BABYLON {
  19133. /** @hidden */
  19134. export var lineVertexShader: {
  19135. name: string;
  19136. shader: string;
  19137. };
  19138. }
  19139. declare module BABYLON {
  19140. interface AbstractMesh {
  19141. /**
  19142. * Gets the edgesRenderer associated with the mesh
  19143. */
  19144. edgesRenderer: Nullable<EdgesRenderer>;
  19145. }
  19146. interface LinesMesh {
  19147. /**
  19148. * Enables the edge rendering mode on the mesh.
  19149. * This mode makes the mesh edges visible
  19150. * @param epsilon defines the maximal distance between two angles to detect a face
  19151. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19152. * @returns the currentAbstractMesh
  19153. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19154. */
  19155. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19156. }
  19157. interface InstancedLinesMesh {
  19158. /**
  19159. * Enables the edge rendering mode on the mesh.
  19160. * This mode makes the mesh edges visible
  19161. * @param epsilon defines the maximal distance between two angles to detect a face
  19162. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19163. * @returns the current InstancedLinesMesh
  19164. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19165. */
  19166. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19167. }
  19168. /**
  19169. * Defines the minimum contract an Edges renderer should follow.
  19170. */
  19171. export interface IEdgesRenderer extends IDisposable {
  19172. /**
  19173. * Gets or sets a boolean indicating if the edgesRenderer is active
  19174. */
  19175. isEnabled: boolean;
  19176. /**
  19177. * Renders the edges of the attached mesh,
  19178. */
  19179. render(): void;
  19180. /**
  19181. * Checks wether or not the edges renderer is ready to render.
  19182. * @return true if ready, otherwise false.
  19183. */
  19184. isReady(): boolean;
  19185. }
  19186. /**
  19187. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19188. */
  19189. export class EdgesRenderer implements IEdgesRenderer {
  19190. /**
  19191. * Define the size of the edges with an orthographic camera
  19192. */
  19193. edgesWidthScalerForOrthographic: number;
  19194. /**
  19195. * Define the size of the edges with a perspective camera
  19196. */
  19197. edgesWidthScalerForPerspective: number;
  19198. protected _source: AbstractMesh;
  19199. protected _linesPositions: number[];
  19200. protected _linesNormals: number[];
  19201. protected _linesIndices: number[];
  19202. protected _epsilon: number;
  19203. protected _indicesCount: number;
  19204. protected _lineShader: ShaderMaterial;
  19205. protected _ib: DataBuffer;
  19206. protected _buffers: {
  19207. [key: string]: Nullable<VertexBuffer>;
  19208. };
  19209. protected _checkVerticesInsteadOfIndices: boolean;
  19210. private _meshRebuildObserver;
  19211. private _meshDisposeObserver;
  19212. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19213. isEnabled: boolean;
  19214. /**
  19215. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19216. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19217. * @param source Mesh used to create edges
  19218. * @param epsilon sum of angles in adjacency to check for edge
  19219. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19220. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19221. */
  19222. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19223. protected _prepareRessources(): void;
  19224. /** @hidden */
  19225. _rebuild(): void;
  19226. /**
  19227. * Releases the required resources for the edges renderer
  19228. */
  19229. dispose(): void;
  19230. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19231. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19232. /**
  19233. * Checks if the pair of p0 and p1 is en edge
  19234. * @param faceIndex
  19235. * @param edge
  19236. * @param faceNormals
  19237. * @param p0
  19238. * @param p1
  19239. * @private
  19240. */
  19241. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19242. /**
  19243. * push line into the position, normal and index buffer
  19244. * @protected
  19245. */
  19246. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19247. /**
  19248. * Generates lines edges from adjacencjes
  19249. * @private
  19250. */
  19251. _generateEdgesLines(): void;
  19252. /**
  19253. * Checks wether or not the edges renderer is ready to render.
  19254. * @return true if ready, otherwise false.
  19255. */
  19256. isReady(): boolean;
  19257. /**
  19258. * Renders the edges of the attached mesh,
  19259. */
  19260. render(): void;
  19261. }
  19262. /**
  19263. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19264. */
  19265. export class LineEdgesRenderer extends EdgesRenderer {
  19266. /**
  19267. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19268. * @param source LineMesh used to generate edges
  19269. * @param epsilon not important (specified angle for edge detection)
  19270. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19271. */
  19272. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19273. /**
  19274. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19275. */
  19276. _generateEdgesLines(): void;
  19277. }
  19278. }
  19279. declare module BABYLON {
  19280. /**
  19281. * This represents the object necessary to create a rendering group.
  19282. * This is exclusively used and created by the rendering manager.
  19283. * To modify the behavior, you use the available helpers in your scene or meshes.
  19284. * @hidden
  19285. */
  19286. export class RenderingGroup {
  19287. index: number;
  19288. private static _zeroVector;
  19289. private _scene;
  19290. private _opaqueSubMeshes;
  19291. private _transparentSubMeshes;
  19292. private _alphaTestSubMeshes;
  19293. private _depthOnlySubMeshes;
  19294. private _particleSystems;
  19295. private _spriteManagers;
  19296. private _opaqueSortCompareFn;
  19297. private _alphaTestSortCompareFn;
  19298. private _transparentSortCompareFn;
  19299. private _renderOpaque;
  19300. private _renderAlphaTest;
  19301. private _renderTransparent;
  19302. /** @hidden */
  19303. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19304. onBeforeTransparentRendering: () => void;
  19305. /**
  19306. * Set the opaque sort comparison function.
  19307. * If null the sub meshes will be render in the order they were created
  19308. */
  19309. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19310. /**
  19311. * Set the alpha test sort comparison function.
  19312. * If null the sub meshes will be render in the order they were created
  19313. */
  19314. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19315. /**
  19316. * Set the transparent sort comparison function.
  19317. * If null the sub meshes will be render in the order they were created
  19318. */
  19319. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19320. /**
  19321. * Creates a new rendering group.
  19322. * @param index The rendering group index
  19323. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19324. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19325. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19326. */
  19327. 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>);
  19328. /**
  19329. * Render all the sub meshes contained in the group.
  19330. * @param customRenderFunction Used to override the default render behaviour of the group.
  19331. * @returns true if rendered some submeshes.
  19332. */
  19333. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19334. /**
  19335. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19336. * @param subMeshes The submeshes to render
  19337. */
  19338. private renderOpaqueSorted;
  19339. /**
  19340. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19341. * @param subMeshes The submeshes to render
  19342. */
  19343. private renderAlphaTestSorted;
  19344. /**
  19345. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19346. * @param subMeshes The submeshes to render
  19347. */
  19348. private renderTransparentSorted;
  19349. /**
  19350. * Renders the submeshes in a specified order.
  19351. * @param subMeshes The submeshes to sort before render
  19352. * @param sortCompareFn The comparison function use to sort
  19353. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19354. * @param transparent Specifies to activate blending if true
  19355. */
  19356. private static renderSorted;
  19357. /**
  19358. * Renders the submeshes in the order they were dispatched (no sort applied).
  19359. * @param subMeshes The submeshes to render
  19360. */
  19361. private static renderUnsorted;
  19362. /**
  19363. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19364. * are rendered back to front if in the same alpha index.
  19365. *
  19366. * @param a The first submesh
  19367. * @param b The second submesh
  19368. * @returns The result of the comparison
  19369. */
  19370. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19371. /**
  19372. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19373. * are rendered back to front.
  19374. *
  19375. * @param a The first submesh
  19376. * @param b The second submesh
  19377. * @returns The result of the comparison
  19378. */
  19379. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19380. /**
  19381. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19382. * are rendered front to back (prevent overdraw).
  19383. *
  19384. * @param a The first submesh
  19385. * @param b The second submesh
  19386. * @returns The result of the comparison
  19387. */
  19388. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19389. /**
  19390. * Resets the different lists of submeshes to prepare a new frame.
  19391. */
  19392. prepare(): void;
  19393. dispose(): void;
  19394. /**
  19395. * Inserts the submesh in its correct queue depending on its material.
  19396. * @param subMesh The submesh to dispatch
  19397. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19398. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19399. */
  19400. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19401. dispatchSprites(spriteManager: ISpriteManager): void;
  19402. dispatchParticles(particleSystem: IParticleSystem): void;
  19403. private _renderParticles;
  19404. private _renderSprites;
  19405. }
  19406. }
  19407. declare module BABYLON {
  19408. /**
  19409. * Interface describing the different options available in the rendering manager
  19410. * regarding Auto Clear between groups.
  19411. */
  19412. export interface IRenderingManagerAutoClearSetup {
  19413. /**
  19414. * Defines whether or not autoclear is enable.
  19415. */
  19416. autoClear: boolean;
  19417. /**
  19418. * Defines whether or not to autoclear the depth buffer.
  19419. */
  19420. depth: boolean;
  19421. /**
  19422. * Defines whether or not to autoclear the stencil buffer.
  19423. */
  19424. stencil: boolean;
  19425. }
  19426. /**
  19427. * This class is used by the onRenderingGroupObservable
  19428. */
  19429. export class RenderingGroupInfo {
  19430. /**
  19431. * The Scene that being rendered
  19432. */
  19433. scene: Scene;
  19434. /**
  19435. * The camera currently used for the rendering pass
  19436. */
  19437. camera: Nullable<Camera>;
  19438. /**
  19439. * The ID of the renderingGroup being processed
  19440. */
  19441. renderingGroupId: number;
  19442. }
  19443. /**
  19444. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19445. * It is enable to manage the different groups as well as the different necessary sort functions.
  19446. * This should not be used directly aside of the few static configurations
  19447. */
  19448. export class RenderingManager {
  19449. /**
  19450. * The max id used for rendering groups (not included)
  19451. */
  19452. static MAX_RENDERINGGROUPS: number;
  19453. /**
  19454. * The min id used for rendering groups (included)
  19455. */
  19456. static MIN_RENDERINGGROUPS: number;
  19457. /**
  19458. * Used to globally prevent autoclearing scenes.
  19459. */
  19460. static AUTOCLEAR: boolean;
  19461. /**
  19462. * @hidden
  19463. */
  19464. _useSceneAutoClearSetup: boolean;
  19465. private _scene;
  19466. private _renderingGroups;
  19467. private _depthStencilBufferAlreadyCleaned;
  19468. private _autoClearDepthStencil;
  19469. private _customOpaqueSortCompareFn;
  19470. private _customAlphaTestSortCompareFn;
  19471. private _customTransparentSortCompareFn;
  19472. private _renderingGroupInfo;
  19473. /**
  19474. * Instantiates a new rendering group for a particular scene
  19475. * @param scene Defines the scene the groups belongs to
  19476. */
  19477. constructor(scene: Scene);
  19478. private _clearDepthStencilBuffer;
  19479. /**
  19480. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19481. * @hidden
  19482. */
  19483. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19484. /**
  19485. * Resets the different information of the group to prepare a new frame
  19486. * @hidden
  19487. */
  19488. reset(): void;
  19489. /**
  19490. * Dispose and release the group and its associated resources.
  19491. * @hidden
  19492. */
  19493. dispose(): void;
  19494. /**
  19495. * Clear the info related to rendering groups preventing retention points during dispose.
  19496. */
  19497. freeRenderingGroups(): void;
  19498. private _prepareRenderingGroup;
  19499. /**
  19500. * Add a sprite manager to the rendering manager in order to render it this frame.
  19501. * @param spriteManager Define the sprite manager to render
  19502. */
  19503. dispatchSprites(spriteManager: ISpriteManager): void;
  19504. /**
  19505. * Add a particle system to the rendering manager in order to render it this frame.
  19506. * @param particleSystem Define the particle system to render
  19507. */
  19508. dispatchParticles(particleSystem: IParticleSystem): void;
  19509. /**
  19510. * Add a submesh to the manager in order to render it this frame
  19511. * @param subMesh The submesh to dispatch
  19512. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19513. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19514. */
  19515. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19516. /**
  19517. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19518. * This allowed control for front to back rendering or reversly depending of the special needs.
  19519. *
  19520. * @param renderingGroupId The rendering group id corresponding to its index
  19521. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19522. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19523. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19524. */
  19525. 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;
  19526. /**
  19527. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19528. *
  19529. * @param renderingGroupId The rendering group id corresponding to its index
  19530. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19531. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19532. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19533. */
  19534. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19535. /**
  19536. * Gets the current auto clear configuration for one rendering group of the rendering
  19537. * manager.
  19538. * @param index the rendering group index to get the information for
  19539. * @returns The auto clear setup for the requested rendering group
  19540. */
  19541. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19542. }
  19543. }
  19544. declare module BABYLON {
  19545. /**
  19546. * This Helps creating a texture that will be created from a camera in your scene.
  19547. * It is basically a dynamic texture that could be used to create special effects for instance.
  19548. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19549. */
  19550. export class RenderTargetTexture extends Texture {
  19551. isCube: boolean;
  19552. /**
  19553. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19554. */
  19555. static readonly REFRESHRATE_RENDER_ONCE: number;
  19556. /**
  19557. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19558. */
  19559. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19560. /**
  19561. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19562. * the central point of your effect and can save a lot of performances.
  19563. */
  19564. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19565. /**
  19566. * Use this predicate to dynamically define the list of mesh you want to render.
  19567. * If set, the renderList property will be overwritten.
  19568. */
  19569. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19570. private _renderList;
  19571. /**
  19572. * Use this list to define the list of mesh you want to render.
  19573. */
  19574. renderList: Nullable<Array<AbstractMesh>>;
  19575. private _hookArray;
  19576. /**
  19577. * Define if particles should be rendered in your texture.
  19578. */
  19579. renderParticles: boolean;
  19580. /**
  19581. * Define if sprites should be rendered in your texture.
  19582. */
  19583. renderSprites: boolean;
  19584. /**
  19585. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19586. */
  19587. coordinatesMode: number;
  19588. /**
  19589. * Define the camera used to render the texture.
  19590. */
  19591. activeCamera: Nullable<Camera>;
  19592. /**
  19593. * Override the render function of the texture with your own one.
  19594. */
  19595. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19596. /**
  19597. * Define if camera post processes should be use while rendering the texture.
  19598. */
  19599. useCameraPostProcesses: boolean;
  19600. /**
  19601. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19602. */
  19603. ignoreCameraViewport: boolean;
  19604. private _postProcessManager;
  19605. private _postProcesses;
  19606. private _resizeObserver;
  19607. /**
  19608. * An event triggered when the texture is unbind.
  19609. */
  19610. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19611. /**
  19612. * An event triggered when the texture is unbind.
  19613. */
  19614. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19615. private _onAfterUnbindObserver;
  19616. /**
  19617. * Set a after unbind callback in the texture.
  19618. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19619. */
  19620. onAfterUnbind: () => void;
  19621. /**
  19622. * An event triggered before rendering the texture
  19623. */
  19624. onBeforeRenderObservable: Observable<number>;
  19625. private _onBeforeRenderObserver;
  19626. /**
  19627. * Set a before render callback in the texture.
  19628. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19629. */
  19630. onBeforeRender: (faceIndex: number) => void;
  19631. /**
  19632. * An event triggered after rendering the texture
  19633. */
  19634. onAfterRenderObservable: Observable<number>;
  19635. private _onAfterRenderObserver;
  19636. /**
  19637. * Set a after render callback in the texture.
  19638. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19639. */
  19640. onAfterRender: (faceIndex: number) => void;
  19641. /**
  19642. * An event triggered after the texture clear
  19643. */
  19644. onClearObservable: Observable<Engine>;
  19645. private _onClearObserver;
  19646. /**
  19647. * Set a clear callback in the texture.
  19648. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19649. */
  19650. onClear: (Engine: Engine) => void;
  19651. /**
  19652. * An event triggered when the texture is resized.
  19653. */
  19654. onResizeObservable: Observable<RenderTargetTexture>;
  19655. /**
  19656. * Define the clear color of the Render Target if it should be different from the scene.
  19657. */
  19658. clearColor: Color4;
  19659. protected _size: number | {
  19660. width: number;
  19661. height: number;
  19662. };
  19663. protected _initialSizeParameter: number | {
  19664. width: number;
  19665. height: number;
  19666. } | {
  19667. ratio: number;
  19668. };
  19669. protected _sizeRatio: Nullable<number>;
  19670. /** @hidden */
  19671. _generateMipMaps: boolean;
  19672. protected _renderingManager: RenderingManager;
  19673. /** @hidden */
  19674. _waitingRenderList: string[];
  19675. protected _doNotChangeAspectRatio: boolean;
  19676. protected _currentRefreshId: number;
  19677. protected _refreshRate: number;
  19678. protected _textureMatrix: Matrix;
  19679. protected _samples: number;
  19680. protected _renderTargetOptions: RenderTargetCreationOptions;
  19681. /**
  19682. * Gets render target creation options that were used.
  19683. */
  19684. readonly renderTargetOptions: RenderTargetCreationOptions;
  19685. protected _engine: Engine;
  19686. protected _onRatioRescale(): void;
  19687. /**
  19688. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19689. * It must define where the camera used to render the texture is set
  19690. */
  19691. boundingBoxPosition: Vector3;
  19692. private _boundingBoxSize;
  19693. /**
  19694. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19695. * When defined, the cubemap will switch to local mode
  19696. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19697. * @example https://www.babylonjs-playground.com/#RNASML
  19698. */
  19699. boundingBoxSize: Vector3;
  19700. /**
  19701. * In case the RTT has been created with a depth texture, get the associated
  19702. * depth texture.
  19703. * Otherwise, return null.
  19704. */
  19705. depthStencilTexture: Nullable<InternalTexture>;
  19706. /**
  19707. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19708. * or used a shadow, depth texture...
  19709. * @param name The friendly name of the texture
  19710. * @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)
  19711. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19712. * @param generateMipMaps True if mip maps need to be generated after render.
  19713. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19714. * @param type The type of the buffer in the RTT (int, half float, float...)
  19715. * @param isCube True if a cube texture needs to be created
  19716. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19717. * @param generateDepthBuffer True to generate a depth buffer
  19718. * @param generateStencilBuffer True to generate a stencil buffer
  19719. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19720. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19721. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19722. */
  19723. constructor(name: string, size: number | {
  19724. width: number;
  19725. height: number;
  19726. } | {
  19727. ratio: number;
  19728. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19729. /**
  19730. * Creates a depth stencil texture.
  19731. * This is only available in WebGL 2 or with the depth texture extension available.
  19732. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19733. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19734. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19735. */
  19736. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19737. private _processSizeParameter;
  19738. /**
  19739. * Define the number of samples to use in case of MSAA.
  19740. * It defaults to one meaning no MSAA has been enabled.
  19741. */
  19742. samples: number;
  19743. /**
  19744. * Resets the refresh counter of the texture and start bak from scratch.
  19745. * Could be useful to regenerate the texture if it is setup to render only once.
  19746. */
  19747. resetRefreshCounter(): void;
  19748. /**
  19749. * Define the refresh rate of the texture or the rendering frequency.
  19750. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19751. */
  19752. refreshRate: number;
  19753. /**
  19754. * Adds a post process to the render target rendering passes.
  19755. * @param postProcess define the post process to add
  19756. */
  19757. addPostProcess(postProcess: PostProcess): void;
  19758. /**
  19759. * Clear all the post processes attached to the render target
  19760. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19761. */
  19762. clearPostProcesses(dispose?: boolean): void;
  19763. /**
  19764. * Remove one of the post process from the list of attached post processes to the texture
  19765. * @param postProcess define the post process to remove from the list
  19766. */
  19767. removePostProcess(postProcess: PostProcess): void;
  19768. /** @hidden */
  19769. _shouldRender(): boolean;
  19770. /**
  19771. * Gets the actual render size of the texture.
  19772. * @returns the width of the render size
  19773. */
  19774. getRenderSize(): number;
  19775. /**
  19776. * Gets the actual render width of the texture.
  19777. * @returns the width of the render size
  19778. */
  19779. getRenderWidth(): number;
  19780. /**
  19781. * Gets the actual render height of the texture.
  19782. * @returns the height of the render size
  19783. */
  19784. getRenderHeight(): number;
  19785. /**
  19786. * Get if the texture can be rescaled or not.
  19787. */
  19788. readonly canRescale: boolean;
  19789. /**
  19790. * Resize the texture using a ratio.
  19791. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19792. */
  19793. scale(ratio: number): void;
  19794. /**
  19795. * Get the texture reflection matrix used to rotate/transform the reflection.
  19796. * @returns the reflection matrix
  19797. */
  19798. getReflectionTextureMatrix(): Matrix;
  19799. /**
  19800. * Resize the texture to a new desired size.
  19801. * Be carrefull as it will recreate all the data in the new texture.
  19802. * @param size Define the new size. It can be:
  19803. * - a number for squared texture,
  19804. * - an object containing { width: number, height: number }
  19805. * - or an object containing a ratio { ratio: number }
  19806. */
  19807. resize(size: number | {
  19808. width: number;
  19809. height: number;
  19810. } | {
  19811. ratio: number;
  19812. }): void;
  19813. /**
  19814. * Renders all the objects from the render list into the texture.
  19815. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  19816. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  19817. */
  19818. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  19819. private _bestReflectionRenderTargetDimension;
  19820. /**
  19821. * @hidden
  19822. * @param faceIndex face index to bind to if this is a cubetexture
  19823. */
  19824. _bindFrameBuffer(faceIndex?: number): void;
  19825. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19826. private renderToTarget;
  19827. /**
  19828. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19829. * This allowed control for front to back rendering or reversly depending of the special needs.
  19830. *
  19831. * @param renderingGroupId The rendering group id corresponding to its index
  19832. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19833. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19834. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19835. */
  19836. 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;
  19837. /**
  19838. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19839. *
  19840. * @param renderingGroupId The rendering group id corresponding to its index
  19841. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19842. */
  19843. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19844. /**
  19845. * Clones the texture.
  19846. * @returns the cloned texture
  19847. */
  19848. clone(): RenderTargetTexture;
  19849. /**
  19850. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19851. * @returns The JSON representation of the texture
  19852. */
  19853. serialize(): any;
  19854. /**
  19855. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  19856. */
  19857. disposeFramebufferObjects(): void;
  19858. /**
  19859. * Dispose the texture and release its associated resources.
  19860. */
  19861. dispose(): void;
  19862. /** @hidden */
  19863. _rebuild(): void;
  19864. /**
  19865. * Clear the info related to rendering groups preventing retention point in material dispose.
  19866. */
  19867. freeRenderingGroups(): void;
  19868. /**
  19869. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19870. * @returns the view count
  19871. */
  19872. getViewCount(): number;
  19873. }
  19874. }
  19875. declare module BABYLON {
  19876. /**
  19877. * Base class for the main features of a material in Babylon.js
  19878. */
  19879. export class Material implements IAnimatable {
  19880. /**
  19881. * Returns the triangle fill mode
  19882. */
  19883. static readonly TriangleFillMode: number;
  19884. /**
  19885. * Returns the wireframe mode
  19886. */
  19887. static readonly WireFrameFillMode: number;
  19888. /**
  19889. * Returns the point fill mode
  19890. */
  19891. static readonly PointFillMode: number;
  19892. /**
  19893. * Returns the point list draw mode
  19894. */
  19895. static readonly PointListDrawMode: number;
  19896. /**
  19897. * Returns the line list draw mode
  19898. */
  19899. static readonly LineListDrawMode: number;
  19900. /**
  19901. * Returns the line loop draw mode
  19902. */
  19903. static readonly LineLoopDrawMode: number;
  19904. /**
  19905. * Returns the line strip draw mode
  19906. */
  19907. static readonly LineStripDrawMode: number;
  19908. /**
  19909. * Returns the triangle strip draw mode
  19910. */
  19911. static readonly TriangleStripDrawMode: number;
  19912. /**
  19913. * Returns the triangle fan draw mode
  19914. */
  19915. static readonly TriangleFanDrawMode: number;
  19916. /**
  19917. * Stores the clock-wise side orientation
  19918. */
  19919. static readonly ClockWiseSideOrientation: number;
  19920. /**
  19921. * Stores the counter clock-wise side orientation
  19922. */
  19923. static readonly CounterClockWiseSideOrientation: number;
  19924. /**
  19925. * The dirty texture flag value
  19926. */
  19927. static readonly TextureDirtyFlag: number;
  19928. /**
  19929. * The dirty light flag value
  19930. */
  19931. static readonly LightDirtyFlag: number;
  19932. /**
  19933. * The dirty fresnel flag value
  19934. */
  19935. static readonly FresnelDirtyFlag: number;
  19936. /**
  19937. * The dirty attribute flag value
  19938. */
  19939. static readonly AttributesDirtyFlag: number;
  19940. /**
  19941. * The dirty misc flag value
  19942. */
  19943. static readonly MiscDirtyFlag: number;
  19944. /**
  19945. * The all dirty flag value
  19946. */
  19947. static readonly AllDirtyFlag: number;
  19948. /**
  19949. * The ID of the material
  19950. */
  19951. id: string;
  19952. /**
  19953. * Gets or sets the unique id of the material
  19954. */
  19955. uniqueId: number;
  19956. /**
  19957. * The name of the material
  19958. */
  19959. name: string;
  19960. /**
  19961. * Gets or sets user defined metadata
  19962. */
  19963. metadata: any;
  19964. /**
  19965. * For internal use only. Please do not use.
  19966. */
  19967. reservedDataStore: any;
  19968. /**
  19969. * Specifies if the ready state should be checked on each call
  19970. */
  19971. checkReadyOnEveryCall: boolean;
  19972. /**
  19973. * Specifies if the ready state should be checked once
  19974. */
  19975. checkReadyOnlyOnce: boolean;
  19976. /**
  19977. * The state of the material
  19978. */
  19979. state: string;
  19980. /**
  19981. * The alpha value of the material
  19982. */
  19983. protected _alpha: number;
  19984. /**
  19985. * List of inspectable custom properties (used by the Inspector)
  19986. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19987. */
  19988. inspectableCustomProperties: IInspectable[];
  19989. /**
  19990. * Sets the alpha value of the material
  19991. */
  19992. /**
  19993. * Gets the alpha value of the material
  19994. */
  19995. alpha: number;
  19996. /**
  19997. * Specifies if back face culling is enabled
  19998. */
  19999. protected _backFaceCulling: boolean;
  20000. /**
  20001. * Sets the back-face culling state
  20002. */
  20003. /**
  20004. * Gets the back-face culling state
  20005. */
  20006. backFaceCulling: boolean;
  20007. /**
  20008. * Stores the value for side orientation
  20009. */
  20010. sideOrientation: number;
  20011. /**
  20012. * Callback triggered when the material is compiled
  20013. */
  20014. onCompiled: Nullable<(effect: Effect) => void>;
  20015. /**
  20016. * Callback triggered when an error occurs
  20017. */
  20018. onError: Nullable<(effect: Effect, errors: string) => void>;
  20019. /**
  20020. * Callback triggered to get the render target textures
  20021. */
  20022. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20023. /**
  20024. * Gets a boolean indicating that current material needs to register RTT
  20025. */
  20026. readonly hasRenderTargetTextures: boolean;
  20027. /**
  20028. * Specifies if the material should be serialized
  20029. */
  20030. doNotSerialize: boolean;
  20031. /**
  20032. * @hidden
  20033. */
  20034. _storeEffectOnSubMeshes: boolean;
  20035. /**
  20036. * Stores the animations for the material
  20037. */
  20038. animations: Nullable<Array<Animation>>;
  20039. /**
  20040. * An event triggered when the material is disposed
  20041. */
  20042. onDisposeObservable: Observable<Material>;
  20043. /**
  20044. * An observer which watches for dispose events
  20045. */
  20046. private _onDisposeObserver;
  20047. private _onUnBindObservable;
  20048. /**
  20049. * Called during a dispose event
  20050. */
  20051. onDispose: () => void;
  20052. private _onBindObservable;
  20053. /**
  20054. * An event triggered when the material is bound
  20055. */
  20056. readonly onBindObservable: Observable<AbstractMesh>;
  20057. /**
  20058. * An observer which watches for bind events
  20059. */
  20060. private _onBindObserver;
  20061. /**
  20062. * Called during a bind event
  20063. */
  20064. onBind: (Mesh: AbstractMesh) => void;
  20065. /**
  20066. * An event triggered when the material is unbound
  20067. */
  20068. readonly onUnBindObservable: Observable<Material>;
  20069. /**
  20070. * Stores the value of the alpha mode
  20071. */
  20072. private _alphaMode;
  20073. /**
  20074. * Sets the value of the alpha mode.
  20075. *
  20076. * | Value | Type | Description |
  20077. * | --- | --- | --- |
  20078. * | 0 | ALPHA_DISABLE | |
  20079. * | 1 | ALPHA_ADD | |
  20080. * | 2 | ALPHA_COMBINE | |
  20081. * | 3 | ALPHA_SUBTRACT | |
  20082. * | 4 | ALPHA_MULTIPLY | |
  20083. * | 5 | ALPHA_MAXIMIZED | |
  20084. * | 6 | ALPHA_ONEONE | |
  20085. * | 7 | ALPHA_PREMULTIPLIED | |
  20086. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20087. * | 9 | ALPHA_INTERPOLATE | |
  20088. * | 10 | ALPHA_SCREENMODE | |
  20089. *
  20090. */
  20091. /**
  20092. * Gets the value of the alpha mode
  20093. */
  20094. alphaMode: number;
  20095. /**
  20096. * Stores the state of the need depth pre-pass value
  20097. */
  20098. private _needDepthPrePass;
  20099. /**
  20100. * Sets the need depth pre-pass value
  20101. */
  20102. /**
  20103. * Gets the depth pre-pass value
  20104. */
  20105. needDepthPrePass: boolean;
  20106. /**
  20107. * Specifies if depth writing should be disabled
  20108. */
  20109. disableDepthWrite: boolean;
  20110. /**
  20111. * Specifies if depth writing should be forced
  20112. */
  20113. forceDepthWrite: boolean;
  20114. /**
  20115. * Specifies if there should be a separate pass for culling
  20116. */
  20117. separateCullingPass: boolean;
  20118. /**
  20119. * Stores the state specifing if fog should be enabled
  20120. */
  20121. private _fogEnabled;
  20122. /**
  20123. * Sets the state for enabling fog
  20124. */
  20125. /**
  20126. * Gets the value of the fog enabled state
  20127. */
  20128. fogEnabled: boolean;
  20129. /**
  20130. * Stores the size of points
  20131. */
  20132. pointSize: number;
  20133. /**
  20134. * Stores the z offset value
  20135. */
  20136. zOffset: number;
  20137. /**
  20138. * Gets a value specifying if wireframe mode is enabled
  20139. */
  20140. /**
  20141. * Sets the state of wireframe mode
  20142. */
  20143. wireframe: boolean;
  20144. /**
  20145. * Gets the value specifying if point clouds are enabled
  20146. */
  20147. /**
  20148. * Sets the state of point cloud mode
  20149. */
  20150. pointsCloud: boolean;
  20151. /**
  20152. * Gets the material fill mode
  20153. */
  20154. /**
  20155. * Sets the material fill mode
  20156. */
  20157. fillMode: number;
  20158. /**
  20159. * @hidden
  20160. * Stores the effects for the material
  20161. */
  20162. _effect: Nullable<Effect>;
  20163. /**
  20164. * @hidden
  20165. * Specifies if the material was previously ready
  20166. */
  20167. _wasPreviouslyReady: boolean;
  20168. /**
  20169. * Specifies if uniform buffers should be used
  20170. */
  20171. private _useUBO;
  20172. /**
  20173. * Stores a reference to the scene
  20174. */
  20175. private _scene;
  20176. /**
  20177. * Stores the fill mode state
  20178. */
  20179. private _fillMode;
  20180. /**
  20181. * Specifies if the depth write state should be cached
  20182. */
  20183. private _cachedDepthWriteState;
  20184. /**
  20185. * Stores the uniform buffer
  20186. */
  20187. protected _uniformBuffer: UniformBuffer;
  20188. /** @hidden */
  20189. _indexInSceneMaterialArray: number;
  20190. /** @hidden */
  20191. meshMap: Nullable<{
  20192. [id: string]: AbstractMesh | undefined;
  20193. }>;
  20194. /**
  20195. * Creates a material instance
  20196. * @param name defines the name of the material
  20197. * @param scene defines the scene to reference
  20198. * @param doNotAdd specifies if the material should be added to the scene
  20199. */
  20200. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20201. /**
  20202. * Returns a string representation of the current material
  20203. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20204. * @returns a string with material information
  20205. */
  20206. toString(fullDetails?: boolean): string;
  20207. /**
  20208. * Gets the class name of the material
  20209. * @returns a string with the class name of the material
  20210. */
  20211. getClassName(): string;
  20212. /**
  20213. * Specifies if updates for the material been locked
  20214. */
  20215. readonly isFrozen: boolean;
  20216. /**
  20217. * Locks updates for the material
  20218. */
  20219. freeze(): void;
  20220. /**
  20221. * Unlocks updates for the material
  20222. */
  20223. unfreeze(): void;
  20224. /**
  20225. * Specifies if the material is ready to be used
  20226. * @param mesh defines the mesh to check
  20227. * @param useInstances specifies if instances should be used
  20228. * @returns a boolean indicating if the material is ready to be used
  20229. */
  20230. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20231. /**
  20232. * Specifies that the submesh is ready to be used
  20233. * @param mesh defines the mesh to check
  20234. * @param subMesh defines which submesh to check
  20235. * @param useInstances specifies that instances should be used
  20236. * @returns a boolean indicating that the submesh is ready or not
  20237. */
  20238. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20239. /**
  20240. * Returns the material effect
  20241. * @returns the effect associated with the material
  20242. */
  20243. getEffect(): Nullable<Effect>;
  20244. /**
  20245. * Returns the current scene
  20246. * @returns a Scene
  20247. */
  20248. getScene(): Scene;
  20249. /**
  20250. * Specifies if the material will require alpha blending
  20251. * @returns a boolean specifying if alpha blending is needed
  20252. */
  20253. needAlphaBlending(): boolean;
  20254. /**
  20255. * Specifies if the mesh will require alpha blending
  20256. * @param mesh defines the mesh to check
  20257. * @returns a boolean specifying if alpha blending is needed for the mesh
  20258. */
  20259. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20260. /**
  20261. * Specifies if this material should be rendered in alpha test mode
  20262. * @returns a boolean specifying if an alpha test is needed.
  20263. */
  20264. needAlphaTesting(): boolean;
  20265. /**
  20266. * Gets the texture used for the alpha test
  20267. * @returns the texture to use for alpha testing
  20268. */
  20269. getAlphaTestTexture(): Nullable<BaseTexture>;
  20270. /**
  20271. * Marks the material to indicate that it needs to be re-calculated
  20272. */
  20273. markDirty(): void;
  20274. /** @hidden */
  20275. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20276. /**
  20277. * Binds the material to the mesh
  20278. * @param world defines the world transformation matrix
  20279. * @param mesh defines the mesh to bind the material to
  20280. */
  20281. bind(world: Matrix, mesh?: Mesh): void;
  20282. /**
  20283. * Binds the submesh to the material
  20284. * @param world defines the world transformation matrix
  20285. * @param mesh defines the mesh containing the submesh
  20286. * @param subMesh defines the submesh to bind the material to
  20287. */
  20288. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20289. /**
  20290. * Binds the world matrix to the material
  20291. * @param world defines the world transformation matrix
  20292. */
  20293. bindOnlyWorldMatrix(world: Matrix): void;
  20294. /**
  20295. * Binds the scene's uniform buffer to the effect.
  20296. * @param effect defines the effect to bind to the scene uniform buffer
  20297. * @param sceneUbo defines the uniform buffer storing scene data
  20298. */
  20299. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20300. /**
  20301. * Binds the view matrix to the effect
  20302. * @param effect defines the effect to bind the view matrix to
  20303. */
  20304. bindView(effect: Effect): void;
  20305. /**
  20306. * Binds the view projection matrix to the effect
  20307. * @param effect defines the effect to bind the view projection matrix to
  20308. */
  20309. bindViewProjection(effect: Effect): void;
  20310. /**
  20311. * Specifies if material alpha testing should be turned on for the mesh
  20312. * @param mesh defines the mesh to check
  20313. */
  20314. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20315. /**
  20316. * Processes to execute after binding the material to a mesh
  20317. * @param mesh defines the rendered mesh
  20318. */
  20319. protected _afterBind(mesh?: Mesh): void;
  20320. /**
  20321. * Unbinds the material from the mesh
  20322. */
  20323. unbind(): void;
  20324. /**
  20325. * Gets the active textures from the material
  20326. * @returns an array of textures
  20327. */
  20328. getActiveTextures(): BaseTexture[];
  20329. /**
  20330. * Specifies if the material uses a texture
  20331. * @param texture defines the texture to check against the material
  20332. * @returns a boolean specifying if the material uses the texture
  20333. */
  20334. hasTexture(texture: BaseTexture): boolean;
  20335. /**
  20336. * Makes a duplicate of the material, and gives it a new name
  20337. * @param name defines the new name for the duplicated material
  20338. * @returns the cloned material
  20339. */
  20340. clone(name: string): Nullable<Material>;
  20341. /**
  20342. * Gets the meshes bound to the material
  20343. * @returns an array of meshes bound to the material
  20344. */
  20345. getBindedMeshes(): AbstractMesh[];
  20346. /**
  20347. * Force shader compilation
  20348. * @param mesh defines the mesh associated with this material
  20349. * @param onCompiled defines a function to execute once the material is compiled
  20350. * @param options defines the options to configure the compilation
  20351. */
  20352. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20353. clipPlane: boolean;
  20354. }>): void;
  20355. /**
  20356. * Force shader compilation
  20357. * @param mesh defines the mesh that will use this material
  20358. * @param options defines additional options for compiling the shaders
  20359. * @returns a promise that resolves when the compilation completes
  20360. */
  20361. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20362. clipPlane: boolean;
  20363. }>): Promise<void>;
  20364. private static readonly _AllDirtyCallBack;
  20365. private static readonly _ImageProcessingDirtyCallBack;
  20366. private static readonly _TextureDirtyCallBack;
  20367. private static readonly _FresnelDirtyCallBack;
  20368. private static readonly _MiscDirtyCallBack;
  20369. private static readonly _LightsDirtyCallBack;
  20370. private static readonly _AttributeDirtyCallBack;
  20371. private static _FresnelAndMiscDirtyCallBack;
  20372. private static _TextureAndMiscDirtyCallBack;
  20373. private static readonly _DirtyCallbackArray;
  20374. private static readonly _RunDirtyCallBacks;
  20375. /**
  20376. * Marks a define in the material to indicate that it needs to be re-computed
  20377. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20378. */
  20379. markAsDirty(flag: number): void;
  20380. /**
  20381. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20382. * @param func defines a function which checks material defines against the submeshes
  20383. */
  20384. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20385. /**
  20386. * Indicates that we need to re-calculated for all submeshes
  20387. */
  20388. protected _markAllSubMeshesAsAllDirty(): void;
  20389. /**
  20390. * Indicates that image processing needs to be re-calculated for all submeshes
  20391. */
  20392. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20393. /**
  20394. * Indicates that textures need to be re-calculated for all submeshes
  20395. */
  20396. protected _markAllSubMeshesAsTexturesDirty(): void;
  20397. /**
  20398. * Indicates that fresnel needs to be re-calculated for all submeshes
  20399. */
  20400. protected _markAllSubMeshesAsFresnelDirty(): void;
  20401. /**
  20402. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20403. */
  20404. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20405. /**
  20406. * Indicates that lights need to be re-calculated for all submeshes
  20407. */
  20408. protected _markAllSubMeshesAsLightsDirty(): void;
  20409. /**
  20410. * Indicates that attributes need to be re-calculated for all submeshes
  20411. */
  20412. protected _markAllSubMeshesAsAttributesDirty(): void;
  20413. /**
  20414. * Indicates that misc needs to be re-calculated for all submeshes
  20415. */
  20416. protected _markAllSubMeshesAsMiscDirty(): void;
  20417. /**
  20418. * Indicates that textures and misc need to be re-calculated for all submeshes
  20419. */
  20420. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20421. /**
  20422. * Disposes the material
  20423. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20424. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20425. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20426. */
  20427. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20428. /** @hidden */
  20429. private releaseVertexArrayObject;
  20430. /**
  20431. * Serializes this material
  20432. * @returns the serialized material object
  20433. */
  20434. serialize(): any;
  20435. /**
  20436. * Creates a material from parsed material data
  20437. * @param parsedMaterial defines parsed material data
  20438. * @param scene defines the hosting scene
  20439. * @param rootUrl defines the root URL to use to load textures
  20440. * @returns a new material
  20441. */
  20442. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20443. }
  20444. }
  20445. declare module BABYLON {
  20446. /**
  20447. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20448. * separate meshes. This can be use to improve performances.
  20449. * @see http://doc.babylonjs.com/how_to/multi_materials
  20450. */
  20451. export class MultiMaterial extends Material {
  20452. private _subMaterials;
  20453. /**
  20454. * Gets or Sets the list of Materials used within the multi material.
  20455. * They need to be ordered according to the submeshes order in the associated mesh
  20456. */
  20457. subMaterials: Nullable<Material>[];
  20458. /**
  20459. * Function used to align with Node.getChildren()
  20460. * @returns the list of Materials used within the multi material
  20461. */
  20462. getChildren(): Nullable<Material>[];
  20463. /**
  20464. * Instantiates a new Multi Material
  20465. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20466. * separate meshes. This can be use to improve performances.
  20467. * @see http://doc.babylonjs.com/how_to/multi_materials
  20468. * @param name Define the name in the scene
  20469. * @param scene Define the scene the material belongs to
  20470. */
  20471. constructor(name: string, scene: Scene);
  20472. private _hookArray;
  20473. /**
  20474. * Get one of the submaterial by its index in the submaterials array
  20475. * @param index The index to look the sub material at
  20476. * @returns The Material if the index has been defined
  20477. */
  20478. getSubMaterial(index: number): Nullable<Material>;
  20479. /**
  20480. * Get the list of active textures for the whole sub materials list.
  20481. * @returns All the textures that will be used during the rendering
  20482. */
  20483. getActiveTextures(): BaseTexture[];
  20484. /**
  20485. * Gets the current class name of the material e.g. "MultiMaterial"
  20486. * Mainly use in serialization.
  20487. * @returns the class name
  20488. */
  20489. getClassName(): string;
  20490. /**
  20491. * Checks if the material is ready to render the requested sub mesh
  20492. * @param mesh Define the mesh the submesh belongs to
  20493. * @param subMesh Define the sub mesh to look readyness for
  20494. * @param useInstances Define whether or not the material is used with instances
  20495. * @returns true if ready, otherwise false
  20496. */
  20497. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20498. /**
  20499. * Clones the current material and its related sub materials
  20500. * @param name Define the name of the newly cloned material
  20501. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20502. * @returns the cloned material
  20503. */
  20504. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20505. /**
  20506. * Serializes the materials into a JSON representation.
  20507. * @returns the JSON representation
  20508. */
  20509. serialize(): any;
  20510. /**
  20511. * Dispose the material and release its associated resources
  20512. * @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)
  20513. * @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)
  20514. * @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)
  20515. */
  20516. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20517. /**
  20518. * Creates a MultiMaterial from parsed MultiMaterial data.
  20519. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20520. * @param scene defines the hosting scene
  20521. * @returns a new MultiMaterial
  20522. */
  20523. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20524. }
  20525. }
  20526. declare module BABYLON {
  20527. /**
  20528. * Base class for submeshes
  20529. */
  20530. export class BaseSubMesh {
  20531. /** @hidden */
  20532. _materialDefines: Nullable<MaterialDefines>;
  20533. /** @hidden */
  20534. _materialEffect: Nullable<Effect>;
  20535. /**
  20536. * Gets associated effect
  20537. */
  20538. readonly effect: Nullable<Effect>;
  20539. /**
  20540. * Sets associated effect (effect used to render this submesh)
  20541. * @param effect defines the effect to associate with
  20542. * @param defines defines the set of defines used to compile this effect
  20543. */
  20544. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20545. }
  20546. /**
  20547. * Defines a subdivision inside a mesh
  20548. */
  20549. export class SubMesh extends BaseSubMesh implements ICullable {
  20550. /** the material index to use */
  20551. materialIndex: number;
  20552. /** vertex index start */
  20553. verticesStart: number;
  20554. /** vertices count */
  20555. verticesCount: number;
  20556. /** index start */
  20557. indexStart: number;
  20558. /** indices count */
  20559. indexCount: number;
  20560. /** @hidden */
  20561. _linesIndexCount: number;
  20562. private _mesh;
  20563. private _renderingMesh;
  20564. private _boundingInfo;
  20565. private _linesIndexBuffer;
  20566. /** @hidden */
  20567. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20568. /** @hidden */
  20569. _trianglePlanes: Plane[];
  20570. /** @hidden */
  20571. _lastColliderTransformMatrix: Nullable<Matrix>;
  20572. /** @hidden */
  20573. _renderId: number;
  20574. /** @hidden */
  20575. _alphaIndex: number;
  20576. /** @hidden */
  20577. _distanceToCamera: number;
  20578. /** @hidden */
  20579. _id: number;
  20580. private _currentMaterial;
  20581. /**
  20582. * Add a new submesh to a mesh
  20583. * @param materialIndex defines the material index to use
  20584. * @param verticesStart defines vertex index start
  20585. * @param verticesCount defines vertices count
  20586. * @param indexStart defines index start
  20587. * @param indexCount defines indices count
  20588. * @param mesh defines the parent mesh
  20589. * @param renderingMesh defines an optional rendering mesh
  20590. * @param createBoundingBox defines if bounding box should be created for this submesh
  20591. * @returns the new submesh
  20592. */
  20593. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20594. /**
  20595. * Creates a new submesh
  20596. * @param materialIndex defines the material index to use
  20597. * @param verticesStart defines vertex index start
  20598. * @param verticesCount defines vertices count
  20599. * @param indexStart defines index start
  20600. * @param indexCount defines indices count
  20601. * @param mesh defines the parent mesh
  20602. * @param renderingMesh defines an optional rendering mesh
  20603. * @param createBoundingBox defines if bounding box should be created for this submesh
  20604. */
  20605. constructor(
  20606. /** the material index to use */
  20607. materialIndex: number,
  20608. /** vertex index start */
  20609. verticesStart: number,
  20610. /** vertices count */
  20611. verticesCount: number,
  20612. /** index start */
  20613. indexStart: number,
  20614. /** indices count */
  20615. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20616. /**
  20617. * Returns true if this submesh covers the entire parent mesh
  20618. * @ignorenaming
  20619. */
  20620. readonly IsGlobal: boolean;
  20621. /**
  20622. * Returns the submesh BoudingInfo object
  20623. * @returns current bounding info (or mesh's one if the submesh is global)
  20624. */
  20625. getBoundingInfo(): BoundingInfo;
  20626. /**
  20627. * Sets the submesh BoundingInfo
  20628. * @param boundingInfo defines the new bounding info to use
  20629. * @returns the SubMesh
  20630. */
  20631. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20632. /**
  20633. * Returns the mesh of the current submesh
  20634. * @return the parent mesh
  20635. */
  20636. getMesh(): AbstractMesh;
  20637. /**
  20638. * Returns the rendering mesh of the submesh
  20639. * @returns the rendering mesh (could be different from parent mesh)
  20640. */
  20641. getRenderingMesh(): Mesh;
  20642. /**
  20643. * Returns the submesh material
  20644. * @returns null or the current material
  20645. */
  20646. getMaterial(): Nullable<Material>;
  20647. /**
  20648. * Sets a new updated BoundingInfo object to the submesh
  20649. * @param data defines an optional position array to use to determine the bounding info
  20650. * @returns the SubMesh
  20651. */
  20652. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20653. /** @hidden */
  20654. _checkCollision(collider: Collider): boolean;
  20655. /**
  20656. * Updates the submesh BoundingInfo
  20657. * @param world defines the world matrix to use to update the bounding info
  20658. * @returns the submesh
  20659. */
  20660. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20661. /**
  20662. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20663. * @param frustumPlanes defines the frustum planes
  20664. * @returns true if the submesh is intersecting with the frustum
  20665. */
  20666. isInFrustum(frustumPlanes: Plane[]): boolean;
  20667. /**
  20668. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20669. * @param frustumPlanes defines the frustum planes
  20670. * @returns true if the submesh is inside the frustum
  20671. */
  20672. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20673. /**
  20674. * Renders the submesh
  20675. * @param enableAlphaMode defines if alpha needs to be used
  20676. * @returns the submesh
  20677. */
  20678. render(enableAlphaMode: boolean): SubMesh;
  20679. /**
  20680. * @hidden
  20681. */
  20682. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20683. /**
  20684. * Checks if the submesh intersects with a ray
  20685. * @param ray defines the ray to test
  20686. * @returns true is the passed ray intersects the submesh bounding box
  20687. */
  20688. canIntersects(ray: Ray): boolean;
  20689. /**
  20690. * Intersects current submesh with a ray
  20691. * @param ray defines the ray to test
  20692. * @param positions defines mesh's positions array
  20693. * @param indices defines mesh's indices array
  20694. * @param fastCheck defines if only bounding info should be used
  20695. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20696. * @returns intersection info or null if no intersection
  20697. */
  20698. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20699. /** @hidden */
  20700. private _intersectLines;
  20701. /** @hidden */
  20702. private _intersectUnIndexedLines;
  20703. /** @hidden */
  20704. private _intersectTriangles;
  20705. /** @hidden */
  20706. private _intersectUnIndexedTriangles;
  20707. /** @hidden */
  20708. _rebuild(): void;
  20709. /**
  20710. * Creates a new submesh from the passed mesh
  20711. * @param newMesh defines the new hosting mesh
  20712. * @param newRenderingMesh defines an optional rendering mesh
  20713. * @returns the new submesh
  20714. */
  20715. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20716. /**
  20717. * Release associated resources
  20718. */
  20719. dispose(): void;
  20720. /**
  20721. * Gets the class name
  20722. * @returns the string "SubMesh".
  20723. */
  20724. getClassName(): string;
  20725. /**
  20726. * Creates a new submesh from indices data
  20727. * @param materialIndex the index of the main mesh material
  20728. * @param startIndex the index where to start the copy in the mesh indices array
  20729. * @param indexCount the number of indices to copy then from the startIndex
  20730. * @param mesh the main mesh to create the submesh from
  20731. * @param renderingMesh the optional rendering mesh
  20732. * @returns a new submesh
  20733. */
  20734. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20735. }
  20736. }
  20737. declare module BABYLON {
  20738. /**
  20739. * Class used to represent data loading progression
  20740. */
  20741. export class SceneLoaderFlags {
  20742. private static _ForceFullSceneLoadingForIncremental;
  20743. private static _ShowLoadingScreen;
  20744. private static _CleanBoneMatrixWeights;
  20745. private static _loggingLevel;
  20746. /**
  20747. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20748. */
  20749. static ForceFullSceneLoadingForIncremental: boolean;
  20750. /**
  20751. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20752. */
  20753. static ShowLoadingScreen: boolean;
  20754. /**
  20755. * Defines the current logging level (while loading the scene)
  20756. * @ignorenaming
  20757. */
  20758. static loggingLevel: number;
  20759. /**
  20760. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20761. */
  20762. static CleanBoneMatrixWeights: boolean;
  20763. }
  20764. }
  20765. declare module BABYLON {
  20766. /**
  20767. * Class used to store geometry data (vertex buffers + index buffer)
  20768. */
  20769. export class Geometry implements IGetSetVerticesData {
  20770. /**
  20771. * Gets or sets the ID of the geometry
  20772. */
  20773. id: string;
  20774. /**
  20775. * Gets or sets the unique ID of the geometry
  20776. */
  20777. uniqueId: number;
  20778. /**
  20779. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20780. */
  20781. delayLoadState: number;
  20782. /**
  20783. * Gets the file containing the data to load when running in delay load state
  20784. */
  20785. delayLoadingFile: Nullable<string>;
  20786. /**
  20787. * Callback called when the geometry is updated
  20788. */
  20789. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20790. private _scene;
  20791. private _engine;
  20792. private _meshes;
  20793. private _totalVertices;
  20794. /** @hidden */
  20795. _indices: IndicesArray;
  20796. /** @hidden */
  20797. _vertexBuffers: {
  20798. [key: string]: VertexBuffer;
  20799. };
  20800. private _isDisposed;
  20801. private _extend;
  20802. private _boundingBias;
  20803. /** @hidden */
  20804. _delayInfo: Array<string>;
  20805. private _indexBuffer;
  20806. private _indexBufferIsUpdatable;
  20807. /** @hidden */
  20808. _boundingInfo: Nullable<BoundingInfo>;
  20809. /** @hidden */
  20810. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20811. /** @hidden */
  20812. _softwareSkinningFrameId: number;
  20813. private _vertexArrayObjects;
  20814. private _updatable;
  20815. /** @hidden */
  20816. _positions: Nullable<Vector3[]>;
  20817. /**
  20818. * 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
  20819. */
  20820. /**
  20821. * 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
  20822. */
  20823. boundingBias: Vector2;
  20824. /**
  20825. * Static function used to attach a new empty geometry to a mesh
  20826. * @param mesh defines the mesh to attach the geometry to
  20827. * @returns the new Geometry
  20828. */
  20829. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20830. /**
  20831. * Creates a new geometry
  20832. * @param id defines the unique ID
  20833. * @param scene defines the hosting scene
  20834. * @param vertexData defines the VertexData used to get geometry data
  20835. * @param updatable defines if geometry must be updatable (false by default)
  20836. * @param mesh defines the mesh that will be associated with the geometry
  20837. */
  20838. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20839. /**
  20840. * Gets the current extend of the geometry
  20841. */
  20842. readonly extend: {
  20843. minimum: Vector3;
  20844. maximum: Vector3;
  20845. };
  20846. /**
  20847. * Gets the hosting scene
  20848. * @returns the hosting Scene
  20849. */
  20850. getScene(): Scene;
  20851. /**
  20852. * Gets the hosting engine
  20853. * @returns the hosting Engine
  20854. */
  20855. getEngine(): Engine;
  20856. /**
  20857. * Defines if the geometry is ready to use
  20858. * @returns true if the geometry is ready to be used
  20859. */
  20860. isReady(): boolean;
  20861. /**
  20862. * Gets a value indicating that the geometry should not be serialized
  20863. */
  20864. readonly doNotSerialize: boolean;
  20865. /** @hidden */
  20866. _rebuild(): void;
  20867. /**
  20868. * Affects all geometry data in one call
  20869. * @param vertexData defines the geometry data
  20870. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20871. */
  20872. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20873. /**
  20874. * Set specific vertex data
  20875. * @param kind defines the data kind (Position, normal, etc...)
  20876. * @param data defines the vertex data to use
  20877. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20878. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20879. */
  20880. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20881. /**
  20882. * Removes a specific vertex data
  20883. * @param kind defines the data kind (Position, normal, etc...)
  20884. */
  20885. removeVerticesData(kind: string): void;
  20886. /**
  20887. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20888. * @param buffer defines the vertex buffer to use
  20889. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20890. */
  20891. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20892. /**
  20893. * Update a specific vertex buffer
  20894. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  20895. * It will do nothing if the buffer is not updatable
  20896. * @param kind defines the data kind (Position, normal, etc...)
  20897. * @param data defines the data to use
  20898. * @param offset defines the offset in the target buffer where to store the data
  20899. * @param useBytes set to true if the offset is in bytes
  20900. */
  20901. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20902. /**
  20903. * Update a specific vertex buffer
  20904. * This function will create a new buffer if the current one is not updatable
  20905. * @param kind defines the data kind (Position, normal, etc...)
  20906. * @param data defines the data to use
  20907. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20908. */
  20909. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20910. private _updateBoundingInfo;
  20911. /** @hidden */
  20912. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  20913. /**
  20914. * Gets total number of vertices
  20915. * @returns the total number of vertices
  20916. */
  20917. getTotalVertices(): number;
  20918. /**
  20919. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20920. * @param kind defines the data kind (Position, normal, etc...)
  20921. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20922. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20923. * @returns a float array containing vertex data
  20924. */
  20925. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20926. /**
  20927. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20928. * @param kind defines the data kind (Position, normal, etc...)
  20929. * @returns true if the vertex buffer with the specified kind is updatable
  20930. */
  20931. isVertexBufferUpdatable(kind: string): boolean;
  20932. /**
  20933. * Gets a specific vertex buffer
  20934. * @param kind defines the data kind (Position, normal, etc...)
  20935. * @returns a VertexBuffer
  20936. */
  20937. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20938. /**
  20939. * Returns all vertex buffers
  20940. * @return an object holding all vertex buffers indexed by kind
  20941. */
  20942. getVertexBuffers(): Nullable<{
  20943. [key: string]: VertexBuffer;
  20944. }>;
  20945. /**
  20946. * Gets a boolean indicating if specific vertex buffer is present
  20947. * @param kind defines the data kind (Position, normal, etc...)
  20948. * @returns true if data is present
  20949. */
  20950. isVerticesDataPresent(kind: string): boolean;
  20951. /**
  20952. * Gets a list of all attached data kinds (Position, normal, etc...)
  20953. * @returns a list of string containing all kinds
  20954. */
  20955. getVerticesDataKinds(): string[];
  20956. /**
  20957. * Update index buffer
  20958. * @param indices defines the indices to store in the index buffer
  20959. * @param offset defines the offset in the target buffer where to store the data
  20960. * @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)
  20961. */
  20962. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  20963. /**
  20964. * Creates a new index buffer
  20965. * @param indices defines the indices to store in the index buffer
  20966. * @param totalVertices defines the total number of vertices (could be null)
  20967. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20968. */
  20969. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20970. /**
  20971. * Return the total number of indices
  20972. * @returns the total number of indices
  20973. */
  20974. getTotalIndices(): number;
  20975. /**
  20976. * Gets the index buffer array
  20977. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20978. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20979. * @returns the index buffer array
  20980. */
  20981. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20982. /**
  20983. * Gets the index buffer
  20984. * @return the index buffer
  20985. */
  20986. getIndexBuffer(): Nullable<DataBuffer>;
  20987. /** @hidden */
  20988. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  20989. /**
  20990. * Release the associated resources for a specific mesh
  20991. * @param mesh defines the source mesh
  20992. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20993. */
  20994. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20995. /**
  20996. * Apply current geometry to a given mesh
  20997. * @param mesh defines the mesh to apply geometry to
  20998. */
  20999. applyToMesh(mesh: Mesh): void;
  21000. private _updateExtend;
  21001. private _applyToMesh;
  21002. private notifyUpdate;
  21003. /**
  21004. * Load the geometry if it was flagged as delay loaded
  21005. * @param scene defines the hosting scene
  21006. * @param onLoaded defines a callback called when the geometry is loaded
  21007. */
  21008. load(scene: Scene, onLoaded?: () => void): void;
  21009. private _queueLoad;
  21010. /**
  21011. * Invert the geometry to move from a right handed system to a left handed one.
  21012. */
  21013. toLeftHanded(): void;
  21014. /** @hidden */
  21015. _resetPointsArrayCache(): void;
  21016. /** @hidden */
  21017. _generatePointsArray(): boolean;
  21018. /**
  21019. * Gets a value indicating if the geometry is disposed
  21020. * @returns true if the geometry was disposed
  21021. */
  21022. isDisposed(): boolean;
  21023. private _disposeVertexArrayObjects;
  21024. /**
  21025. * Free all associated resources
  21026. */
  21027. dispose(): void;
  21028. /**
  21029. * Clone the current geometry into a new geometry
  21030. * @param id defines the unique ID of the new geometry
  21031. * @returns a new geometry object
  21032. */
  21033. copy(id: string): Geometry;
  21034. /**
  21035. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21036. * @return a JSON representation of the current geometry data (without the vertices data)
  21037. */
  21038. serialize(): any;
  21039. private toNumberArray;
  21040. /**
  21041. * Serialize all vertices data into a JSON oject
  21042. * @returns a JSON representation of the current geometry data
  21043. */
  21044. serializeVerticeData(): any;
  21045. /**
  21046. * Extracts a clone of a mesh geometry
  21047. * @param mesh defines the source mesh
  21048. * @param id defines the unique ID of the new geometry object
  21049. * @returns the new geometry object
  21050. */
  21051. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21052. /**
  21053. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21054. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21055. * Be aware Math.random() could cause collisions, but:
  21056. * "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"
  21057. * @returns a string containing a new GUID
  21058. */
  21059. static RandomId(): string;
  21060. /** @hidden */
  21061. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21062. private static _CleanMatricesWeights;
  21063. /**
  21064. * Create a new geometry from persisted data (Using .babylon file format)
  21065. * @param parsedVertexData defines the persisted data
  21066. * @param scene defines the hosting scene
  21067. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21068. * @returns the new geometry object
  21069. */
  21070. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21071. }
  21072. }
  21073. declare module BABYLON {
  21074. /**
  21075. * Define an interface for all classes that will get and set the data on vertices
  21076. */
  21077. export interface IGetSetVerticesData {
  21078. /**
  21079. * Gets a boolean indicating if specific vertex data is present
  21080. * @param kind defines the vertex data kind to use
  21081. * @returns true is data kind is present
  21082. */
  21083. isVerticesDataPresent(kind: string): boolean;
  21084. /**
  21085. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21086. * @param kind defines the data kind (Position, normal, etc...)
  21087. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21088. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21089. * @returns a float array containing vertex data
  21090. */
  21091. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21092. /**
  21093. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21094. * @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.
  21095. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21096. * @returns the indices array or an empty array if the mesh has no geometry
  21097. */
  21098. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21099. /**
  21100. * Set specific vertex data
  21101. * @param kind defines the data kind (Position, normal, etc...)
  21102. * @param data defines the vertex data to use
  21103. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21104. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21105. */
  21106. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21107. /**
  21108. * Update a specific associated vertex buffer
  21109. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21110. * - VertexBuffer.PositionKind
  21111. * - VertexBuffer.UVKind
  21112. * - VertexBuffer.UV2Kind
  21113. * - VertexBuffer.UV3Kind
  21114. * - VertexBuffer.UV4Kind
  21115. * - VertexBuffer.UV5Kind
  21116. * - VertexBuffer.UV6Kind
  21117. * - VertexBuffer.ColorKind
  21118. * - VertexBuffer.MatricesIndicesKind
  21119. * - VertexBuffer.MatricesIndicesExtraKind
  21120. * - VertexBuffer.MatricesWeightsKind
  21121. * - VertexBuffer.MatricesWeightsExtraKind
  21122. * @param data defines the data source
  21123. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21124. * @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)
  21125. */
  21126. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21127. /**
  21128. * Creates a new index buffer
  21129. * @param indices defines the indices to store in the index buffer
  21130. * @param totalVertices defines the total number of vertices (could be null)
  21131. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21132. */
  21133. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21134. }
  21135. /**
  21136. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21137. */
  21138. export class VertexData {
  21139. /**
  21140. * Mesh side orientation : usually the external or front surface
  21141. */
  21142. static readonly FRONTSIDE: number;
  21143. /**
  21144. * Mesh side orientation : usually the internal or back surface
  21145. */
  21146. static readonly BACKSIDE: number;
  21147. /**
  21148. * Mesh side orientation : both internal and external or front and back surfaces
  21149. */
  21150. static readonly DOUBLESIDE: number;
  21151. /**
  21152. * Mesh side orientation : by default, `FRONTSIDE`
  21153. */
  21154. static readonly DEFAULTSIDE: number;
  21155. /**
  21156. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21157. */
  21158. positions: Nullable<FloatArray>;
  21159. /**
  21160. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21161. */
  21162. normals: Nullable<FloatArray>;
  21163. /**
  21164. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21165. */
  21166. tangents: Nullable<FloatArray>;
  21167. /**
  21168. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21169. */
  21170. uvs: Nullable<FloatArray>;
  21171. /**
  21172. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21173. */
  21174. uvs2: Nullable<FloatArray>;
  21175. /**
  21176. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21177. */
  21178. uvs3: Nullable<FloatArray>;
  21179. /**
  21180. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21181. */
  21182. uvs4: Nullable<FloatArray>;
  21183. /**
  21184. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21185. */
  21186. uvs5: Nullable<FloatArray>;
  21187. /**
  21188. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21189. */
  21190. uvs6: Nullable<FloatArray>;
  21191. /**
  21192. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21193. */
  21194. colors: Nullable<FloatArray>;
  21195. /**
  21196. * 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).
  21197. */
  21198. matricesIndices: Nullable<FloatArray>;
  21199. /**
  21200. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21201. */
  21202. matricesWeights: Nullable<FloatArray>;
  21203. /**
  21204. * An array extending the number of possible indices
  21205. */
  21206. matricesIndicesExtra: Nullable<FloatArray>;
  21207. /**
  21208. * An array extending the number of possible weights when the number of indices is extended
  21209. */
  21210. matricesWeightsExtra: Nullable<FloatArray>;
  21211. /**
  21212. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21213. */
  21214. indices: Nullable<IndicesArray>;
  21215. /**
  21216. * Uses the passed data array to set the set the values for the specified kind of data
  21217. * @param data a linear array of floating numbers
  21218. * @param kind the type of data that is being set, eg positions, colors etc
  21219. */
  21220. set(data: FloatArray, kind: string): void;
  21221. /**
  21222. * Associates the vertexData to the passed Mesh.
  21223. * Sets it as updatable or not (default `false`)
  21224. * @param mesh the mesh the vertexData is applied to
  21225. * @param updatable when used and having the value true allows new data to update the vertexData
  21226. * @returns the VertexData
  21227. */
  21228. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21229. /**
  21230. * Associates the vertexData to the passed Geometry.
  21231. * Sets it as updatable or not (default `false`)
  21232. * @param geometry the geometry the vertexData is applied to
  21233. * @param updatable when used and having the value true allows new data to update the vertexData
  21234. * @returns VertexData
  21235. */
  21236. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21237. /**
  21238. * Updates the associated mesh
  21239. * @param mesh the mesh to be updated
  21240. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21241. * @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
  21242. * @returns VertexData
  21243. */
  21244. updateMesh(mesh: Mesh): VertexData;
  21245. /**
  21246. * Updates the associated geometry
  21247. * @param geometry the geometry to be updated
  21248. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21249. * @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
  21250. * @returns VertexData.
  21251. */
  21252. updateGeometry(geometry: Geometry): VertexData;
  21253. private _applyTo;
  21254. private _update;
  21255. /**
  21256. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21257. * @param matrix the transforming matrix
  21258. * @returns the VertexData
  21259. */
  21260. transform(matrix: Matrix): VertexData;
  21261. /**
  21262. * Merges the passed VertexData into the current one
  21263. * @param other the VertexData to be merged into the current one
  21264. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21265. * @returns the modified VertexData
  21266. */
  21267. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21268. private _mergeElement;
  21269. private _validate;
  21270. /**
  21271. * Serializes the VertexData
  21272. * @returns a serialized object
  21273. */
  21274. serialize(): any;
  21275. /**
  21276. * Extracts the vertexData from a mesh
  21277. * @param mesh the mesh from which to extract the VertexData
  21278. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21279. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21280. * @returns the object VertexData associated to the passed mesh
  21281. */
  21282. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21283. /**
  21284. * Extracts the vertexData from the geometry
  21285. * @param geometry the geometry from which to extract the VertexData
  21286. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21287. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21288. * @returns the object VertexData associated to the passed mesh
  21289. */
  21290. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21291. private static _ExtractFrom;
  21292. /**
  21293. * Creates the VertexData for a Ribbon
  21294. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21295. * * pathArray array of paths, each of which an array of successive Vector3
  21296. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21297. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21298. * * 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
  21299. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21300. * * 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)
  21301. * * 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)
  21302. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21303. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21304. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21305. * @returns the VertexData of the ribbon
  21306. */
  21307. static CreateRibbon(options: {
  21308. pathArray: Vector3[][];
  21309. closeArray?: boolean;
  21310. closePath?: boolean;
  21311. offset?: number;
  21312. sideOrientation?: number;
  21313. frontUVs?: Vector4;
  21314. backUVs?: Vector4;
  21315. invertUV?: boolean;
  21316. uvs?: Vector2[];
  21317. colors?: Color4[];
  21318. }): VertexData;
  21319. /**
  21320. * Creates the VertexData for a box
  21321. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21322. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21323. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21324. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21325. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21326. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21327. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21328. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21329. * * 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)
  21330. * * 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)
  21331. * @returns the VertexData of the box
  21332. */
  21333. static CreateBox(options: {
  21334. size?: number;
  21335. width?: number;
  21336. height?: number;
  21337. depth?: number;
  21338. faceUV?: Vector4[];
  21339. faceColors?: Color4[];
  21340. sideOrientation?: number;
  21341. frontUVs?: Vector4;
  21342. backUVs?: Vector4;
  21343. }): VertexData;
  21344. /**
  21345. * Creates the VertexData for a tiled box
  21346. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21347. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21348. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21349. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21350. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21351. * @returns the VertexData of the box
  21352. */
  21353. static CreateTiledBox(options: {
  21354. pattern?: number;
  21355. width?: number;
  21356. height?: number;
  21357. depth?: number;
  21358. tileSize?: number;
  21359. tileWidth?: number;
  21360. tileHeight?: number;
  21361. alignHorizontal?: number;
  21362. alignVertical?: number;
  21363. faceUV?: Vector4[];
  21364. faceColors?: Color4[];
  21365. sideOrientation?: number;
  21366. }): VertexData;
  21367. /**
  21368. * Creates the VertexData for a tiled plane
  21369. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21370. * * pattern a limited pattern arrangement depending on the number
  21371. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21372. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21373. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21374. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21375. * * 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)
  21376. * * 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)
  21377. * @returns the VertexData of the tiled plane
  21378. */
  21379. static CreateTiledPlane(options: {
  21380. pattern?: number;
  21381. tileSize?: number;
  21382. tileWidth?: number;
  21383. tileHeight?: number;
  21384. size?: number;
  21385. width?: number;
  21386. height?: number;
  21387. alignHorizontal?: number;
  21388. alignVertical?: number;
  21389. sideOrientation?: number;
  21390. frontUVs?: Vector4;
  21391. backUVs?: Vector4;
  21392. }): VertexData;
  21393. /**
  21394. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21395. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21396. * * segments sets the number of horizontal strips optional, default 32
  21397. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21398. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21399. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21400. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21401. * * 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
  21402. * * 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
  21403. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21404. * * 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)
  21405. * * 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)
  21406. * @returns the VertexData of the ellipsoid
  21407. */
  21408. static CreateSphere(options: {
  21409. segments?: number;
  21410. diameter?: number;
  21411. diameterX?: number;
  21412. diameterY?: number;
  21413. diameterZ?: number;
  21414. arc?: number;
  21415. slice?: number;
  21416. sideOrientation?: number;
  21417. frontUVs?: Vector4;
  21418. backUVs?: Vector4;
  21419. }): VertexData;
  21420. /**
  21421. * Creates the VertexData for a cylinder, cone or prism
  21422. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21423. * * height sets the height (y direction) of the cylinder, optional, default 2
  21424. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21425. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21426. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21427. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21428. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21429. * * 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
  21430. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21431. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21432. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21433. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21434. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21435. * * 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)
  21436. * * 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)
  21437. * @returns the VertexData of the cylinder, cone or prism
  21438. */
  21439. static CreateCylinder(options: {
  21440. height?: number;
  21441. diameterTop?: number;
  21442. diameterBottom?: number;
  21443. diameter?: number;
  21444. tessellation?: number;
  21445. subdivisions?: number;
  21446. arc?: number;
  21447. faceColors?: Color4[];
  21448. faceUV?: Vector4[];
  21449. hasRings?: boolean;
  21450. enclose?: boolean;
  21451. sideOrientation?: number;
  21452. frontUVs?: Vector4;
  21453. backUVs?: Vector4;
  21454. }): VertexData;
  21455. /**
  21456. * Creates the VertexData for a torus
  21457. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21458. * * diameter the diameter of the torus, optional default 1
  21459. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21460. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21461. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21462. * * 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)
  21463. * * 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)
  21464. * @returns the VertexData of the torus
  21465. */
  21466. static CreateTorus(options: {
  21467. diameter?: number;
  21468. thickness?: number;
  21469. tessellation?: number;
  21470. sideOrientation?: number;
  21471. frontUVs?: Vector4;
  21472. backUVs?: Vector4;
  21473. }): VertexData;
  21474. /**
  21475. * Creates the VertexData of the LineSystem
  21476. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21477. * - lines an array of lines, each line being an array of successive Vector3
  21478. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21479. * @returns the VertexData of the LineSystem
  21480. */
  21481. static CreateLineSystem(options: {
  21482. lines: Vector3[][];
  21483. colors?: Nullable<Color4[][]>;
  21484. }): VertexData;
  21485. /**
  21486. * Create the VertexData for a DashedLines
  21487. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21488. * - points an array successive Vector3
  21489. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21490. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21491. * - dashNb the intended total number of dashes, optional, default 200
  21492. * @returns the VertexData for the DashedLines
  21493. */
  21494. static CreateDashedLines(options: {
  21495. points: Vector3[];
  21496. dashSize?: number;
  21497. gapSize?: number;
  21498. dashNb?: number;
  21499. }): VertexData;
  21500. /**
  21501. * Creates the VertexData for a Ground
  21502. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21503. * - width the width (x direction) of the ground, optional, default 1
  21504. * - height the height (z direction) of the ground, optional, default 1
  21505. * - subdivisions the number of subdivisions per side, optional, default 1
  21506. * @returns the VertexData of the Ground
  21507. */
  21508. static CreateGround(options: {
  21509. width?: number;
  21510. height?: number;
  21511. subdivisions?: number;
  21512. subdivisionsX?: number;
  21513. subdivisionsY?: number;
  21514. }): VertexData;
  21515. /**
  21516. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21517. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21518. * * xmin the ground minimum X coordinate, optional, default -1
  21519. * * zmin the ground minimum Z coordinate, optional, default -1
  21520. * * xmax the ground maximum X coordinate, optional, default 1
  21521. * * zmax the ground maximum Z coordinate, optional, default 1
  21522. * * 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}
  21523. * * 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}
  21524. * @returns the VertexData of the TiledGround
  21525. */
  21526. static CreateTiledGround(options: {
  21527. xmin: number;
  21528. zmin: number;
  21529. xmax: number;
  21530. zmax: number;
  21531. subdivisions?: {
  21532. w: number;
  21533. h: number;
  21534. };
  21535. precision?: {
  21536. w: number;
  21537. h: number;
  21538. };
  21539. }): VertexData;
  21540. /**
  21541. * Creates the VertexData of the Ground designed from a heightmap
  21542. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21543. * * width the width (x direction) of the ground
  21544. * * height the height (z direction) of the ground
  21545. * * subdivisions the number of subdivisions per side
  21546. * * minHeight the minimum altitude on the ground, optional, default 0
  21547. * * maxHeight the maximum altitude on the ground, optional default 1
  21548. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21549. * * buffer the array holding the image color data
  21550. * * bufferWidth the width of image
  21551. * * bufferHeight the height of image
  21552. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21553. * @returns the VertexData of the Ground designed from a heightmap
  21554. */
  21555. static CreateGroundFromHeightMap(options: {
  21556. width: number;
  21557. height: number;
  21558. subdivisions: number;
  21559. minHeight: number;
  21560. maxHeight: number;
  21561. colorFilter: Color3;
  21562. buffer: Uint8Array;
  21563. bufferWidth: number;
  21564. bufferHeight: number;
  21565. alphaFilter: number;
  21566. }): VertexData;
  21567. /**
  21568. * Creates the VertexData for a Plane
  21569. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21570. * * size sets the width and height of the plane to the value of size, optional default 1
  21571. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21572. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21573. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21574. * * 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)
  21575. * * 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)
  21576. * @returns the VertexData of the box
  21577. */
  21578. static CreatePlane(options: {
  21579. size?: number;
  21580. width?: number;
  21581. height?: number;
  21582. sideOrientation?: number;
  21583. frontUVs?: Vector4;
  21584. backUVs?: Vector4;
  21585. }): VertexData;
  21586. /**
  21587. * Creates the VertexData of the Disc or regular Polygon
  21588. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21589. * * radius the radius of the disc, optional default 0.5
  21590. * * tessellation the number of polygon sides, optional, default 64
  21591. * * 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
  21592. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21593. * * 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)
  21594. * * 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)
  21595. * @returns the VertexData of the box
  21596. */
  21597. static CreateDisc(options: {
  21598. radius?: number;
  21599. tessellation?: number;
  21600. arc?: number;
  21601. sideOrientation?: number;
  21602. frontUVs?: Vector4;
  21603. backUVs?: Vector4;
  21604. }): VertexData;
  21605. /**
  21606. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21607. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21608. * @param polygon a mesh built from polygonTriangulation.build()
  21609. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21610. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21611. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21612. * @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)
  21613. * @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)
  21614. * @returns the VertexData of the Polygon
  21615. */
  21616. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21617. /**
  21618. * Creates the VertexData of the IcoSphere
  21619. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21620. * * radius the radius of the IcoSphere, optional default 1
  21621. * * radiusX allows stretching in the x direction, optional, default radius
  21622. * * radiusY allows stretching in the y direction, optional, default radius
  21623. * * radiusZ allows stretching in the z direction, optional, default radius
  21624. * * flat when true creates a flat shaded mesh, optional, default true
  21625. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21626. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21627. * * 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)
  21628. * * 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)
  21629. * @returns the VertexData of the IcoSphere
  21630. */
  21631. static CreateIcoSphere(options: {
  21632. radius?: number;
  21633. radiusX?: number;
  21634. radiusY?: number;
  21635. radiusZ?: number;
  21636. flat?: boolean;
  21637. subdivisions?: number;
  21638. sideOrientation?: number;
  21639. frontUVs?: Vector4;
  21640. backUVs?: Vector4;
  21641. }): VertexData;
  21642. /**
  21643. * Creates the VertexData for a Polyhedron
  21644. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21645. * * type provided types are:
  21646. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21647. * * 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)
  21648. * * size the size of the IcoSphere, optional default 1
  21649. * * sizeX allows stretching in the x direction, optional, default size
  21650. * * sizeY allows stretching in the y direction, optional, default size
  21651. * * sizeZ allows stretching in the z direction, optional, default size
  21652. * * 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
  21653. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21654. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21655. * * flat when true creates a flat shaded mesh, optional, default true
  21656. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21657. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21658. * * 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)
  21659. * * 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)
  21660. * @returns the VertexData of the Polyhedron
  21661. */
  21662. static CreatePolyhedron(options: {
  21663. type?: number;
  21664. size?: number;
  21665. sizeX?: number;
  21666. sizeY?: number;
  21667. sizeZ?: number;
  21668. custom?: any;
  21669. faceUV?: Vector4[];
  21670. faceColors?: Color4[];
  21671. flat?: boolean;
  21672. sideOrientation?: number;
  21673. frontUVs?: Vector4;
  21674. backUVs?: Vector4;
  21675. }): VertexData;
  21676. /**
  21677. * Creates the VertexData for a TorusKnot
  21678. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21679. * * radius the radius of the torus knot, optional, default 2
  21680. * * tube the thickness of the tube, optional, default 0.5
  21681. * * radialSegments the number of sides on each tube segments, optional, default 32
  21682. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21683. * * p the number of windings around the z axis, optional, default 2
  21684. * * q the number of windings around the x axis, optional, default 3
  21685. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21686. * * 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)
  21687. * * 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)
  21688. * @returns the VertexData of the Torus Knot
  21689. */
  21690. static CreateTorusKnot(options: {
  21691. radius?: number;
  21692. tube?: number;
  21693. radialSegments?: number;
  21694. tubularSegments?: number;
  21695. p?: number;
  21696. q?: number;
  21697. sideOrientation?: number;
  21698. frontUVs?: Vector4;
  21699. backUVs?: Vector4;
  21700. }): VertexData;
  21701. /**
  21702. * Compute normals for given positions and indices
  21703. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21704. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21705. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21706. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21707. * * facetNormals : optional array of facet normals (vector3)
  21708. * * facetPositions : optional array of facet positions (vector3)
  21709. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21710. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21711. * * bInfo : optional bounding info, required for facetPartitioning computation
  21712. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21713. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21714. * * useRightHandedSystem: optional boolean to for right handed system computation
  21715. * * depthSort : optional boolean to enable the facet depth sort computation
  21716. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21717. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21718. */
  21719. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21720. facetNormals?: any;
  21721. facetPositions?: any;
  21722. facetPartitioning?: any;
  21723. ratio?: number;
  21724. bInfo?: any;
  21725. bbSize?: Vector3;
  21726. subDiv?: any;
  21727. useRightHandedSystem?: boolean;
  21728. depthSort?: boolean;
  21729. distanceTo?: Vector3;
  21730. depthSortedFacets?: any;
  21731. }): void;
  21732. /** @hidden */
  21733. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21734. /**
  21735. * Applies VertexData created from the imported parameters to the geometry
  21736. * @param parsedVertexData the parsed data from an imported file
  21737. * @param geometry the geometry to apply the VertexData to
  21738. */
  21739. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21740. }
  21741. }
  21742. declare module BABYLON {
  21743. /**
  21744. * Defines a target to use with MorphTargetManager
  21745. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21746. */
  21747. export class MorphTarget implements IAnimatable {
  21748. /** defines the name of the target */
  21749. name: string;
  21750. /**
  21751. * Gets or sets the list of animations
  21752. */
  21753. animations: Animation[];
  21754. private _scene;
  21755. private _positions;
  21756. private _normals;
  21757. private _tangents;
  21758. private _uvs;
  21759. private _influence;
  21760. /**
  21761. * Observable raised when the influence changes
  21762. */
  21763. onInfluenceChanged: Observable<boolean>;
  21764. /** @hidden */
  21765. _onDataLayoutChanged: Observable<void>;
  21766. /**
  21767. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21768. */
  21769. influence: number;
  21770. /**
  21771. * Gets or sets the id of the morph Target
  21772. */
  21773. id: string;
  21774. private _animationPropertiesOverride;
  21775. /**
  21776. * Gets or sets the animation properties override
  21777. */
  21778. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21779. /**
  21780. * Creates a new MorphTarget
  21781. * @param name defines the name of the target
  21782. * @param influence defines the influence to use
  21783. * @param scene defines the scene the morphtarget belongs to
  21784. */
  21785. constructor(
  21786. /** defines the name of the target */
  21787. name: string, influence?: number, scene?: Nullable<Scene>);
  21788. /**
  21789. * Gets a boolean defining if the target contains position data
  21790. */
  21791. readonly hasPositions: boolean;
  21792. /**
  21793. * Gets a boolean defining if the target contains normal data
  21794. */
  21795. readonly hasNormals: boolean;
  21796. /**
  21797. * Gets a boolean defining if the target contains tangent data
  21798. */
  21799. readonly hasTangents: boolean;
  21800. /**
  21801. * Gets a boolean defining if the target contains texture coordinates data
  21802. */
  21803. readonly hasUVs: boolean;
  21804. /**
  21805. * Affects position data to this target
  21806. * @param data defines the position data to use
  21807. */
  21808. setPositions(data: Nullable<FloatArray>): void;
  21809. /**
  21810. * Gets the position data stored in this target
  21811. * @returns a FloatArray containing the position data (or null if not present)
  21812. */
  21813. getPositions(): Nullable<FloatArray>;
  21814. /**
  21815. * Affects normal data to this target
  21816. * @param data defines the normal data to use
  21817. */
  21818. setNormals(data: Nullable<FloatArray>): void;
  21819. /**
  21820. * Gets the normal data stored in this target
  21821. * @returns a FloatArray containing the normal data (or null if not present)
  21822. */
  21823. getNormals(): Nullable<FloatArray>;
  21824. /**
  21825. * Affects tangent data to this target
  21826. * @param data defines the tangent data to use
  21827. */
  21828. setTangents(data: Nullable<FloatArray>): void;
  21829. /**
  21830. * Gets the tangent data stored in this target
  21831. * @returns a FloatArray containing the tangent data (or null if not present)
  21832. */
  21833. getTangents(): Nullable<FloatArray>;
  21834. /**
  21835. * Affects texture coordinates data to this target
  21836. * @param data defines the texture coordinates data to use
  21837. */
  21838. setUVs(data: Nullable<FloatArray>): void;
  21839. /**
  21840. * Gets the texture coordinates data stored in this target
  21841. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  21842. */
  21843. getUVs(): Nullable<FloatArray>;
  21844. /**
  21845. * Serializes the current target into a Serialization object
  21846. * @returns the serialized object
  21847. */
  21848. serialize(): any;
  21849. /**
  21850. * Returns the string "MorphTarget"
  21851. * @returns "MorphTarget"
  21852. */
  21853. getClassName(): string;
  21854. /**
  21855. * Creates a new target from serialized data
  21856. * @param serializationObject defines the serialized data to use
  21857. * @returns a new MorphTarget
  21858. */
  21859. static Parse(serializationObject: any): MorphTarget;
  21860. /**
  21861. * Creates a MorphTarget from mesh data
  21862. * @param mesh defines the source mesh
  21863. * @param name defines the name to use for the new target
  21864. * @param influence defines the influence to attach to the target
  21865. * @returns a new MorphTarget
  21866. */
  21867. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  21868. }
  21869. }
  21870. declare module BABYLON {
  21871. /**
  21872. * This class is used to deform meshes using morphing between different targets
  21873. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21874. */
  21875. export class MorphTargetManager {
  21876. private _targets;
  21877. private _targetInfluenceChangedObservers;
  21878. private _targetDataLayoutChangedObservers;
  21879. private _activeTargets;
  21880. private _scene;
  21881. private _influences;
  21882. private _supportsNormals;
  21883. private _supportsTangents;
  21884. private _supportsUVs;
  21885. private _vertexCount;
  21886. private _uniqueId;
  21887. private _tempInfluences;
  21888. /**
  21889. * Gets or sets a boolean indicating if normals must be morphed
  21890. */
  21891. enableNormalMorphing: boolean;
  21892. /**
  21893. * Gets or sets a boolean indicating if tangents must be morphed
  21894. */
  21895. enableTangentMorphing: boolean;
  21896. /**
  21897. * Gets or sets a boolean indicating if UV must be morphed
  21898. */
  21899. enableUVMorphing: boolean;
  21900. /**
  21901. * Creates a new MorphTargetManager
  21902. * @param scene defines the current scene
  21903. */
  21904. constructor(scene?: Nullable<Scene>);
  21905. /**
  21906. * Gets the unique ID of this manager
  21907. */
  21908. readonly uniqueId: number;
  21909. /**
  21910. * Gets the number of vertices handled by this manager
  21911. */
  21912. readonly vertexCount: number;
  21913. /**
  21914. * Gets a boolean indicating if this manager supports morphing of normals
  21915. */
  21916. readonly supportsNormals: boolean;
  21917. /**
  21918. * Gets a boolean indicating if this manager supports morphing of tangents
  21919. */
  21920. readonly supportsTangents: boolean;
  21921. /**
  21922. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  21923. */
  21924. readonly supportsUVs: boolean;
  21925. /**
  21926. * Gets the number of targets stored in this manager
  21927. */
  21928. readonly numTargets: number;
  21929. /**
  21930. * Gets the number of influencers (ie. the number of targets with influences > 0)
  21931. */
  21932. readonly numInfluencers: number;
  21933. /**
  21934. * Gets the list of influences (one per target)
  21935. */
  21936. readonly influences: Float32Array;
  21937. /**
  21938. * Gets the active target at specified index. An active target is a target with an influence > 0
  21939. * @param index defines the index to check
  21940. * @returns the requested target
  21941. */
  21942. getActiveTarget(index: number): MorphTarget;
  21943. /**
  21944. * Gets the target at specified index
  21945. * @param index defines the index to check
  21946. * @returns the requested target
  21947. */
  21948. getTarget(index: number): MorphTarget;
  21949. /**
  21950. * Add a new target to this manager
  21951. * @param target defines the target to add
  21952. */
  21953. addTarget(target: MorphTarget): void;
  21954. /**
  21955. * Removes a target from the manager
  21956. * @param target defines the target to remove
  21957. */
  21958. removeTarget(target: MorphTarget): void;
  21959. /**
  21960. * Serializes the current manager into a Serialization object
  21961. * @returns the serialized object
  21962. */
  21963. serialize(): any;
  21964. private _syncActiveTargets;
  21965. /**
  21966. * Syncrhonize the targets with all the meshes using this morph target manager
  21967. */
  21968. synchronize(): void;
  21969. /**
  21970. * Creates a new MorphTargetManager from serialized data
  21971. * @param serializationObject defines the serialized data
  21972. * @param scene defines the hosting scene
  21973. * @returns the new MorphTargetManager
  21974. */
  21975. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  21976. }
  21977. }
  21978. declare module BABYLON {
  21979. /**
  21980. * Class used to represent a specific level of detail of a mesh
  21981. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21982. */
  21983. export class MeshLODLevel {
  21984. /** Defines the distance where this level should star being displayed */
  21985. distance: number;
  21986. /** Defines the mesh to use to render this level */
  21987. mesh: Nullable<Mesh>;
  21988. /**
  21989. * Creates a new LOD level
  21990. * @param distance defines the distance where this level should star being displayed
  21991. * @param mesh defines the mesh to use to render this level
  21992. */
  21993. constructor(
  21994. /** Defines the distance where this level should star being displayed */
  21995. distance: number,
  21996. /** Defines the mesh to use to render this level */
  21997. mesh: Nullable<Mesh>);
  21998. }
  21999. }
  22000. declare module BABYLON {
  22001. /**
  22002. * Mesh representing the gorund
  22003. */
  22004. export class GroundMesh extends Mesh {
  22005. /** If octree should be generated */
  22006. generateOctree: boolean;
  22007. private _heightQuads;
  22008. /** @hidden */
  22009. _subdivisionsX: number;
  22010. /** @hidden */
  22011. _subdivisionsY: number;
  22012. /** @hidden */
  22013. _width: number;
  22014. /** @hidden */
  22015. _height: number;
  22016. /** @hidden */
  22017. _minX: number;
  22018. /** @hidden */
  22019. _maxX: number;
  22020. /** @hidden */
  22021. _minZ: number;
  22022. /** @hidden */
  22023. _maxZ: number;
  22024. constructor(name: string, scene: Scene);
  22025. /**
  22026. * "GroundMesh"
  22027. * @returns "GroundMesh"
  22028. */
  22029. getClassName(): string;
  22030. /**
  22031. * The minimum of x and y subdivisions
  22032. */
  22033. readonly subdivisions: number;
  22034. /**
  22035. * X subdivisions
  22036. */
  22037. readonly subdivisionsX: number;
  22038. /**
  22039. * Y subdivisions
  22040. */
  22041. readonly subdivisionsY: number;
  22042. /**
  22043. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22044. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22045. * @param chunksCount the number of subdivisions for x and y
  22046. * @param octreeBlocksSize (Default: 32)
  22047. */
  22048. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22049. /**
  22050. * Returns a height (y) value in the Worl system :
  22051. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22052. * @param x x coordinate
  22053. * @param z z coordinate
  22054. * @returns the ground y position if (x, z) are outside the ground surface.
  22055. */
  22056. getHeightAtCoordinates(x: number, z: number): number;
  22057. /**
  22058. * Returns a normalized vector (Vector3) orthogonal to the ground
  22059. * at the ground coordinates (x, z) expressed in the World system.
  22060. * @param x x coordinate
  22061. * @param z z coordinate
  22062. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22063. */
  22064. getNormalAtCoordinates(x: number, z: number): Vector3;
  22065. /**
  22066. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22067. * at the ground coordinates (x, z) expressed in the World system.
  22068. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22069. * @param x x coordinate
  22070. * @param z z coordinate
  22071. * @param ref vector to store the result
  22072. * @returns the GroundMesh.
  22073. */
  22074. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22075. /**
  22076. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22077. * if the ground has been updated.
  22078. * This can be used in the render loop.
  22079. * @returns the GroundMesh.
  22080. */
  22081. updateCoordinateHeights(): GroundMesh;
  22082. private _getFacetAt;
  22083. private _initHeightQuads;
  22084. private _computeHeightQuads;
  22085. /**
  22086. * Serializes this ground mesh
  22087. * @param serializationObject object to write serialization to
  22088. */
  22089. serialize(serializationObject: any): void;
  22090. /**
  22091. * Parses a serialized ground mesh
  22092. * @param parsedMesh the serialized mesh
  22093. * @param scene the scene to create the ground mesh in
  22094. * @returns the created ground mesh
  22095. */
  22096. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22097. }
  22098. }
  22099. declare module BABYLON {
  22100. /**
  22101. * Interface for Physics-Joint data
  22102. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22103. */
  22104. export interface PhysicsJointData {
  22105. /**
  22106. * The main pivot of the joint
  22107. */
  22108. mainPivot?: Vector3;
  22109. /**
  22110. * The connected pivot of the joint
  22111. */
  22112. connectedPivot?: Vector3;
  22113. /**
  22114. * The main axis of the joint
  22115. */
  22116. mainAxis?: Vector3;
  22117. /**
  22118. * The connected axis of the joint
  22119. */
  22120. connectedAxis?: Vector3;
  22121. /**
  22122. * The collision of the joint
  22123. */
  22124. collision?: boolean;
  22125. /**
  22126. * Native Oimo/Cannon/Energy data
  22127. */
  22128. nativeParams?: any;
  22129. }
  22130. /**
  22131. * This is a holder class for the physics joint created by the physics plugin
  22132. * It holds a set of functions to control the underlying joint
  22133. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22134. */
  22135. export class PhysicsJoint {
  22136. /**
  22137. * The type of the physics joint
  22138. */
  22139. type: number;
  22140. /**
  22141. * The data for the physics joint
  22142. */
  22143. jointData: PhysicsJointData;
  22144. private _physicsJoint;
  22145. protected _physicsPlugin: IPhysicsEnginePlugin;
  22146. /**
  22147. * Initializes the physics joint
  22148. * @param type The type of the physics joint
  22149. * @param jointData The data for the physics joint
  22150. */
  22151. constructor(
  22152. /**
  22153. * The type of the physics joint
  22154. */
  22155. type: number,
  22156. /**
  22157. * The data for the physics joint
  22158. */
  22159. jointData: PhysicsJointData);
  22160. /**
  22161. * Gets the physics joint
  22162. */
  22163. /**
  22164. * Sets the physics joint
  22165. */
  22166. physicsJoint: any;
  22167. /**
  22168. * Sets the physics plugin
  22169. */
  22170. physicsPlugin: IPhysicsEnginePlugin;
  22171. /**
  22172. * Execute a function that is physics-plugin specific.
  22173. * @param {Function} func the function that will be executed.
  22174. * It accepts two parameters: the physics world and the physics joint
  22175. */
  22176. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22177. /**
  22178. * Distance-Joint type
  22179. */
  22180. static DistanceJoint: number;
  22181. /**
  22182. * Hinge-Joint type
  22183. */
  22184. static HingeJoint: number;
  22185. /**
  22186. * Ball-and-Socket joint type
  22187. */
  22188. static BallAndSocketJoint: number;
  22189. /**
  22190. * Wheel-Joint type
  22191. */
  22192. static WheelJoint: number;
  22193. /**
  22194. * Slider-Joint type
  22195. */
  22196. static SliderJoint: number;
  22197. /**
  22198. * Prismatic-Joint type
  22199. */
  22200. static PrismaticJoint: number;
  22201. /**
  22202. * Universal-Joint type
  22203. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22204. */
  22205. static UniversalJoint: number;
  22206. /**
  22207. * Hinge-Joint 2 type
  22208. */
  22209. static Hinge2Joint: number;
  22210. /**
  22211. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22212. */
  22213. static PointToPointJoint: number;
  22214. /**
  22215. * Spring-Joint type
  22216. */
  22217. static SpringJoint: number;
  22218. /**
  22219. * Lock-Joint type
  22220. */
  22221. static LockJoint: number;
  22222. }
  22223. /**
  22224. * A class representing a physics distance joint
  22225. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22226. */
  22227. export class DistanceJoint extends PhysicsJoint {
  22228. /**
  22229. *
  22230. * @param jointData The data for the Distance-Joint
  22231. */
  22232. constructor(jointData: DistanceJointData);
  22233. /**
  22234. * Update the predefined distance.
  22235. * @param maxDistance The maximum preferred distance
  22236. * @param minDistance The minimum preferred distance
  22237. */
  22238. updateDistance(maxDistance: number, minDistance?: number): void;
  22239. }
  22240. /**
  22241. * Represents a Motor-Enabled Joint
  22242. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22243. */
  22244. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22245. /**
  22246. * Initializes the Motor-Enabled Joint
  22247. * @param type The type of the joint
  22248. * @param jointData The physica joint data for the joint
  22249. */
  22250. constructor(type: number, jointData: PhysicsJointData);
  22251. /**
  22252. * Set the motor values.
  22253. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22254. * @param force the force to apply
  22255. * @param maxForce max force for this motor.
  22256. */
  22257. setMotor(force?: number, maxForce?: number): void;
  22258. /**
  22259. * Set the motor's limits.
  22260. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22261. * @param upperLimit The upper limit of the motor
  22262. * @param lowerLimit The lower limit of the motor
  22263. */
  22264. setLimit(upperLimit: number, lowerLimit?: number): void;
  22265. }
  22266. /**
  22267. * This class represents a single physics Hinge-Joint
  22268. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22269. */
  22270. export class HingeJoint extends MotorEnabledJoint {
  22271. /**
  22272. * Initializes the Hinge-Joint
  22273. * @param jointData The joint data for the Hinge-Joint
  22274. */
  22275. constructor(jointData: PhysicsJointData);
  22276. /**
  22277. * Set the motor values.
  22278. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22279. * @param {number} force the force to apply
  22280. * @param {number} maxForce max force for this motor.
  22281. */
  22282. setMotor(force?: number, maxForce?: number): void;
  22283. /**
  22284. * Set the motor's limits.
  22285. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22286. * @param upperLimit The upper limit of the motor
  22287. * @param lowerLimit The lower limit of the motor
  22288. */
  22289. setLimit(upperLimit: number, lowerLimit?: number): void;
  22290. }
  22291. /**
  22292. * This class represents a dual hinge physics joint (same as wheel joint)
  22293. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22294. */
  22295. export class Hinge2Joint extends MotorEnabledJoint {
  22296. /**
  22297. * Initializes the Hinge2-Joint
  22298. * @param jointData The joint data for the Hinge2-Joint
  22299. */
  22300. constructor(jointData: PhysicsJointData);
  22301. /**
  22302. * Set the motor values.
  22303. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22304. * @param {number} targetSpeed the speed the motor is to reach
  22305. * @param {number} maxForce max force for this motor.
  22306. * @param {motorIndex} the motor's index, 0 or 1.
  22307. */
  22308. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22309. /**
  22310. * Set the motor limits.
  22311. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22312. * @param {number} upperLimit the upper limit
  22313. * @param {number} lowerLimit lower limit
  22314. * @param {motorIndex} the motor's index, 0 or 1.
  22315. */
  22316. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22317. }
  22318. /**
  22319. * Interface for a motor enabled joint
  22320. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22321. */
  22322. export interface IMotorEnabledJoint {
  22323. /**
  22324. * Physics joint
  22325. */
  22326. physicsJoint: any;
  22327. /**
  22328. * Sets the motor of the motor-enabled joint
  22329. * @param force The force of the motor
  22330. * @param maxForce The maximum force of the motor
  22331. * @param motorIndex The index of the motor
  22332. */
  22333. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22334. /**
  22335. * Sets the limit of the motor
  22336. * @param upperLimit The upper limit of the motor
  22337. * @param lowerLimit The lower limit of the motor
  22338. * @param motorIndex The index of the motor
  22339. */
  22340. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22341. }
  22342. /**
  22343. * Joint data for a Distance-Joint
  22344. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22345. */
  22346. export interface DistanceJointData extends PhysicsJointData {
  22347. /**
  22348. * Max distance the 2 joint objects can be apart
  22349. */
  22350. maxDistance: number;
  22351. }
  22352. /**
  22353. * Joint data from a spring joint
  22354. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22355. */
  22356. export interface SpringJointData extends PhysicsJointData {
  22357. /**
  22358. * Length of the spring
  22359. */
  22360. length: number;
  22361. /**
  22362. * Stiffness of the spring
  22363. */
  22364. stiffness: number;
  22365. /**
  22366. * Damping of the spring
  22367. */
  22368. damping: number;
  22369. /** this callback will be called when applying the force to the impostors. */
  22370. forceApplicationCallback: () => void;
  22371. }
  22372. }
  22373. declare module BABYLON {
  22374. /**
  22375. * Holds the data for the raycast result
  22376. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22377. */
  22378. export class PhysicsRaycastResult {
  22379. private _hasHit;
  22380. private _hitDistance;
  22381. private _hitNormalWorld;
  22382. private _hitPointWorld;
  22383. private _rayFromWorld;
  22384. private _rayToWorld;
  22385. /**
  22386. * Gets if there was a hit
  22387. */
  22388. readonly hasHit: boolean;
  22389. /**
  22390. * Gets the distance from the hit
  22391. */
  22392. readonly hitDistance: number;
  22393. /**
  22394. * Gets the hit normal/direction in the world
  22395. */
  22396. readonly hitNormalWorld: Vector3;
  22397. /**
  22398. * Gets the hit point in the world
  22399. */
  22400. readonly hitPointWorld: Vector3;
  22401. /**
  22402. * Gets the ray "start point" of the ray in the world
  22403. */
  22404. readonly rayFromWorld: Vector3;
  22405. /**
  22406. * Gets the ray "end point" of the ray in the world
  22407. */
  22408. readonly rayToWorld: Vector3;
  22409. /**
  22410. * Sets the hit data (normal & point in world space)
  22411. * @param hitNormalWorld defines the normal in world space
  22412. * @param hitPointWorld defines the point in world space
  22413. */
  22414. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22415. /**
  22416. * Sets the distance from the start point to the hit point
  22417. * @param distance
  22418. */
  22419. setHitDistance(distance: number): void;
  22420. /**
  22421. * Calculates the distance manually
  22422. */
  22423. calculateHitDistance(): void;
  22424. /**
  22425. * Resets all the values to default
  22426. * @param from The from point on world space
  22427. * @param to The to point on world space
  22428. */
  22429. reset(from?: Vector3, to?: Vector3): void;
  22430. }
  22431. /**
  22432. * Interface for the size containing width and height
  22433. */
  22434. interface IXYZ {
  22435. /**
  22436. * X
  22437. */
  22438. x: number;
  22439. /**
  22440. * Y
  22441. */
  22442. y: number;
  22443. /**
  22444. * Z
  22445. */
  22446. z: number;
  22447. }
  22448. }
  22449. declare module BABYLON {
  22450. /**
  22451. * Interface used to describe a physics joint
  22452. */
  22453. export interface PhysicsImpostorJoint {
  22454. /** Defines the main impostor to which the joint is linked */
  22455. mainImpostor: PhysicsImpostor;
  22456. /** Defines the impostor that is connected to the main impostor using this joint */
  22457. connectedImpostor: PhysicsImpostor;
  22458. /** Defines the joint itself */
  22459. joint: PhysicsJoint;
  22460. }
  22461. /** @hidden */
  22462. export interface IPhysicsEnginePlugin {
  22463. world: any;
  22464. name: string;
  22465. setGravity(gravity: Vector3): void;
  22466. setTimeStep(timeStep: number): void;
  22467. getTimeStep(): number;
  22468. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22469. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22470. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22471. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22472. removePhysicsBody(impostor: PhysicsImpostor): void;
  22473. generateJoint(joint: PhysicsImpostorJoint): void;
  22474. removeJoint(joint: PhysicsImpostorJoint): void;
  22475. isSupported(): boolean;
  22476. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22477. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22478. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22479. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22480. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22481. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22482. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22483. getBodyMass(impostor: PhysicsImpostor): number;
  22484. getBodyFriction(impostor: PhysicsImpostor): number;
  22485. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22486. getBodyRestitution(impostor: PhysicsImpostor): number;
  22487. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22488. getBodyPressure?(impostor: PhysicsImpostor): number;
  22489. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22490. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22491. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22492. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22493. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22494. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22495. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22496. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22497. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22498. sleepBody(impostor: PhysicsImpostor): void;
  22499. wakeUpBody(impostor: PhysicsImpostor): void;
  22500. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22501. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22502. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22503. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22504. getRadius(impostor: PhysicsImpostor): number;
  22505. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22506. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22507. dispose(): void;
  22508. }
  22509. /**
  22510. * Interface used to define a physics engine
  22511. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22512. */
  22513. export interface IPhysicsEngine {
  22514. /**
  22515. * Gets the gravity vector used by the simulation
  22516. */
  22517. gravity: Vector3;
  22518. /**
  22519. * Sets the gravity vector used by the simulation
  22520. * @param gravity defines the gravity vector to use
  22521. */
  22522. setGravity(gravity: Vector3): void;
  22523. /**
  22524. * Set the time step of the physics engine.
  22525. * Default is 1/60.
  22526. * To slow it down, enter 1/600 for example.
  22527. * To speed it up, 1/30
  22528. * @param newTimeStep the new timestep to apply to this world.
  22529. */
  22530. setTimeStep(newTimeStep: number): void;
  22531. /**
  22532. * Get the time step of the physics engine.
  22533. * @returns the current time step
  22534. */
  22535. getTimeStep(): number;
  22536. /**
  22537. * Release all resources
  22538. */
  22539. dispose(): void;
  22540. /**
  22541. * Gets the name of the current physics plugin
  22542. * @returns the name of the plugin
  22543. */
  22544. getPhysicsPluginName(): string;
  22545. /**
  22546. * Adding a new impostor for the impostor tracking.
  22547. * This will be done by the impostor itself.
  22548. * @param impostor the impostor to add
  22549. */
  22550. addImpostor(impostor: PhysicsImpostor): void;
  22551. /**
  22552. * Remove an impostor from the engine.
  22553. * This impostor and its mesh will not longer be updated by the physics engine.
  22554. * @param impostor the impostor to remove
  22555. */
  22556. removeImpostor(impostor: PhysicsImpostor): void;
  22557. /**
  22558. * Add a joint to the physics engine
  22559. * @param mainImpostor defines the main impostor to which the joint is added.
  22560. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22561. * @param joint defines the joint that will connect both impostors.
  22562. */
  22563. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22564. /**
  22565. * Removes a joint from the simulation
  22566. * @param mainImpostor defines the impostor used with the joint
  22567. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22568. * @param joint defines the joint to remove
  22569. */
  22570. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22571. /**
  22572. * Gets the current plugin used to run the simulation
  22573. * @returns current plugin
  22574. */
  22575. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22576. /**
  22577. * Gets the list of physic impostors
  22578. * @returns an array of PhysicsImpostor
  22579. */
  22580. getImpostors(): Array<PhysicsImpostor>;
  22581. /**
  22582. * Gets the impostor for a physics enabled object
  22583. * @param object defines the object impersonated by the impostor
  22584. * @returns the PhysicsImpostor or null if not found
  22585. */
  22586. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22587. /**
  22588. * Gets the impostor for a physics body object
  22589. * @param body defines physics body used by the impostor
  22590. * @returns the PhysicsImpostor or null if not found
  22591. */
  22592. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22593. /**
  22594. * Does a raycast in the physics world
  22595. * @param from when should the ray start?
  22596. * @param to when should the ray end?
  22597. * @returns PhysicsRaycastResult
  22598. */
  22599. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22600. /**
  22601. * Called by the scene. No need to call it.
  22602. * @param delta defines the timespam between frames
  22603. */
  22604. _step(delta: number): void;
  22605. }
  22606. }
  22607. declare module BABYLON {
  22608. /**
  22609. * The interface for the physics imposter parameters
  22610. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22611. */
  22612. export interface PhysicsImpostorParameters {
  22613. /**
  22614. * The mass of the physics imposter
  22615. */
  22616. mass: number;
  22617. /**
  22618. * The friction of the physics imposter
  22619. */
  22620. friction?: number;
  22621. /**
  22622. * The coefficient of restitution of the physics imposter
  22623. */
  22624. restitution?: number;
  22625. /**
  22626. * The native options of the physics imposter
  22627. */
  22628. nativeOptions?: any;
  22629. /**
  22630. * Specifies if the parent should be ignored
  22631. */
  22632. ignoreParent?: boolean;
  22633. /**
  22634. * Specifies if bi-directional transformations should be disabled
  22635. */
  22636. disableBidirectionalTransformation?: boolean;
  22637. /**
  22638. * The pressure inside the physics imposter, soft object only
  22639. */
  22640. pressure?: number;
  22641. /**
  22642. * The stiffness the physics imposter, soft object only
  22643. */
  22644. stiffness?: number;
  22645. /**
  22646. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22647. */
  22648. velocityIterations?: number;
  22649. /**
  22650. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22651. */
  22652. positionIterations?: number;
  22653. /**
  22654. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22655. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22656. * Add to fix multiple points
  22657. */
  22658. fixedPoints?: number;
  22659. /**
  22660. * The collision margin around a soft object
  22661. */
  22662. margin?: number;
  22663. /**
  22664. * The collision margin around a soft object
  22665. */
  22666. damping?: number;
  22667. /**
  22668. * The path for a rope based on an extrusion
  22669. */
  22670. path?: any;
  22671. /**
  22672. * The shape of an extrusion used for a rope based on an extrusion
  22673. */
  22674. shape?: any;
  22675. }
  22676. /**
  22677. * Interface for a physics-enabled object
  22678. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22679. */
  22680. export interface IPhysicsEnabledObject {
  22681. /**
  22682. * The position of the physics-enabled object
  22683. */
  22684. position: Vector3;
  22685. /**
  22686. * The rotation of the physics-enabled object
  22687. */
  22688. rotationQuaternion: Nullable<Quaternion>;
  22689. /**
  22690. * The scale of the physics-enabled object
  22691. */
  22692. scaling: Vector3;
  22693. /**
  22694. * The rotation of the physics-enabled object
  22695. */
  22696. rotation?: Vector3;
  22697. /**
  22698. * The parent of the physics-enabled object
  22699. */
  22700. parent?: any;
  22701. /**
  22702. * The bounding info of the physics-enabled object
  22703. * @returns The bounding info of the physics-enabled object
  22704. */
  22705. getBoundingInfo(): BoundingInfo;
  22706. /**
  22707. * Computes the world matrix
  22708. * @param force Specifies if the world matrix should be computed by force
  22709. * @returns A world matrix
  22710. */
  22711. computeWorldMatrix(force: boolean): Matrix;
  22712. /**
  22713. * Gets the world matrix
  22714. * @returns A world matrix
  22715. */
  22716. getWorldMatrix?(): Matrix;
  22717. /**
  22718. * Gets the child meshes
  22719. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22720. * @returns An array of abstract meshes
  22721. */
  22722. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22723. /**
  22724. * Gets the vertex data
  22725. * @param kind The type of vertex data
  22726. * @returns A nullable array of numbers, or a float32 array
  22727. */
  22728. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22729. /**
  22730. * Gets the indices from the mesh
  22731. * @returns A nullable array of index arrays
  22732. */
  22733. getIndices?(): Nullable<IndicesArray>;
  22734. /**
  22735. * Gets the scene from the mesh
  22736. * @returns the indices array or null
  22737. */
  22738. getScene?(): Scene;
  22739. /**
  22740. * Gets the absolute position from the mesh
  22741. * @returns the absolute position
  22742. */
  22743. getAbsolutePosition(): Vector3;
  22744. /**
  22745. * Gets the absolute pivot point from the mesh
  22746. * @returns the absolute pivot point
  22747. */
  22748. getAbsolutePivotPoint(): Vector3;
  22749. /**
  22750. * Rotates the mesh
  22751. * @param axis The axis of rotation
  22752. * @param amount The amount of rotation
  22753. * @param space The space of the rotation
  22754. * @returns The rotation transform node
  22755. */
  22756. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22757. /**
  22758. * Translates the mesh
  22759. * @param axis The axis of translation
  22760. * @param distance The distance of translation
  22761. * @param space The space of the translation
  22762. * @returns The transform node
  22763. */
  22764. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22765. /**
  22766. * Sets the absolute position of the mesh
  22767. * @param absolutePosition The absolute position of the mesh
  22768. * @returns The transform node
  22769. */
  22770. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22771. /**
  22772. * Gets the class name of the mesh
  22773. * @returns The class name
  22774. */
  22775. getClassName(): string;
  22776. }
  22777. /**
  22778. * Represents a physics imposter
  22779. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22780. */
  22781. export class PhysicsImpostor {
  22782. /**
  22783. * The physics-enabled object used as the physics imposter
  22784. */
  22785. object: IPhysicsEnabledObject;
  22786. /**
  22787. * The type of the physics imposter
  22788. */
  22789. type: number;
  22790. private _options;
  22791. private _scene?;
  22792. /**
  22793. * The default object size of the imposter
  22794. */
  22795. static DEFAULT_OBJECT_SIZE: Vector3;
  22796. /**
  22797. * The identity quaternion of the imposter
  22798. */
  22799. static IDENTITY_QUATERNION: Quaternion;
  22800. /** @hidden */
  22801. _pluginData: any;
  22802. private _physicsEngine;
  22803. private _physicsBody;
  22804. private _bodyUpdateRequired;
  22805. private _onBeforePhysicsStepCallbacks;
  22806. private _onAfterPhysicsStepCallbacks;
  22807. /** @hidden */
  22808. _onPhysicsCollideCallbacks: Array<{
  22809. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  22810. otherImpostors: Array<PhysicsImpostor>;
  22811. }>;
  22812. private _deltaPosition;
  22813. private _deltaRotation;
  22814. private _deltaRotationConjugated;
  22815. /** @hidden */
  22816. _isFromLine: boolean;
  22817. private _parent;
  22818. private _isDisposed;
  22819. private static _tmpVecs;
  22820. private static _tmpQuat;
  22821. /**
  22822. * Specifies if the physics imposter is disposed
  22823. */
  22824. readonly isDisposed: boolean;
  22825. /**
  22826. * Gets the mass of the physics imposter
  22827. */
  22828. mass: number;
  22829. /**
  22830. * Gets the coefficient of friction
  22831. */
  22832. /**
  22833. * Sets the coefficient of friction
  22834. */
  22835. friction: number;
  22836. /**
  22837. * Gets the coefficient of restitution
  22838. */
  22839. /**
  22840. * Sets the coefficient of restitution
  22841. */
  22842. restitution: number;
  22843. /**
  22844. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  22845. */
  22846. /**
  22847. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  22848. */
  22849. pressure: number;
  22850. /**
  22851. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22852. */
  22853. /**
  22854. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22855. */
  22856. stiffness: number;
  22857. /**
  22858. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22859. */
  22860. /**
  22861. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22862. */
  22863. velocityIterations: number;
  22864. /**
  22865. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22866. */
  22867. /**
  22868. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22869. */
  22870. positionIterations: number;
  22871. /**
  22872. * The unique id of the physics imposter
  22873. * set by the physics engine when adding this impostor to the array
  22874. */
  22875. uniqueId: number;
  22876. /**
  22877. * @hidden
  22878. */
  22879. soft: boolean;
  22880. /**
  22881. * @hidden
  22882. */
  22883. segments: number;
  22884. private _joints;
  22885. /**
  22886. * Initializes the physics imposter
  22887. * @param object The physics-enabled object used as the physics imposter
  22888. * @param type The type of the physics imposter
  22889. * @param _options The options for the physics imposter
  22890. * @param _scene The Babylon scene
  22891. */
  22892. constructor(
  22893. /**
  22894. * The physics-enabled object used as the physics imposter
  22895. */
  22896. object: IPhysicsEnabledObject,
  22897. /**
  22898. * The type of the physics imposter
  22899. */
  22900. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  22901. /**
  22902. * This function will completly initialize this impostor.
  22903. * It will create a new body - but only if this mesh has no parent.
  22904. * If it has, this impostor will not be used other than to define the impostor
  22905. * of the child mesh.
  22906. * @hidden
  22907. */
  22908. _init(): void;
  22909. private _getPhysicsParent;
  22910. /**
  22911. * Should a new body be generated.
  22912. * @returns boolean specifying if body initialization is required
  22913. */
  22914. isBodyInitRequired(): boolean;
  22915. /**
  22916. * Sets the updated scaling
  22917. * @param updated Specifies if the scaling is updated
  22918. */
  22919. setScalingUpdated(): void;
  22920. /**
  22921. * Force a regeneration of this or the parent's impostor's body.
  22922. * Use under cautious - This will remove all joints already implemented.
  22923. */
  22924. forceUpdate(): void;
  22925. /**
  22926. * Gets the body that holds this impostor. Either its own, or its parent.
  22927. */
  22928. /**
  22929. * Set the physics body. Used mainly by the physics engine/plugin
  22930. */
  22931. physicsBody: any;
  22932. /**
  22933. * Get the parent of the physics imposter
  22934. * @returns Physics imposter or null
  22935. */
  22936. /**
  22937. * Sets the parent of the physics imposter
  22938. */
  22939. parent: Nullable<PhysicsImpostor>;
  22940. /**
  22941. * Resets the update flags
  22942. */
  22943. resetUpdateFlags(): void;
  22944. /**
  22945. * Gets the object extend size
  22946. * @returns the object extend size
  22947. */
  22948. getObjectExtendSize(): Vector3;
  22949. /**
  22950. * Gets the object center
  22951. * @returns The object center
  22952. */
  22953. getObjectCenter(): Vector3;
  22954. /**
  22955. * Get a specific parametes from the options parameter
  22956. * @param paramName The object parameter name
  22957. * @returns The object parameter
  22958. */
  22959. getParam(paramName: string): any;
  22960. /**
  22961. * Sets a specific parameter in the options given to the physics plugin
  22962. * @param paramName The parameter name
  22963. * @param value The value of the parameter
  22964. */
  22965. setParam(paramName: string, value: number): void;
  22966. /**
  22967. * Specifically change the body's mass option. Won't recreate the physics body object
  22968. * @param mass The mass of the physics imposter
  22969. */
  22970. setMass(mass: number): void;
  22971. /**
  22972. * Gets the linear velocity
  22973. * @returns linear velocity or null
  22974. */
  22975. getLinearVelocity(): Nullable<Vector3>;
  22976. /**
  22977. * Sets the linear velocity
  22978. * @param velocity linear velocity or null
  22979. */
  22980. setLinearVelocity(velocity: Nullable<Vector3>): void;
  22981. /**
  22982. * Gets the angular velocity
  22983. * @returns angular velocity or null
  22984. */
  22985. getAngularVelocity(): Nullable<Vector3>;
  22986. /**
  22987. * Sets the angular velocity
  22988. * @param velocity The velocity or null
  22989. */
  22990. setAngularVelocity(velocity: Nullable<Vector3>): void;
  22991. /**
  22992. * Execute a function with the physics plugin native code
  22993. * Provide a function the will have two variables - the world object and the physics body object
  22994. * @param func The function to execute with the physics plugin native code
  22995. */
  22996. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  22997. /**
  22998. * Register a function that will be executed before the physics world is stepping forward
  22999. * @param func The function to execute before the physics world is stepped forward
  23000. */
  23001. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23002. /**
  23003. * Unregister a function that will be executed before the physics world is stepping forward
  23004. * @param func The function to execute before the physics world is stepped forward
  23005. */
  23006. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23007. /**
  23008. * Register a function that will be executed after the physics step
  23009. * @param func The function to execute after physics step
  23010. */
  23011. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23012. /**
  23013. * Unregisters a function that will be executed after the physics step
  23014. * @param func The function to execute after physics step
  23015. */
  23016. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23017. /**
  23018. * register a function that will be executed when this impostor collides against a different body
  23019. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23020. * @param func Callback that is executed on collision
  23021. */
  23022. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23023. /**
  23024. * Unregisters the physics imposter on contact
  23025. * @param collideAgainst The physics object to collide against
  23026. * @param func Callback to execute on collision
  23027. */
  23028. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23029. private _tmpQuat;
  23030. private _tmpQuat2;
  23031. /**
  23032. * Get the parent rotation
  23033. * @returns The parent rotation
  23034. */
  23035. getParentsRotation(): Quaternion;
  23036. /**
  23037. * this function is executed by the physics engine.
  23038. */
  23039. beforeStep: () => void;
  23040. /**
  23041. * this function is executed by the physics engine
  23042. */
  23043. afterStep: () => void;
  23044. /**
  23045. * Legacy collision detection event support
  23046. */
  23047. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23048. /**
  23049. * event and body object due to cannon's event-based architecture.
  23050. */
  23051. onCollide: (e: {
  23052. body: any;
  23053. }) => void;
  23054. /**
  23055. * Apply a force
  23056. * @param force The force to apply
  23057. * @param contactPoint The contact point for the force
  23058. * @returns The physics imposter
  23059. */
  23060. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23061. /**
  23062. * Apply an impulse
  23063. * @param force The impulse force
  23064. * @param contactPoint The contact point for the impulse force
  23065. * @returns The physics imposter
  23066. */
  23067. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23068. /**
  23069. * A help function to create a joint
  23070. * @param otherImpostor A physics imposter used to create a joint
  23071. * @param jointType The type of joint
  23072. * @param jointData The data for the joint
  23073. * @returns The physics imposter
  23074. */
  23075. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23076. /**
  23077. * Add a joint to this impostor with a different impostor
  23078. * @param otherImpostor A physics imposter used to add a joint
  23079. * @param joint The joint to add
  23080. * @returns The physics imposter
  23081. */
  23082. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23083. /**
  23084. * Add an anchor to a cloth impostor
  23085. * @param otherImpostor rigid impostor to anchor to
  23086. * @param width ratio across width from 0 to 1
  23087. * @param height ratio up height from 0 to 1
  23088. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23089. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23090. * @returns impostor the soft imposter
  23091. */
  23092. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23093. /**
  23094. * Add a hook to a rope impostor
  23095. * @param otherImpostor rigid impostor to anchor to
  23096. * @param length ratio across rope from 0 to 1
  23097. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23098. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23099. * @returns impostor the rope imposter
  23100. */
  23101. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23102. /**
  23103. * Will keep this body still, in a sleep mode.
  23104. * @returns the physics imposter
  23105. */
  23106. sleep(): PhysicsImpostor;
  23107. /**
  23108. * Wake the body up.
  23109. * @returns The physics imposter
  23110. */
  23111. wakeUp(): PhysicsImpostor;
  23112. /**
  23113. * Clones the physics imposter
  23114. * @param newObject The physics imposter clones to this physics-enabled object
  23115. * @returns A nullable physics imposter
  23116. */
  23117. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23118. /**
  23119. * Disposes the physics imposter
  23120. */
  23121. dispose(): void;
  23122. /**
  23123. * Sets the delta position
  23124. * @param position The delta position amount
  23125. */
  23126. setDeltaPosition(position: Vector3): void;
  23127. /**
  23128. * Sets the delta rotation
  23129. * @param rotation The delta rotation amount
  23130. */
  23131. setDeltaRotation(rotation: Quaternion): void;
  23132. /**
  23133. * Gets the box size of the physics imposter and stores the result in the input parameter
  23134. * @param result Stores the box size
  23135. * @returns The physics imposter
  23136. */
  23137. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23138. /**
  23139. * Gets the radius of the physics imposter
  23140. * @returns Radius of the physics imposter
  23141. */
  23142. getRadius(): number;
  23143. /**
  23144. * Sync a bone with this impostor
  23145. * @param bone The bone to sync to the impostor.
  23146. * @param boneMesh The mesh that the bone is influencing.
  23147. * @param jointPivot The pivot of the joint / bone in local space.
  23148. * @param distToJoint Optional distance from the impostor to the joint.
  23149. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23150. */
  23151. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23152. /**
  23153. * Sync impostor to a bone
  23154. * @param bone The bone that the impostor will be synced to.
  23155. * @param boneMesh The mesh that the bone is influencing.
  23156. * @param jointPivot The pivot of the joint / bone in local space.
  23157. * @param distToJoint Optional distance from the impostor to the joint.
  23158. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23159. * @param boneAxis Optional vector3 axis the bone is aligned with
  23160. */
  23161. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23162. /**
  23163. * No-Imposter type
  23164. */
  23165. static NoImpostor: number;
  23166. /**
  23167. * Sphere-Imposter type
  23168. */
  23169. static SphereImpostor: number;
  23170. /**
  23171. * Box-Imposter type
  23172. */
  23173. static BoxImpostor: number;
  23174. /**
  23175. * Plane-Imposter type
  23176. */
  23177. static PlaneImpostor: number;
  23178. /**
  23179. * Mesh-imposter type
  23180. */
  23181. static MeshImpostor: number;
  23182. /**
  23183. * Capsule-Impostor type (Ammo.js plugin only)
  23184. */
  23185. static CapsuleImpostor: number;
  23186. /**
  23187. * Cylinder-Imposter type
  23188. */
  23189. static CylinderImpostor: number;
  23190. /**
  23191. * Particle-Imposter type
  23192. */
  23193. static ParticleImpostor: number;
  23194. /**
  23195. * Heightmap-Imposter type
  23196. */
  23197. static HeightmapImpostor: number;
  23198. /**
  23199. * ConvexHull-Impostor type (Ammo.js plugin only)
  23200. */
  23201. static ConvexHullImpostor: number;
  23202. /**
  23203. * Rope-Imposter type
  23204. */
  23205. static RopeImpostor: number;
  23206. /**
  23207. * Cloth-Imposter type
  23208. */
  23209. static ClothImpostor: number;
  23210. /**
  23211. * Softbody-Imposter type
  23212. */
  23213. static SoftbodyImpostor: number;
  23214. }
  23215. }
  23216. declare module BABYLON {
  23217. /**
  23218. * @hidden
  23219. **/
  23220. export class _CreationDataStorage {
  23221. closePath?: boolean;
  23222. closeArray?: boolean;
  23223. idx: number[];
  23224. dashSize: number;
  23225. gapSize: number;
  23226. path3D: Path3D;
  23227. pathArray: Vector3[][];
  23228. arc: number;
  23229. radius: number;
  23230. cap: number;
  23231. tessellation: number;
  23232. }
  23233. /**
  23234. * @hidden
  23235. **/
  23236. class _InstanceDataStorage {
  23237. visibleInstances: any;
  23238. batchCache: _InstancesBatch;
  23239. instancesBufferSize: number;
  23240. instancesBuffer: Nullable<Buffer>;
  23241. instancesData: Float32Array;
  23242. overridenInstanceCount: number;
  23243. isFrozen: boolean;
  23244. previousBatch: Nullable<_InstancesBatch>;
  23245. hardwareInstancedRendering: boolean;
  23246. sideOrientation: number;
  23247. }
  23248. /**
  23249. * @hidden
  23250. **/
  23251. export class _InstancesBatch {
  23252. mustReturn: boolean;
  23253. visibleInstances: Nullable<InstancedMesh[]>[];
  23254. renderSelf: boolean[];
  23255. hardwareInstancedRendering: boolean[];
  23256. }
  23257. /**
  23258. * Class used to represent renderable models
  23259. */
  23260. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23261. /**
  23262. * Mesh side orientation : usually the external or front surface
  23263. */
  23264. static readonly FRONTSIDE: number;
  23265. /**
  23266. * Mesh side orientation : usually the internal or back surface
  23267. */
  23268. static readonly BACKSIDE: number;
  23269. /**
  23270. * Mesh side orientation : both internal and external or front and back surfaces
  23271. */
  23272. static readonly DOUBLESIDE: number;
  23273. /**
  23274. * Mesh side orientation : by default, `FRONTSIDE`
  23275. */
  23276. static readonly DEFAULTSIDE: number;
  23277. /**
  23278. * Mesh cap setting : no cap
  23279. */
  23280. static readonly NO_CAP: number;
  23281. /**
  23282. * Mesh cap setting : one cap at the beginning of the mesh
  23283. */
  23284. static readonly CAP_START: number;
  23285. /**
  23286. * Mesh cap setting : one cap at the end of the mesh
  23287. */
  23288. static readonly CAP_END: number;
  23289. /**
  23290. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23291. */
  23292. static readonly CAP_ALL: number;
  23293. /**
  23294. * Mesh pattern setting : no flip or rotate
  23295. */
  23296. static readonly NO_FLIP: number;
  23297. /**
  23298. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23299. */
  23300. static readonly FLIP_TILE: number;
  23301. /**
  23302. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23303. */
  23304. static readonly ROTATE_TILE: number;
  23305. /**
  23306. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23307. */
  23308. static readonly FLIP_ROW: number;
  23309. /**
  23310. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23311. */
  23312. static readonly ROTATE_ROW: number;
  23313. /**
  23314. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23315. */
  23316. static readonly FLIP_N_ROTATE_TILE: number;
  23317. /**
  23318. * Mesh pattern setting : rotate pattern and rotate
  23319. */
  23320. static readonly FLIP_N_ROTATE_ROW: number;
  23321. /**
  23322. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23323. */
  23324. static readonly CENTER: number;
  23325. /**
  23326. * Mesh tile positioning : part tiles on left
  23327. */
  23328. static readonly LEFT: number;
  23329. /**
  23330. * Mesh tile positioning : part tiles on right
  23331. */
  23332. static readonly RIGHT: number;
  23333. /**
  23334. * Mesh tile positioning : part tiles on top
  23335. */
  23336. static readonly TOP: number;
  23337. /**
  23338. * Mesh tile positioning : part tiles on bottom
  23339. */
  23340. static readonly BOTTOM: number;
  23341. /**
  23342. * Gets the default side orientation.
  23343. * @param orientation the orientation to value to attempt to get
  23344. * @returns the default orientation
  23345. * @hidden
  23346. */
  23347. static _GetDefaultSideOrientation(orientation?: number): number;
  23348. private _internalMeshDataInfo;
  23349. /**
  23350. * An event triggered before rendering the mesh
  23351. */
  23352. readonly onBeforeRenderObservable: Observable<Mesh>;
  23353. /**
  23354. * An event triggered before binding the mesh
  23355. */
  23356. readonly onBeforeBindObservable: Observable<Mesh>;
  23357. /**
  23358. * An event triggered after rendering the mesh
  23359. */
  23360. readonly onAfterRenderObservable: Observable<Mesh>;
  23361. /**
  23362. * An event triggered before drawing the mesh
  23363. */
  23364. readonly onBeforeDrawObservable: Observable<Mesh>;
  23365. private _onBeforeDrawObserver;
  23366. /**
  23367. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23368. */
  23369. onBeforeDraw: () => void;
  23370. readonly hasInstances: boolean;
  23371. /**
  23372. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23373. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23374. */
  23375. delayLoadState: number;
  23376. /**
  23377. * Gets the list of instances created from this mesh
  23378. * it is not supposed to be modified manually.
  23379. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23380. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23381. */
  23382. instances: InstancedMesh[];
  23383. /**
  23384. * Gets the file containing delay loading data for this mesh
  23385. */
  23386. delayLoadingFile: string;
  23387. /** @hidden */
  23388. _binaryInfo: any;
  23389. /**
  23390. * User defined function used to change how LOD level selection is done
  23391. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23392. */
  23393. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23394. /**
  23395. * Gets or sets the morph target manager
  23396. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23397. */
  23398. morphTargetManager: Nullable<MorphTargetManager>;
  23399. /** @hidden */
  23400. _creationDataStorage: Nullable<_CreationDataStorage>;
  23401. /** @hidden */
  23402. _geometry: Nullable<Geometry>;
  23403. /** @hidden */
  23404. _delayInfo: Array<string>;
  23405. /** @hidden */
  23406. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23407. /** @hidden */
  23408. _instanceDataStorage: _InstanceDataStorage;
  23409. private _effectiveMaterial;
  23410. /** @hidden */
  23411. _shouldGenerateFlatShading: boolean;
  23412. /** @hidden */
  23413. _originalBuilderSideOrientation: number;
  23414. /**
  23415. * Use this property to change the original side orientation defined at construction time
  23416. */
  23417. overrideMaterialSideOrientation: Nullable<number>;
  23418. /**
  23419. * Gets the source mesh (the one used to clone this one from)
  23420. */
  23421. readonly source: Nullable<Mesh>;
  23422. /**
  23423. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23424. */
  23425. isUnIndexed: boolean;
  23426. /**
  23427. * @constructor
  23428. * @param name The value used by scene.getMeshByName() to do a lookup.
  23429. * @param scene The scene to add this mesh to.
  23430. * @param parent The parent of this mesh, if it has one
  23431. * @param source An optional Mesh from which geometry is shared, cloned.
  23432. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23433. * When false, achieved by calling a clone(), also passing False.
  23434. * This will make creation of children, recursive.
  23435. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23436. */
  23437. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23438. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23439. /**
  23440. * Gets the class name
  23441. * @returns the string "Mesh".
  23442. */
  23443. getClassName(): string;
  23444. /** @hidden */
  23445. readonly _isMesh: boolean;
  23446. /**
  23447. * Returns a description of this mesh
  23448. * @param fullDetails define if full details about this mesh must be used
  23449. * @returns a descriptive string representing this mesh
  23450. */
  23451. toString(fullDetails?: boolean): string;
  23452. /** @hidden */
  23453. _unBindEffect(): void;
  23454. /**
  23455. * Gets a boolean indicating if this mesh has LOD
  23456. */
  23457. readonly hasLODLevels: boolean;
  23458. /**
  23459. * Gets the list of MeshLODLevel associated with the current mesh
  23460. * @returns an array of MeshLODLevel
  23461. */
  23462. getLODLevels(): MeshLODLevel[];
  23463. private _sortLODLevels;
  23464. /**
  23465. * Add a mesh as LOD level triggered at the given distance.
  23466. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23467. * @param distance The distance from the center of the object to show this level
  23468. * @param mesh The mesh to be added as LOD level (can be null)
  23469. * @return This mesh (for chaining)
  23470. */
  23471. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23472. /**
  23473. * Returns the LOD level mesh at the passed distance or null if not found.
  23474. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23475. * @param distance The distance from the center of the object to show this level
  23476. * @returns a Mesh or `null`
  23477. */
  23478. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23479. /**
  23480. * Remove a mesh from the LOD array
  23481. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23482. * @param mesh defines the mesh to be removed
  23483. * @return This mesh (for chaining)
  23484. */
  23485. removeLODLevel(mesh: Mesh): Mesh;
  23486. /**
  23487. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23488. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23489. * @param camera defines the camera to use to compute distance
  23490. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23491. * @return This mesh (for chaining)
  23492. */
  23493. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23494. /**
  23495. * Gets the mesh internal Geometry object
  23496. */
  23497. readonly geometry: Nullable<Geometry>;
  23498. /**
  23499. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23500. * @returns the total number of vertices
  23501. */
  23502. getTotalVertices(): number;
  23503. /**
  23504. * Returns the content of an associated vertex buffer
  23505. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23506. * - VertexBuffer.PositionKind
  23507. * - VertexBuffer.UVKind
  23508. * - VertexBuffer.UV2Kind
  23509. * - VertexBuffer.UV3Kind
  23510. * - VertexBuffer.UV4Kind
  23511. * - VertexBuffer.UV5Kind
  23512. * - VertexBuffer.UV6Kind
  23513. * - VertexBuffer.ColorKind
  23514. * - VertexBuffer.MatricesIndicesKind
  23515. * - VertexBuffer.MatricesIndicesExtraKind
  23516. * - VertexBuffer.MatricesWeightsKind
  23517. * - VertexBuffer.MatricesWeightsExtraKind
  23518. * @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
  23519. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23520. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23521. */
  23522. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23523. /**
  23524. * Returns the mesh VertexBuffer object from the requested `kind`
  23525. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23526. * - VertexBuffer.PositionKind
  23527. * - VertexBuffer.NormalKind
  23528. * - VertexBuffer.UVKind
  23529. * - VertexBuffer.UV2Kind
  23530. * - VertexBuffer.UV3Kind
  23531. * - VertexBuffer.UV4Kind
  23532. * - VertexBuffer.UV5Kind
  23533. * - VertexBuffer.UV6Kind
  23534. * - VertexBuffer.ColorKind
  23535. * - VertexBuffer.MatricesIndicesKind
  23536. * - VertexBuffer.MatricesIndicesExtraKind
  23537. * - VertexBuffer.MatricesWeightsKind
  23538. * - VertexBuffer.MatricesWeightsExtraKind
  23539. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23540. */
  23541. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23542. /**
  23543. * Tests if a specific vertex buffer is associated with this mesh
  23544. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23545. * - VertexBuffer.PositionKind
  23546. * - VertexBuffer.NormalKind
  23547. * - VertexBuffer.UVKind
  23548. * - VertexBuffer.UV2Kind
  23549. * - VertexBuffer.UV3Kind
  23550. * - VertexBuffer.UV4Kind
  23551. * - VertexBuffer.UV5Kind
  23552. * - VertexBuffer.UV6Kind
  23553. * - VertexBuffer.ColorKind
  23554. * - VertexBuffer.MatricesIndicesKind
  23555. * - VertexBuffer.MatricesIndicesExtraKind
  23556. * - VertexBuffer.MatricesWeightsKind
  23557. * - VertexBuffer.MatricesWeightsExtraKind
  23558. * @returns a boolean
  23559. */
  23560. isVerticesDataPresent(kind: string): boolean;
  23561. /**
  23562. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23563. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23564. * - VertexBuffer.PositionKind
  23565. * - VertexBuffer.UVKind
  23566. * - VertexBuffer.UV2Kind
  23567. * - VertexBuffer.UV3Kind
  23568. * - VertexBuffer.UV4Kind
  23569. * - VertexBuffer.UV5Kind
  23570. * - VertexBuffer.UV6Kind
  23571. * - VertexBuffer.ColorKind
  23572. * - VertexBuffer.MatricesIndicesKind
  23573. * - VertexBuffer.MatricesIndicesExtraKind
  23574. * - VertexBuffer.MatricesWeightsKind
  23575. * - VertexBuffer.MatricesWeightsExtraKind
  23576. * @returns a boolean
  23577. */
  23578. isVertexBufferUpdatable(kind: string): boolean;
  23579. /**
  23580. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23581. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23582. * - VertexBuffer.PositionKind
  23583. * - VertexBuffer.NormalKind
  23584. * - VertexBuffer.UVKind
  23585. * - VertexBuffer.UV2Kind
  23586. * - VertexBuffer.UV3Kind
  23587. * - VertexBuffer.UV4Kind
  23588. * - VertexBuffer.UV5Kind
  23589. * - VertexBuffer.UV6Kind
  23590. * - VertexBuffer.ColorKind
  23591. * - VertexBuffer.MatricesIndicesKind
  23592. * - VertexBuffer.MatricesIndicesExtraKind
  23593. * - VertexBuffer.MatricesWeightsKind
  23594. * - VertexBuffer.MatricesWeightsExtraKind
  23595. * @returns an array of strings
  23596. */
  23597. getVerticesDataKinds(): string[];
  23598. /**
  23599. * Returns a positive integer : the total number of indices in this mesh geometry.
  23600. * @returns the numner of indices or zero if the mesh has no geometry.
  23601. */
  23602. getTotalIndices(): number;
  23603. /**
  23604. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23605. * @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.
  23606. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23607. * @returns the indices array or an empty array if the mesh has no geometry
  23608. */
  23609. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23610. readonly isBlocked: boolean;
  23611. /**
  23612. * Determine if the current mesh is ready to be rendered
  23613. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23614. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23615. * @returns true if all associated assets are ready (material, textures, shaders)
  23616. */
  23617. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23618. /**
  23619. * 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.
  23620. */
  23621. readonly areNormalsFrozen: boolean;
  23622. /**
  23623. * 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.
  23624. * @returns the current mesh
  23625. */
  23626. freezeNormals(): Mesh;
  23627. /**
  23628. * 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
  23629. * @returns the current mesh
  23630. */
  23631. unfreezeNormals(): Mesh;
  23632. /**
  23633. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23634. */
  23635. overridenInstanceCount: number;
  23636. /** @hidden */
  23637. _preActivate(): Mesh;
  23638. /** @hidden */
  23639. _preActivateForIntermediateRendering(renderId: number): Mesh;
  23640. /** @hidden */
  23641. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23642. /**
  23643. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23644. * This means the mesh underlying bounding box and sphere are recomputed.
  23645. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23646. * @returns the current mesh
  23647. */
  23648. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23649. /** @hidden */
  23650. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23651. /**
  23652. * This function will subdivide the mesh into multiple submeshes
  23653. * @param count defines the expected number of submeshes
  23654. */
  23655. subdivide(count: number): void;
  23656. /**
  23657. * Copy a FloatArray into a specific associated vertex buffer
  23658. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23659. * - VertexBuffer.PositionKind
  23660. * - VertexBuffer.UVKind
  23661. * - VertexBuffer.UV2Kind
  23662. * - VertexBuffer.UV3Kind
  23663. * - VertexBuffer.UV4Kind
  23664. * - VertexBuffer.UV5Kind
  23665. * - VertexBuffer.UV6Kind
  23666. * - VertexBuffer.ColorKind
  23667. * - VertexBuffer.MatricesIndicesKind
  23668. * - VertexBuffer.MatricesIndicesExtraKind
  23669. * - VertexBuffer.MatricesWeightsKind
  23670. * - VertexBuffer.MatricesWeightsExtraKind
  23671. * @param data defines the data source
  23672. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23673. * @param stride defines the data stride size (can be null)
  23674. * @returns the current mesh
  23675. */
  23676. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23677. /**
  23678. * Flags an associated vertex buffer as updatable
  23679. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23680. * - VertexBuffer.PositionKind
  23681. * - VertexBuffer.UVKind
  23682. * - VertexBuffer.UV2Kind
  23683. * - VertexBuffer.UV3Kind
  23684. * - VertexBuffer.UV4Kind
  23685. * - VertexBuffer.UV5Kind
  23686. * - VertexBuffer.UV6Kind
  23687. * - VertexBuffer.ColorKind
  23688. * - VertexBuffer.MatricesIndicesKind
  23689. * - VertexBuffer.MatricesIndicesExtraKind
  23690. * - VertexBuffer.MatricesWeightsKind
  23691. * - VertexBuffer.MatricesWeightsExtraKind
  23692. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23693. */
  23694. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23695. /**
  23696. * Sets the mesh global Vertex Buffer
  23697. * @param buffer defines the buffer to use
  23698. * @returns the current mesh
  23699. */
  23700. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23701. /**
  23702. * Update a specific associated vertex buffer
  23703. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23704. * - VertexBuffer.PositionKind
  23705. * - VertexBuffer.UVKind
  23706. * - VertexBuffer.UV2Kind
  23707. * - VertexBuffer.UV3Kind
  23708. * - VertexBuffer.UV4Kind
  23709. * - VertexBuffer.UV5Kind
  23710. * - VertexBuffer.UV6Kind
  23711. * - VertexBuffer.ColorKind
  23712. * - VertexBuffer.MatricesIndicesKind
  23713. * - VertexBuffer.MatricesIndicesExtraKind
  23714. * - VertexBuffer.MatricesWeightsKind
  23715. * - VertexBuffer.MatricesWeightsExtraKind
  23716. * @param data defines the data source
  23717. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23718. * @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)
  23719. * @returns the current mesh
  23720. */
  23721. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23722. /**
  23723. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23724. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23725. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23726. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23727. * @returns the current mesh
  23728. */
  23729. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23730. /**
  23731. * Creates a un-shared specific occurence of the geometry for the mesh.
  23732. * @returns the current mesh
  23733. */
  23734. makeGeometryUnique(): Mesh;
  23735. /**
  23736. * Set the index buffer of this mesh
  23737. * @param indices defines the source data
  23738. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23739. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23740. * @returns the current mesh
  23741. */
  23742. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  23743. /**
  23744. * Update the current index buffer
  23745. * @param indices defines the source data
  23746. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23747. * @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)
  23748. * @returns the current mesh
  23749. */
  23750. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  23751. /**
  23752. * Invert the geometry to move from a right handed system to a left handed one.
  23753. * @returns the current mesh
  23754. */
  23755. toLeftHanded(): Mesh;
  23756. /** @hidden */
  23757. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23758. /** @hidden */
  23759. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23760. /**
  23761. * Registers for this mesh a javascript function called just before the rendering process
  23762. * @param func defines the function to call before rendering this mesh
  23763. * @returns the current mesh
  23764. */
  23765. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23766. /**
  23767. * Disposes a previously registered javascript function called before the rendering
  23768. * @param func defines the function to remove
  23769. * @returns the current mesh
  23770. */
  23771. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23772. /**
  23773. * Registers for this mesh a javascript function called just after the rendering is complete
  23774. * @param func defines the function to call after rendering this mesh
  23775. * @returns the current mesh
  23776. */
  23777. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23778. /**
  23779. * Disposes a previously registered javascript function called after the rendering.
  23780. * @param func defines the function to remove
  23781. * @returns the current mesh
  23782. */
  23783. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23784. /** @hidden */
  23785. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23786. /** @hidden */
  23787. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23788. /** @hidden */
  23789. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23790. /** @hidden */
  23791. _rebuild(): void;
  23792. /** @hidden */
  23793. _freeze(): void;
  23794. /** @hidden */
  23795. _unFreeze(): void;
  23796. /**
  23797. * 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
  23798. * @param subMesh defines the subMesh to render
  23799. * @param enableAlphaMode defines if alpha mode can be changed
  23800. * @returns the current mesh
  23801. */
  23802. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  23803. private _onBeforeDraw;
  23804. /**
  23805. * Renormalize the mesh and patch it up if there are no weights
  23806. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  23807. * However in the case of zero weights then we set just a single influence to 1.
  23808. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  23809. */
  23810. cleanMatrixWeights(): void;
  23811. private normalizeSkinFourWeights;
  23812. private normalizeSkinWeightsAndExtra;
  23813. /**
  23814. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  23815. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  23816. * the user know there was an issue with importing the mesh
  23817. * @returns a validation object with skinned, valid and report string
  23818. */
  23819. validateSkinning(): {
  23820. skinned: boolean;
  23821. valid: boolean;
  23822. report: string;
  23823. };
  23824. /** @hidden */
  23825. _checkDelayState(): Mesh;
  23826. private _queueLoad;
  23827. /**
  23828. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23829. * A mesh is in the frustum if its bounding box intersects the frustum
  23830. * @param frustumPlanes defines the frustum to test
  23831. * @returns true if the mesh is in the frustum planes
  23832. */
  23833. isInFrustum(frustumPlanes: Plane[]): boolean;
  23834. /**
  23835. * Sets the mesh material by the material or multiMaterial `id` property
  23836. * @param id is a string identifying the material or the multiMaterial
  23837. * @returns the current mesh
  23838. */
  23839. setMaterialByID(id: string): Mesh;
  23840. /**
  23841. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  23842. * @returns an array of IAnimatable
  23843. */
  23844. getAnimatables(): IAnimatable[];
  23845. /**
  23846. * Modifies the mesh geometry according to the passed transformation matrix.
  23847. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  23848. * The mesh normals are modified using the same transformation.
  23849. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23850. * @param transform defines the transform matrix to use
  23851. * @see http://doc.babylonjs.com/resources/baking_transformations
  23852. * @returns the current mesh
  23853. */
  23854. bakeTransformIntoVertices(transform: Matrix): Mesh;
  23855. /**
  23856. * Modifies the mesh geometry according to its own current World Matrix.
  23857. * The mesh World Matrix is then reset.
  23858. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  23859. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23860. * @see http://doc.babylonjs.com/resources/baking_transformations
  23861. * @returns the current mesh
  23862. */
  23863. bakeCurrentTransformIntoVertices(): Mesh;
  23864. /** @hidden */
  23865. readonly _positions: Nullable<Vector3[]>;
  23866. /** @hidden */
  23867. _resetPointsArrayCache(): Mesh;
  23868. /** @hidden */
  23869. _generatePointsArray(): boolean;
  23870. /**
  23871. * Returns a new Mesh object generated from the current mesh properties.
  23872. * This method must not get confused with createInstance()
  23873. * @param name is a string, the name given to the new mesh
  23874. * @param newParent can be any Node object (default `null`)
  23875. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  23876. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  23877. * @returns a new mesh
  23878. */
  23879. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  23880. /**
  23881. * Releases resources associated with this mesh.
  23882. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23883. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23884. */
  23885. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23886. /**
  23887. * Modifies the mesh geometry according to a displacement map.
  23888. * 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.
  23889. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23890. * @param url is a string, the URL from the image file is to be downloaded.
  23891. * @param minHeight is the lower limit of the displacement.
  23892. * @param maxHeight is the upper limit of the displacement.
  23893. * @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.
  23894. * @param uvOffset is an optional vector2 used to offset UV.
  23895. * @param uvScale is an optional vector2 used to scale UV.
  23896. * @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.
  23897. * @returns the Mesh.
  23898. */
  23899. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23900. /**
  23901. * Modifies the mesh geometry according to a displacementMap buffer.
  23902. * 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.
  23903. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23904. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  23905. * @param heightMapWidth is the width of the buffer image.
  23906. * @param heightMapHeight is the height of the buffer image.
  23907. * @param minHeight is the lower limit of the displacement.
  23908. * @param maxHeight is the upper limit of the displacement.
  23909. * @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.
  23910. * @param uvOffset is an optional vector2 used to offset UV.
  23911. * @param uvScale is an optional vector2 used to scale UV.
  23912. * @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.
  23913. * @returns the Mesh.
  23914. */
  23915. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23916. /**
  23917. * Modify the mesh to get a flat shading rendering.
  23918. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  23919. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  23920. * @returns current mesh
  23921. */
  23922. convertToFlatShadedMesh(): Mesh;
  23923. /**
  23924. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  23925. * In other words, more vertices, no more indices and a single bigger VBO.
  23926. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  23927. * @returns current mesh
  23928. */
  23929. convertToUnIndexedMesh(): Mesh;
  23930. /**
  23931. * Inverses facet orientations.
  23932. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23933. * @param flipNormals will also inverts the normals
  23934. * @returns current mesh
  23935. */
  23936. flipFaces(flipNormals?: boolean): Mesh;
  23937. /**
  23938. * Increase the number of facets and hence vertices in a mesh
  23939. * Vertex normals are interpolated from existing vertex normals
  23940. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23941. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  23942. */
  23943. increaseVertices(numberPerEdge: number): void;
  23944. /**
  23945. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  23946. * This will undo any application of covertToFlatShadedMesh
  23947. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23948. */
  23949. forceSharedVertices(): void;
  23950. /** @hidden */
  23951. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  23952. /** @hidden */
  23953. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  23954. /**
  23955. * Creates a new InstancedMesh object from the mesh model.
  23956. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23957. * @param name defines the name of the new instance
  23958. * @returns a new InstancedMesh
  23959. */
  23960. createInstance(name: string): InstancedMesh;
  23961. /**
  23962. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  23963. * After this call, all the mesh instances have the same submeshes than the current mesh.
  23964. * @returns the current mesh
  23965. */
  23966. synchronizeInstances(): Mesh;
  23967. /**
  23968. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  23969. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  23970. * This should be used together with the simplification to avoid disappearing triangles.
  23971. * @param successCallback an optional success callback to be called after the optimization finished.
  23972. * @returns the current mesh
  23973. */
  23974. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  23975. /**
  23976. * Serialize current mesh
  23977. * @param serializationObject defines the object which will receive the serialization data
  23978. */
  23979. serialize(serializationObject: any): void;
  23980. /** @hidden */
  23981. _syncGeometryWithMorphTargetManager(): void;
  23982. /** @hidden */
  23983. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  23984. /**
  23985. * Returns a new Mesh object parsed from the source provided.
  23986. * @param parsedMesh is the source
  23987. * @param scene defines the hosting scene
  23988. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  23989. * @returns a new Mesh
  23990. */
  23991. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  23992. /**
  23993. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  23994. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23995. * @param name defines the name of the mesh to create
  23996. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  23997. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  23998. * @param closePath creates a seam between the first and the last points of each path of the path array
  23999. * @param offset is taken in account only if the `pathArray` is containing a single path
  24000. * @param scene defines the hosting scene
  24001. * @param updatable defines if the mesh must be flagged as updatable
  24002. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24003. * @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)
  24004. * @returns a new Mesh
  24005. */
  24006. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24007. /**
  24008. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24009. * @param name defines the name of the mesh to create
  24010. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24011. * @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
  24012. * @param scene defines the hosting scene
  24013. * @param updatable defines if the mesh must be flagged as updatable
  24014. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24015. * @returns a new Mesh
  24016. */
  24017. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24018. /**
  24019. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24020. * @param name defines the name of the mesh to create
  24021. * @param size sets the size (float) of each box side (default 1)
  24022. * @param scene defines the hosting scene
  24023. * @param updatable defines if the mesh must be flagged as updatable
  24024. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24025. * @returns a new Mesh
  24026. */
  24027. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24028. /**
  24029. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24030. * @param name defines the name of the mesh to create
  24031. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24032. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24033. * @param scene defines the hosting scene
  24034. * @param updatable defines if the mesh must be flagged as updatable
  24035. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24036. * @returns a new Mesh
  24037. */
  24038. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24039. /**
  24040. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24041. * @param name defines the name of the mesh to create
  24042. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24043. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24044. * @param scene defines the hosting scene
  24045. * @returns a new Mesh
  24046. */
  24047. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24048. /**
  24049. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24050. * @param name defines the name of the mesh to create
  24051. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24052. * @param diameterTop set the top cap diameter (floats, default 1)
  24053. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24054. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24055. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24056. * @param scene defines the hosting scene
  24057. * @param updatable defines if the mesh must be flagged as updatable
  24058. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24059. * @returns a new Mesh
  24060. */
  24061. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24062. /**
  24063. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24064. * @param name defines the name of the mesh to create
  24065. * @param diameter sets the diameter size (float) of the torus (default 1)
  24066. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24067. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24068. * @param scene defines the hosting scene
  24069. * @param updatable defines if the mesh must be flagged as updatable
  24070. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24071. * @returns a new Mesh
  24072. */
  24073. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24074. /**
  24075. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24076. * @param name defines the name of the mesh to create
  24077. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24078. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24079. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24080. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24081. * @param p the number of windings on X axis (positive integers, default 2)
  24082. * @param q the number of windings on Y axis (positive integers, default 3)
  24083. * @param scene defines the hosting scene
  24084. * @param updatable defines if the mesh must be flagged as updatable
  24085. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24086. * @returns a new Mesh
  24087. */
  24088. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24089. /**
  24090. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24091. * @param name defines the name of the mesh to create
  24092. * @param points is an array successive Vector3
  24093. * @param scene defines the hosting scene
  24094. * @param updatable defines if the mesh must be flagged as updatable
  24095. * @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).
  24096. * @returns a new Mesh
  24097. */
  24098. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24099. /**
  24100. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24101. * @param name defines the name of the mesh to create
  24102. * @param points is an array successive Vector3
  24103. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24104. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24105. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24106. * @param scene defines the hosting scene
  24107. * @param updatable defines if the mesh must be flagged as updatable
  24108. * @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)
  24109. * @returns a new Mesh
  24110. */
  24111. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24112. /**
  24113. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24114. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24115. * 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.
  24116. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24117. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24118. * Remember you can only change the shape positions, not their number when updating a polygon.
  24119. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24120. * @param name defines the name of the mesh to create
  24121. * @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
  24122. * @param scene defines the hosting scene
  24123. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24124. * @param updatable defines if the mesh must be flagged as updatable
  24125. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24126. * @param earcutInjection can be used to inject your own earcut reference
  24127. * @returns a new Mesh
  24128. */
  24129. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24130. /**
  24131. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24132. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24133. * @param name defines the name of the mesh to create
  24134. * @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
  24135. * @param depth defines the height of extrusion
  24136. * @param scene defines the hosting scene
  24137. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24138. * @param updatable defines if the mesh must be flagged as updatable
  24139. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24140. * @param earcutInjection can be used to inject your own earcut reference
  24141. * @returns a new Mesh
  24142. */
  24143. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24144. /**
  24145. * Creates an extruded shape mesh.
  24146. * 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
  24147. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24148. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24149. * @param name defines the name of the mesh to create
  24150. * @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
  24151. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24152. * @param scale is the value to scale the shape
  24153. * @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
  24154. * @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
  24155. * @param scene defines the hosting scene
  24156. * @param updatable defines if the mesh must be flagged as updatable
  24157. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24158. * @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)
  24159. * @returns a new Mesh
  24160. */
  24161. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24162. /**
  24163. * Creates an custom extruded shape mesh.
  24164. * The custom extrusion is a parametric shape.
  24165. * It has no predefined shape. Its final shape will depend on the input parameters.
  24166. * Please consider using the same method from the MeshBuilder class instead
  24167. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24168. * @param name defines the name of the mesh to create
  24169. * @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
  24170. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24171. * @param scaleFunction is a custom Javascript function called on each path point
  24172. * @param rotationFunction is a custom Javascript function called on each path point
  24173. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24174. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24175. * @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
  24176. * @param scene defines the hosting scene
  24177. * @param updatable defines if the mesh must be flagged as updatable
  24178. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24179. * @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)
  24180. * @returns a new Mesh
  24181. */
  24182. 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;
  24183. /**
  24184. * Creates lathe mesh.
  24185. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24186. * Please consider using the same method from the MeshBuilder class instead
  24187. * @param name defines the name of the mesh to create
  24188. * @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
  24189. * @param radius is the radius value of the lathe
  24190. * @param tessellation is the side number of the lathe.
  24191. * @param scene defines the hosting scene
  24192. * @param updatable defines if the mesh must be flagged as updatable
  24193. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24194. * @returns a new Mesh
  24195. */
  24196. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24197. /**
  24198. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24199. * @param name defines the name of the mesh to create
  24200. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24201. * @param scene defines the hosting scene
  24202. * @param updatable defines if the mesh must be flagged as updatable
  24203. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24204. * @returns a new Mesh
  24205. */
  24206. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24207. /**
  24208. * Creates a ground mesh.
  24209. * Please consider using the same method from the MeshBuilder class instead
  24210. * @param name defines the name of the mesh to create
  24211. * @param width set the width of the ground
  24212. * @param height set the height of the ground
  24213. * @param subdivisions sets the number of subdivisions per side
  24214. * @param scene defines the hosting scene
  24215. * @param updatable defines if the mesh must be flagged as updatable
  24216. * @returns a new Mesh
  24217. */
  24218. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24219. /**
  24220. * Creates a tiled ground mesh.
  24221. * Please consider using the same method from the MeshBuilder class instead
  24222. * @param name defines the name of the mesh to create
  24223. * @param xmin set the ground minimum X coordinate
  24224. * @param zmin set the ground minimum Y coordinate
  24225. * @param xmax set the ground maximum X coordinate
  24226. * @param zmax set the ground maximum Z coordinate
  24227. * @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
  24228. * @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
  24229. * @param scene defines the hosting scene
  24230. * @param updatable defines if the mesh must be flagged as updatable
  24231. * @returns a new Mesh
  24232. */
  24233. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24234. w: number;
  24235. h: number;
  24236. }, precision: {
  24237. w: number;
  24238. h: number;
  24239. }, scene: Scene, updatable?: boolean): Mesh;
  24240. /**
  24241. * Creates a ground mesh from a height map.
  24242. * Please consider using the same method from the MeshBuilder class instead
  24243. * @see http://doc.babylonjs.com/babylon101/height_map
  24244. * @param name defines the name of the mesh to create
  24245. * @param url sets the URL of the height map image resource
  24246. * @param width set the ground width size
  24247. * @param height set the ground height size
  24248. * @param subdivisions sets the number of subdivision per side
  24249. * @param minHeight is the minimum altitude on the ground
  24250. * @param maxHeight is the maximum altitude on the ground
  24251. * @param scene defines the hosting scene
  24252. * @param updatable defines if the mesh must be flagged as updatable
  24253. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24254. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24255. * @returns a new Mesh
  24256. */
  24257. 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;
  24258. /**
  24259. * Creates a tube mesh.
  24260. * The tube is a parametric shape.
  24261. * It has no predefined shape. Its final shape will depend on the input parameters.
  24262. * Please consider using the same method from the MeshBuilder class instead
  24263. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24264. * @param name defines the name of the mesh to create
  24265. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24266. * @param radius sets the tube radius size
  24267. * @param tessellation is the number of sides on the tubular surface
  24268. * @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
  24269. * @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
  24270. * @param scene defines the hosting scene
  24271. * @param updatable defines if the mesh must be flagged as updatable
  24272. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24273. * @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)
  24274. * @returns a new Mesh
  24275. */
  24276. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24277. (i: number, distance: number): number;
  24278. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24279. /**
  24280. * Creates a polyhedron mesh.
  24281. * Please consider using the same method from the MeshBuilder class instead.
  24282. * * 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
  24283. * * The parameter `size` (positive float, default 1) sets the polygon size
  24284. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24285. * * 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`
  24286. * * 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
  24287. * * 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)`)
  24288. * * 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
  24289. * * 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
  24290. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24291. * * 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
  24292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24293. * @param name defines the name of the mesh to create
  24294. * @param options defines the options used to create the mesh
  24295. * @param scene defines the hosting scene
  24296. * @returns a new Mesh
  24297. */
  24298. static CreatePolyhedron(name: string, options: {
  24299. type?: number;
  24300. size?: number;
  24301. sizeX?: number;
  24302. sizeY?: number;
  24303. sizeZ?: number;
  24304. custom?: any;
  24305. faceUV?: Vector4[];
  24306. faceColors?: Color4[];
  24307. updatable?: boolean;
  24308. sideOrientation?: number;
  24309. }, scene: Scene): Mesh;
  24310. /**
  24311. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24312. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24313. * * 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`)
  24314. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24315. * * 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
  24316. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24317. * * 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
  24318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24319. * @param name defines the name of the mesh
  24320. * @param options defines the options used to create the mesh
  24321. * @param scene defines the hosting scene
  24322. * @returns a new Mesh
  24323. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24324. */
  24325. static CreateIcoSphere(name: string, options: {
  24326. radius?: number;
  24327. flat?: boolean;
  24328. subdivisions?: number;
  24329. sideOrientation?: number;
  24330. updatable?: boolean;
  24331. }, scene: Scene): Mesh;
  24332. /**
  24333. * Creates a decal mesh.
  24334. * Please consider using the same method from the MeshBuilder class instead.
  24335. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24336. * @param name defines the name of the mesh
  24337. * @param sourceMesh defines the mesh receiving the decal
  24338. * @param position sets the position of the decal in world coordinates
  24339. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24340. * @param size sets the decal scaling
  24341. * @param angle sets the angle to rotate the decal
  24342. * @returns a new Mesh
  24343. */
  24344. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24345. /**
  24346. * Prepare internal position array for software CPU skinning
  24347. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24348. */
  24349. setPositionsForCPUSkinning(): Float32Array;
  24350. /**
  24351. * Prepare internal normal array for software CPU skinning
  24352. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24353. */
  24354. setNormalsForCPUSkinning(): Float32Array;
  24355. /**
  24356. * Updates the vertex buffer by applying transformation from the bones
  24357. * @param skeleton defines the skeleton to apply to current mesh
  24358. * @returns the current mesh
  24359. */
  24360. applySkeleton(skeleton: Skeleton): Mesh;
  24361. /**
  24362. * 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
  24363. * @param meshes defines the list of meshes to scan
  24364. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24365. */
  24366. static MinMax(meshes: AbstractMesh[]): {
  24367. min: Vector3;
  24368. max: Vector3;
  24369. };
  24370. /**
  24371. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24372. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24373. * @returns a vector3
  24374. */
  24375. static Center(meshesOrMinMaxVector: {
  24376. min: Vector3;
  24377. max: Vector3;
  24378. } | AbstractMesh[]): Vector3;
  24379. /**
  24380. * Merge the array of meshes into a single mesh for performance reasons.
  24381. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24382. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24383. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24384. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24385. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24386. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24387. * @returns a new mesh
  24388. */
  24389. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24390. /** @hidden */
  24391. addInstance(instance: InstancedMesh): void;
  24392. /** @hidden */
  24393. removeInstance(instance: InstancedMesh): void;
  24394. }
  24395. }
  24396. declare module BABYLON {
  24397. /**
  24398. * This is the base class of all the camera used in the application.
  24399. * @see http://doc.babylonjs.com/features/cameras
  24400. */
  24401. export class Camera extends Node {
  24402. /** @hidden */
  24403. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24404. /**
  24405. * This is the default projection mode used by the cameras.
  24406. * It helps recreating a feeling of perspective and better appreciate depth.
  24407. * This is the best way to simulate real life cameras.
  24408. */
  24409. static readonly PERSPECTIVE_CAMERA: number;
  24410. /**
  24411. * This helps creating camera with an orthographic mode.
  24412. * 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.
  24413. */
  24414. static readonly ORTHOGRAPHIC_CAMERA: number;
  24415. /**
  24416. * This is the default FOV mode for perspective cameras.
  24417. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24418. */
  24419. static readonly FOVMODE_VERTICAL_FIXED: number;
  24420. /**
  24421. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24422. */
  24423. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24424. /**
  24425. * This specifies ther is no need for a camera rig.
  24426. * Basically only one eye is rendered corresponding to the camera.
  24427. */
  24428. static readonly RIG_MODE_NONE: number;
  24429. /**
  24430. * Simulates a camera Rig with one blue eye and one red eye.
  24431. * This can be use with 3d blue and red glasses.
  24432. */
  24433. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24434. /**
  24435. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24436. */
  24437. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24438. /**
  24439. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24440. */
  24441. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24442. /**
  24443. * Defines that both eyes of the camera will be rendered over under each other.
  24444. */
  24445. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24446. /**
  24447. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24448. */
  24449. static readonly RIG_MODE_VR: number;
  24450. /**
  24451. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24452. */
  24453. static readonly RIG_MODE_WEBVR: number;
  24454. /**
  24455. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24456. */
  24457. static readonly RIG_MODE_CUSTOM: number;
  24458. /**
  24459. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24460. */
  24461. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24462. /**
  24463. * Define the input manager associated with the camera.
  24464. */
  24465. inputs: CameraInputsManager<Camera>;
  24466. /** @hidden */
  24467. _position: Vector3;
  24468. /**
  24469. * Define the current local position of the camera in the scene
  24470. */
  24471. position: Vector3;
  24472. /**
  24473. * The vector the camera should consider as up.
  24474. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24475. */
  24476. upVector: Vector3;
  24477. /**
  24478. * Define the current limit on the left side for an orthographic camera
  24479. * In scene unit
  24480. */
  24481. orthoLeft: Nullable<number>;
  24482. /**
  24483. * Define the current limit on the right side for an orthographic camera
  24484. * In scene unit
  24485. */
  24486. orthoRight: Nullable<number>;
  24487. /**
  24488. * Define the current limit on the bottom side for an orthographic camera
  24489. * In scene unit
  24490. */
  24491. orthoBottom: Nullable<number>;
  24492. /**
  24493. * Define the current limit on the top side for an orthographic camera
  24494. * In scene unit
  24495. */
  24496. orthoTop: Nullable<number>;
  24497. /**
  24498. * Field Of View is set in Radians. (default is 0.8)
  24499. */
  24500. fov: number;
  24501. /**
  24502. * Define the minimum distance the camera can see from.
  24503. * This is important to note that the depth buffer are not infinite and the closer it starts
  24504. * the more your scene might encounter depth fighting issue.
  24505. */
  24506. minZ: number;
  24507. /**
  24508. * Define the maximum distance the camera can see to.
  24509. * This is important to note that the depth buffer are not infinite and the further it end
  24510. * the more your scene might encounter depth fighting issue.
  24511. */
  24512. maxZ: number;
  24513. /**
  24514. * Define the default inertia of the camera.
  24515. * This helps giving a smooth feeling to the camera movement.
  24516. */
  24517. inertia: number;
  24518. /**
  24519. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24520. */
  24521. mode: number;
  24522. /**
  24523. * Define wether the camera is intermediate.
  24524. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24525. */
  24526. isIntermediate: boolean;
  24527. /**
  24528. * Define the viewport of the camera.
  24529. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24530. */
  24531. viewport: Viewport;
  24532. /**
  24533. * Restricts the camera to viewing objects with the same layerMask.
  24534. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24535. */
  24536. layerMask: number;
  24537. /**
  24538. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24539. */
  24540. fovMode: number;
  24541. /**
  24542. * Rig mode of the camera.
  24543. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24544. * This is normally controlled byt the camera themselves as internal use.
  24545. */
  24546. cameraRigMode: number;
  24547. /**
  24548. * Defines the distance between both "eyes" in case of a RIG
  24549. */
  24550. interaxialDistance: number;
  24551. /**
  24552. * Defines if stereoscopic rendering is done side by side or over under.
  24553. */
  24554. isStereoscopicSideBySide: boolean;
  24555. /**
  24556. * 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
  24557. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24558. * else in the scene. (Eg. security camera)
  24559. *
  24560. * 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)
  24561. */
  24562. customRenderTargets: RenderTargetTexture[];
  24563. /**
  24564. * When set, the camera will render to this render target instead of the default canvas
  24565. *
  24566. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24567. */
  24568. outputRenderTarget: Nullable<RenderTargetTexture>;
  24569. /**
  24570. * Observable triggered when the camera view matrix has changed.
  24571. */
  24572. onViewMatrixChangedObservable: Observable<Camera>;
  24573. /**
  24574. * Observable triggered when the camera Projection matrix has changed.
  24575. */
  24576. onProjectionMatrixChangedObservable: Observable<Camera>;
  24577. /**
  24578. * Observable triggered when the inputs have been processed.
  24579. */
  24580. onAfterCheckInputsObservable: Observable<Camera>;
  24581. /**
  24582. * Observable triggered when reset has been called and applied to the camera.
  24583. */
  24584. onRestoreStateObservable: Observable<Camera>;
  24585. /** @hidden */
  24586. _cameraRigParams: any;
  24587. /** @hidden */
  24588. _rigCameras: Camera[];
  24589. /** @hidden */
  24590. _rigPostProcess: Nullable<PostProcess>;
  24591. protected _webvrViewMatrix: Matrix;
  24592. /** @hidden */
  24593. _skipRendering: boolean;
  24594. /** @hidden */
  24595. _projectionMatrix: Matrix;
  24596. /** @hidden */
  24597. _postProcesses: Nullable<PostProcess>[];
  24598. /** @hidden */
  24599. _activeMeshes: SmartArray<AbstractMesh>;
  24600. protected _globalPosition: Vector3;
  24601. /** @hidden */
  24602. _computedViewMatrix: Matrix;
  24603. private _doNotComputeProjectionMatrix;
  24604. private _transformMatrix;
  24605. private _frustumPlanes;
  24606. private _refreshFrustumPlanes;
  24607. private _storedFov;
  24608. private _stateStored;
  24609. /**
  24610. * Instantiates a new camera object.
  24611. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24612. * @see http://doc.babylonjs.com/features/cameras
  24613. * @param name Defines the name of the camera in the scene
  24614. * @param position Defines the position of the camera
  24615. * @param scene Defines the scene the camera belongs too
  24616. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24617. */
  24618. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24619. /**
  24620. * Store current camera state (fov, position, etc..)
  24621. * @returns the camera
  24622. */
  24623. storeState(): Camera;
  24624. /**
  24625. * Restores the camera state values if it has been stored. You must call storeState() first
  24626. */
  24627. protected _restoreStateValues(): boolean;
  24628. /**
  24629. * Restored camera state. You must call storeState() first.
  24630. * @returns true if restored and false otherwise
  24631. */
  24632. restoreState(): boolean;
  24633. /**
  24634. * Gets the class name of the camera.
  24635. * @returns the class name
  24636. */
  24637. getClassName(): string;
  24638. /** @hidden */
  24639. readonly _isCamera: boolean;
  24640. /**
  24641. * Gets a string representation of the camera useful for debug purpose.
  24642. * @param fullDetails Defines that a more verboe level of logging is required
  24643. * @returns the string representation
  24644. */
  24645. toString(fullDetails?: boolean): string;
  24646. /**
  24647. * Gets the current world space position of the camera.
  24648. */
  24649. readonly globalPosition: Vector3;
  24650. /**
  24651. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24652. * @returns the active meshe list
  24653. */
  24654. getActiveMeshes(): SmartArray<AbstractMesh>;
  24655. /**
  24656. * Check wether a mesh is part of the current active mesh list of the camera
  24657. * @param mesh Defines the mesh to check
  24658. * @returns true if active, false otherwise
  24659. */
  24660. isActiveMesh(mesh: Mesh): boolean;
  24661. /**
  24662. * Is this camera ready to be used/rendered
  24663. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24664. * @return true if the camera is ready
  24665. */
  24666. isReady(completeCheck?: boolean): boolean;
  24667. /** @hidden */
  24668. _initCache(): void;
  24669. /** @hidden */
  24670. _updateCache(ignoreParentClass?: boolean): void;
  24671. /** @hidden */
  24672. _isSynchronized(): boolean;
  24673. /** @hidden */
  24674. _isSynchronizedViewMatrix(): boolean;
  24675. /** @hidden */
  24676. _isSynchronizedProjectionMatrix(): boolean;
  24677. /**
  24678. * Attach the input controls to a specific dom element to get the input from.
  24679. * @param element Defines the element the controls should be listened from
  24680. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24681. */
  24682. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24683. /**
  24684. * Detach the current controls from the specified dom element.
  24685. * @param element Defines the element to stop listening the inputs from
  24686. */
  24687. detachControl(element: HTMLElement): void;
  24688. /**
  24689. * Update the camera state according to the different inputs gathered during the frame.
  24690. */
  24691. update(): void;
  24692. /** @hidden */
  24693. _checkInputs(): void;
  24694. /** @hidden */
  24695. readonly rigCameras: Camera[];
  24696. /**
  24697. * Gets the post process used by the rig cameras
  24698. */
  24699. readonly rigPostProcess: Nullable<PostProcess>;
  24700. /**
  24701. * Internal, gets the first post proces.
  24702. * @returns the first post process to be run on this camera.
  24703. */
  24704. _getFirstPostProcess(): Nullable<PostProcess>;
  24705. private _cascadePostProcessesToRigCams;
  24706. /**
  24707. * Attach a post process to the camera.
  24708. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24709. * @param postProcess The post process to attach to the camera
  24710. * @param insertAt The position of the post process in case several of them are in use in the scene
  24711. * @returns the position the post process has been inserted at
  24712. */
  24713. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24714. /**
  24715. * Detach a post process to the camera.
  24716. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24717. * @param postProcess The post process to detach from the camera
  24718. */
  24719. detachPostProcess(postProcess: PostProcess): void;
  24720. /**
  24721. * Gets the current world matrix of the camera
  24722. */
  24723. getWorldMatrix(): Matrix;
  24724. /** @hidden */
  24725. _getViewMatrix(): Matrix;
  24726. /**
  24727. * Gets the current view matrix of the camera.
  24728. * @param force forces the camera to recompute the matrix without looking at the cached state
  24729. * @returns the view matrix
  24730. */
  24731. getViewMatrix(force?: boolean): Matrix;
  24732. /**
  24733. * Freeze the projection matrix.
  24734. * It will prevent the cache check of the camera projection compute and can speed up perf
  24735. * if no parameter of the camera are meant to change
  24736. * @param projection Defines manually a projection if necessary
  24737. */
  24738. freezeProjectionMatrix(projection?: Matrix): void;
  24739. /**
  24740. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24741. */
  24742. unfreezeProjectionMatrix(): void;
  24743. /**
  24744. * Gets the current projection matrix of the camera.
  24745. * @param force forces the camera to recompute the matrix without looking at the cached state
  24746. * @returns the projection matrix
  24747. */
  24748. getProjectionMatrix(force?: boolean): Matrix;
  24749. /**
  24750. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24751. * @returns a Matrix
  24752. */
  24753. getTransformationMatrix(): Matrix;
  24754. private _updateFrustumPlanes;
  24755. /**
  24756. * Checks if a cullable object (mesh...) is in the camera frustum
  24757. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24758. * @param target The object to check
  24759. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24760. * @returns true if the object is in frustum otherwise false
  24761. */
  24762. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24763. /**
  24764. * Checks if a cullable object (mesh...) is in the camera frustum
  24765. * Unlike isInFrustum this cheks the full bounding box
  24766. * @param target The object to check
  24767. * @returns true if the object is in frustum otherwise false
  24768. */
  24769. isCompletelyInFrustum(target: ICullable): boolean;
  24770. /**
  24771. * Gets a ray in the forward direction from the camera.
  24772. * @param length Defines the length of the ray to create
  24773. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24774. * @param origin Defines the start point of the ray which defaults to the camera position
  24775. * @returns the forward ray
  24776. */
  24777. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24778. /**
  24779. * Releases resources associated with this node.
  24780. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24781. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24782. */
  24783. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24784. /** @hidden */
  24785. _isLeftCamera: boolean;
  24786. /**
  24787. * Gets the left camera of a rig setup in case of Rigged Camera
  24788. */
  24789. readonly isLeftCamera: boolean;
  24790. /** @hidden */
  24791. _isRightCamera: boolean;
  24792. /**
  24793. * Gets the right camera of a rig setup in case of Rigged Camera
  24794. */
  24795. readonly isRightCamera: boolean;
  24796. /**
  24797. * Gets the left camera of a rig setup in case of Rigged Camera
  24798. */
  24799. readonly leftCamera: Nullable<FreeCamera>;
  24800. /**
  24801. * Gets the right camera of a rig setup in case of Rigged Camera
  24802. */
  24803. readonly rightCamera: Nullable<FreeCamera>;
  24804. /**
  24805. * Gets the left camera target of a rig setup in case of Rigged Camera
  24806. * @returns the target position
  24807. */
  24808. getLeftTarget(): Nullable<Vector3>;
  24809. /**
  24810. * Gets the right camera target of a rig setup in case of Rigged Camera
  24811. * @returns the target position
  24812. */
  24813. getRightTarget(): Nullable<Vector3>;
  24814. /**
  24815. * @hidden
  24816. */
  24817. setCameraRigMode(mode: number, rigParams: any): void;
  24818. /** @hidden */
  24819. static _setStereoscopicRigMode(camera: Camera): void;
  24820. /** @hidden */
  24821. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  24822. /** @hidden */
  24823. static _setVRRigMode(camera: Camera, rigParams: any): void;
  24824. /** @hidden */
  24825. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  24826. /** @hidden */
  24827. _getVRProjectionMatrix(): Matrix;
  24828. protected _updateCameraRotationMatrix(): void;
  24829. protected _updateWebVRCameraRotationMatrix(): void;
  24830. /**
  24831. * This function MUST be overwritten by the different WebVR cameras available.
  24832. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24833. * @hidden
  24834. */
  24835. _getWebVRProjectionMatrix(): Matrix;
  24836. /**
  24837. * This function MUST be overwritten by the different WebVR cameras available.
  24838. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24839. * @hidden
  24840. */
  24841. _getWebVRViewMatrix(): Matrix;
  24842. /** @hidden */
  24843. setCameraRigParameter(name: string, value: any): void;
  24844. /**
  24845. * needs to be overridden by children so sub has required properties to be copied
  24846. * @hidden
  24847. */
  24848. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  24849. /**
  24850. * May need to be overridden by children
  24851. * @hidden
  24852. */
  24853. _updateRigCameras(): void;
  24854. /** @hidden */
  24855. _setupInputs(): void;
  24856. /**
  24857. * Serialiaze the camera setup to a json represention
  24858. * @returns the JSON representation
  24859. */
  24860. serialize(): any;
  24861. /**
  24862. * Clones the current camera.
  24863. * @param name The cloned camera name
  24864. * @returns the cloned camera
  24865. */
  24866. clone(name: string): Camera;
  24867. /**
  24868. * Gets the direction of the camera relative to a given local axis.
  24869. * @param localAxis Defines the reference axis to provide a relative direction.
  24870. * @return the direction
  24871. */
  24872. getDirection(localAxis: Vector3): Vector3;
  24873. /**
  24874. * Gets the direction of the camera relative to a given local axis into a passed vector.
  24875. * @param localAxis Defines the reference axis to provide a relative direction.
  24876. * @param result Defines the vector to store the result in
  24877. */
  24878. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  24879. /**
  24880. * Gets a camera constructor for a given camera type
  24881. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  24882. * @param name The name of the camera the result will be able to instantiate
  24883. * @param scene The scene the result will construct the camera in
  24884. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  24885. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  24886. * @returns a factory method to construc the camera
  24887. */
  24888. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  24889. /**
  24890. * Compute the world matrix of the camera.
  24891. * @returns the camera workd matrix
  24892. */
  24893. computeWorldMatrix(): Matrix;
  24894. /**
  24895. * Parse a JSON and creates the camera from the parsed information
  24896. * @param parsedCamera The JSON to parse
  24897. * @param scene The scene to instantiate the camera in
  24898. * @returns the newly constructed camera
  24899. */
  24900. static Parse(parsedCamera: any, scene: Scene): Camera;
  24901. }
  24902. }
  24903. declare module BABYLON {
  24904. /**
  24905. * Class containing static functions to help procedurally build meshes
  24906. */
  24907. export class DiscBuilder {
  24908. /**
  24909. * Creates a plane polygonal mesh. By default, this is a disc
  24910. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24911. * * 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
  24912. * * 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
  24913. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24914. * * 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
  24915. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24916. * @param name defines the name of the mesh
  24917. * @param options defines the options used to create the mesh
  24918. * @param scene defines the hosting scene
  24919. * @returns the plane polygonal mesh
  24920. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24921. */
  24922. static CreateDisc(name: string, options: {
  24923. radius?: number;
  24924. tessellation?: number;
  24925. arc?: number;
  24926. updatable?: boolean;
  24927. sideOrientation?: number;
  24928. frontUVs?: Vector4;
  24929. backUVs?: Vector4;
  24930. }, scene?: Nullable<Scene>): Mesh;
  24931. }
  24932. }
  24933. declare module BABYLON {
  24934. /**
  24935. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24936. *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.
  24937. * The SPS is also a particle system. It provides some methods to manage the particles.
  24938. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24939. *
  24940. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  24941. */
  24942. export class SolidParticleSystem implements IDisposable {
  24943. /**
  24944. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24945. * Example : var p = SPS.particles[i];
  24946. */
  24947. particles: SolidParticle[];
  24948. /**
  24949. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24950. */
  24951. nbParticles: number;
  24952. /**
  24953. * If the particles must ever face the camera (default false). Useful for planar particles.
  24954. */
  24955. billboard: boolean;
  24956. /**
  24957. * Recompute normals when adding a shape
  24958. */
  24959. recomputeNormals: boolean;
  24960. /**
  24961. * This a counter ofr your own usage. It's not set by any SPS functions.
  24962. */
  24963. counter: number;
  24964. /**
  24965. * The SPS name. This name is also given to the underlying mesh.
  24966. */
  24967. name: string;
  24968. /**
  24969. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24970. */
  24971. mesh: Mesh;
  24972. /**
  24973. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24974. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  24975. */
  24976. vars: any;
  24977. /**
  24978. * This array is populated when the SPS is set as 'pickable'.
  24979. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24980. * Each element of this array is an object `{idx: int, faceId: int}`.
  24981. * `idx` is the picked particle index in the `SPS.particles` array
  24982. * `faceId` is the picked face index counted within this particle.
  24983. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  24984. */
  24985. pickedParticles: {
  24986. idx: number;
  24987. faceId: number;
  24988. }[];
  24989. /**
  24990. * This array is populated when `enableDepthSort` is set to true.
  24991. * Each element of this array is an instance of the class DepthSortedParticle.
  24992. */
  24993. depthSortedParticles: DepthSortedParticle[];
  24994. /**
  24995. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24996. * @hidden
  24997. */
  24998. _bSphereOnly: boolean;
  24999. /**
  25000. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25001. * @hidden
  25002. */
  25003. _bSphereRadiusFactor: number;
  25004. private _scene;
  25005. private _positions;
  25006. private _indices;
  25007. private _normals;
  25008. private _colors;
  25009. private _uvs;
  25010. private _indices32;
  25011. private _positions32;
  25012. private _normals32;
  25013. private _fixedNormal32;
  25014. private _colors32;
  25015. private _uvs32;
  25016. private _index;
  25017. private _updatable;
  25018. private _pickable;
  25019. private _isVisibilityBoxLocked;
  25020. private _alwaysVisible;
  25021. private _depthSort;
  25022. private _shapeCounter;
  25023. private _copy;
  25024. private _color;
  25025. private _computeParticleColor;
  25026. private _computeParticleTexture;
  25027. private _computeParticleRotation;
  25028. private _computeParticleVertex;
  25029. private _computeBoundingBox;
  25030. private _depthSortParticles;
  25031. private _camera;
  25032. private _mustUnrotateFixedNormals;
  25033. private _particlesIntersect;
  25034. private _needs32Bits;
  25035. /**
  25036. * Creates a SPS (Solid Particle System) object.
  25037. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25038. * @param scene (Scene) is the scene in which the SPS is added.
  25039. * @param options defines the options of the sps e.g.
  25040. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25041. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25042. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25043. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25044. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25045. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25046. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25047. */
  25048. constructor(name: string, scene: Scene, options?: {
  25049. updatable?: boolean;
  25050. isPickable?: boolean;
  25051. enableDepthSort?: boolean;
  25052. particleIntersection?: boolean;
  25053. boundingSphereOnly?: boolean;
  25054. bSphereRadiusFactor?: number;
  25055. });
  25056. /**
  25057. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25058. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25059. * @returns the created mesh
  25060. */
  25061. buildMesh(): Mesh;
  25062. /**
  25063. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25064. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25065. * Thus the particles generated from `digest()` have their property `position` set yet.
  25066. * @param mesh ( Mesh ) is the mesh to be digested
  25067. * @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
  25068. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25069. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25070. * @returns the current SPS
  25071. */
  25072. digest(mesh: Mesh, options?: {
  25073. facetNb?: number;
  25074. number?: number;
  25075. delta?: number;
  25076. }): SolidParticleSystem;
  25077. private _unrotateFixedNormals;
  25078. private _resetCopy;
  25079. private _meshBuilder;
  25080. private _posToShape;
  25081. private _uvsToShapeUV;
  25082. private _addParticle;
  25083. /**
  25084. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25085. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25086. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25087. * @param nb (positive integer) the number of particles to be created from this model
  25088. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25089. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25090. * @returns the number of shapes in the system
  25091. */
  25092. addShape(mesh: Mesh, nb: number, options?: {
  25093. positionFunction?: any;
  25094. vertexFunction?: any;
  25095. }): number;
  25096. private _rebuildParticle;
  25097. /**
  25098. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25099. * @returns the SPS.
  25100. */
  25101. rebuildMesh(): SolidParticleSystem;
  25102. /**
  25103. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25104. * This method calls `updateParticle()` for each particle of the SPS.
  25105. * For an animated SPS, it is usually called within the render loop.
  25106. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25107. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25108. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25109. * @returns the SPS.
  25110. */
  25111. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25112. /**
  25113. * Disposes the SPS.
  25114. */
  25115. dispose(): void;
  25116. /**
  25117. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25118. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25119. * @returns the SPS.
  25120. */
  25121. refreshVisibleSize(): SolidParticleSystem;
  25122. /**
  25123. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25124. * @param size the size (float) of the visibility box
  25125. * note : this doesn't lock the SPS mesh bounding box.
  25126. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25127. */
  25128. setVisibilityBox(size: number): void;
  25129. /**
  25130. * Gets whether the SPS as always visible or not
  25131. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25132. */
  25133. /**
  25134. * Sets the SPS as always visible or not
  25135. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25136. */
  25137. isAlwaysVisible: boolean;
  25138. /**
  25139. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25140. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25141. */
  25142. /**
  25143. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25144. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25145. */
  25146. isVisibilityBoxLocked: boolean;
  25147. /**
  25148. * Tells to `setParticles()` to compute the particle rotations or not.
  25149. * Default value : true. The SPS is faster when it's set to false.
  25150. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25151. */
  25152. /**
  25153. * Gets if `setParticles()` computes the particle rotations or not.
  25154. * Default value : true. The SPS is faster when it's set to false.
  25155. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25156. */
  25157. computeParticleRotation: boolean;
  25158. /**
  25159. * Tells to `setParticles()` to compute the particle colors or not.
  25160. * Default value : true. The SPS is faster when it's set to false.
  25161. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25162. */
  25163. /**
  25164. * Gets if `setParticles()` computes the particle colors or not.
  25165. * Default value : true. The SPS is faster when it's set to false.
  25166. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25167. */
  25168. computeParticleColor: boolean;
  25169. /**
  25170. * Gets if `setParticles()` computes the particle textures or not.
  25171. * Default value : true. The SPS is faster when it's set to false.
  25172. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25173. */
  25174. computeParticleTexture: boolean;
  25175. /**
  25176. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25177. * Default value : false. The SPS is faster when it's set to false.
  25178. * Note : the particle custom vertex positions aren't stored values.
  25179. */
  25180. /**
  25181. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25182. * Default value : false. The SPS is faster when it's set to false.
  25183. * Note : the particle custom vertex positions aren't stored values.
  25184. */
  25185. computeParticleVertex: boolean;
  25186. /**
  25187. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25188. */
  25189. /**
  25190. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25191. */
  25192. computeBoundingBox: boolean;
  25193. /**
  25194. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25195. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25196. * Default : `true`
  25197. */
  25198. /**
  25199. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25200. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25201. * Default : `true`
  25202. */
  25203. depthSortParticles: boolean;
  25204. /**
  25205. * This function does nothing. It may be overwritten to set all the particle first values.
  25206. * The SPS doesn't call this function, you may have to call it by your own.
  25207. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25208. */
  25209. initParticles(): void;
  25210. /**
  25211. * This function does nothing. It may be overwritten to recycle a particle.
  25212. * The SPS doesn't call this function, you may have to call it by your own.
  25213. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25214. * @param particle The particle to recycle
  25215. * @returns the recycled particle
  25216. */
  25217. recycleParticle(particle: SolidParticle): SolidParticle;
  25218. /**
  25219. * Updates a particle : this function should be overwritten by the user.
  25220. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25221. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25222. * @example : just set a particle position or velocity and recycle conditions
  25223. * @param particle The particle to update
  25224. * @returns the updated particle
  25225. */
  25226. updateParticle(particle: SolidParticle): SolidParticle;
  25227. /**
  25228. * Updates a vertex of a particle : it can be overwritten by the user.
  25229. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25230. * @param particle the current particle
  25231. * @param vertex the current index of the current particle
  25232. * @param pt the index of the current vertex in the particle shape
  25233. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25234. * @example : just set a vertex particle position
  25235. * @returns the updated vertex
  25236. */
  25237. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25238. /**
  25239. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25240. * This does nothing and may be overwritten by the user.
  25241. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25242. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25243. * @param update the boolean update value actually passed to setParticles()
  25244. */
  25245. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25246. /**
  25247. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25248. * This will be passed three parameters.
  25249. * This does nothing and may be overwritten by the user.
  25250. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25251. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25252. * @param update the boolean update value actually passed to setParticles()
  25253. */
  25254. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25255. }
  25256. }
  25257. declare module BABYLON {
  25258. /**
  25259. * Represents one particle of a solid particle system.
  25260. */
  25261. export class SolidParticle {
  25262. /**
  25263. * particle global index
  25264. */
  25265. idx: number;
  25266. /**
  25267. * The color of the particle
  25268. */
  25269. color: Nullable<Color4>;
  25270. /**
  25271. * The world space position of the particle.
  25272. */
  25273. position: Vector3;
  25274. /**
  25275. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25276. */
  25277. rotation: Vector3;
  25278. /**
  25279. * The world space rotation quaternion of the particle.
  25280. */
  25281. rotationQuaternion: Nullable<Quaternion>;
  25282. /**
  25283. * The scaling of the particle.
  25284. */
  25285. scaling: Vector3;
  25286. /**
  25287. * The uvs of the particle.
  25288. */
  25289. uvs: Vector4;
  25290. /**
  25291. * The current speed of the particle.
  25292. */
  25293. velocity: Vector3;
  25294. /**
  25295. * The pivot point in the particle local space.
  25296. */
  25297. pivot: Vector3;
  25298. /**
  25299. * Must the particle be translated from its pivot point in its local space ?
  25300. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25301. * Default : false
  25302. */
  25303. translateFromPivot: boolean;
  25304. /**
  25305. * Is the particle active or not ?
  25306. */
  25307. alive: boolean;
  25308. /**
  25309. * Is the particle visible or not ?
  25310. */
  25311. isVisible: boolean;
  25312. /**
  25313. * Index of this particle in the global "positions" array (Internal use)
  25314. * @hidden
  25315. */
  25316. _pos: number;
  25317. /**
  25318. * @hidden Index of this particle in the global "indices" array (Internal use)
  25319. */
  25320. _ind: number;
  25321. /**
  25322. * @hidden ModelShape of this particle (Internal use)
  25323. */
  25324. _model: ModelShape;
  25325. /**
  25326. * ModelShape id of this particle
  25327. */
  25328. shapeId: number;
  25329. /**
  25330. * Index of the particle in its shape id (Internal use)
  25331. */
  25332. idxInShape: number;
  25333. /**
  25334. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25335. */
  25336. _modelBoundingInfo: BoundingInfo;
  25337. /**
  25338. * @hidden Particle BoundingInfo object (Internal use)
  25339. */
  25340. _boundingInfo: BoundingInfo;
  25341. /**
  25342. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25343. */
  25344. _sps: SolidParticleSystem;
  25345. /**
  25346. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25347. */
  25348. _stillInvisible: boolean;
  25349. /**
  25350. * @hidden Last computed particle rotation matrix
  25351. */
  25352. _rotationMatrix: number[];
  25353. /**
  25354. * Parent particle Id, if any.
  25355. * Default null.
  25356. */
  25357. parentId: Nullable<number>;
  25358. /**
  25359. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25360. * The possible values are :
  25361. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25362. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25363. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25364. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25365. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25366. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25367. * */
  25368. cullingStrategy: number;
  25369. /**
  25370. * @hidden Internal global position in the SPS.
  25371. */
  25372. _globalPosition: Vector3;
  25373. /**
  25374. * Creates a Solid Particle object.
  25375. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25376. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25377. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25378. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25379. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25380. * @param shapeId (integer) is the model shape identifier in the SPS.
  25381. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25382. * @param sps defines the sps it is associated to
  25383. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25384. */
  25385. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25386. /**
  25387. * Legacy support, changed scale to scaling
  25388. */
  25389. /**
  25390. * Legacy support, changed scale to scaling
  25391. */
  25392. scale: Vector3;
  25393. /**
  25394. * Legacy support, changed quaternion to rotationQuaternion
  25395. */
  25396. /**
  25397. * Legacy support, changed quaternion to rotationQuaternion
  25398. */
  25399. quaternion: Nullable<Quaternion>;
  25400. /**
  25401. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25402. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25403. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25404. * @returns true if it intersects
  25405. */
  25406. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25407. /**
  25408. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25409. * A particle is in the frustum if its bounding box intersects the frustum
  25410. * @param frustumPlanes defines the frustum to test
  25411. * @returns true if the particle is in the frustum planes
  25412. */
  25413. isInFrustum(frustumPlanes: Plane[]): boolean;
  25414. /**
  25415. * get the rotation matrix of the particle
  25416. * @hidden
  25417. */
  25418. getRotationMatrix(m: Matrix): void;
  25419. }
  25420. /**
  25421. * Represents the shape of the model used by one particle of a solid particle system.
  25422. * SPS internal tool, don't use it manually.
  25423. */
  25424. export class ModelShape {
  25425. /**
  25426. * The shape id
  25427. * @hidden
  25428. */
  25429. shapeID: number;
  25430. /**
  25431. * flat array of model positions (internal use)
  25432. * @hidden
  25433. */
  25434. _shape: Vector3[];
  25435. /**
  25436. * flat array of model UVs (internal use)
  25437. * @hidden
  25438. */
  25439. _shapeUV: number[];
  25440. /**
  25441. * length of the shape in the model indices array (internal use)
  25442. * @hidden
  25443. */
  25444. _indicesLength: number;
  25445. /**
  25446. * Custom position function (internal use)
  25447. * @hidden
  25448. */
  25449. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25450. /**
  25451. * Custom vertex function (internal use)
  25452. * @hidden
  25453. */
  25454. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25455. /**
  25456. * 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.
  25457. * SPS internal tool, don't use it manually.
  25458. * @hidden
  25459. */
  25460. 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>);
  25461. }
  25462. /**
  25463. * Represents a Depth Sorted Particle in the solid particle system.
  25464. */
  25465. export class DepthSortedParticle {
  25466. /**
  25467. * Index of the particle in the "indices" array
  25468. */
  25469. ind: number;
  25470. /**
  25471. * Length of the particle shape in the "indices" array
  25472. */
  25473. indicesLength: number;
  25474. /**
  25475. * Squared distance from the particle to the camera
  25476. */
  25477. sqDistance: number;
  25478. }
  25479. }
  25480. declare module BABYLON {
  25481. /**
  25482. * @hidden
  25483. */
  25484. export class _MeshCollisionData {
  25485. _checkCollisions: boolean;
  25486. _collisionMask: number;
  25487. _collisionGroup: number;
  25488. _collider: Nullable<Collider>;
  25489. _oldPositionForCollisions: Vector3;
  25490. _diffPositionForCollisions: Vector3;
  25491. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25492. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25493. }
  25494. }
  25495. declare module BABYLON {
  25496. /** @hidden */
  25497. class _FacetDataStorage {
  25498. facetPositions: Vector3[];
  25499. facetNormals: Vector3[];
  25500. facetPartitioning: number[][];
  25501. facetNb: number;
  25502. partitioningSubdivisions: number;
  25503. partitioningBBoxRatio: number;
  25504. facetDataEnabled: boolean;
  25505. facetParameters: any;
  25506. bbSize: Vector3;
  25507. subDiv: {
  25508. max: number;
  25509. X: number;
  25510. Y: number;
  25511. Z: number;
  25512. };
  25513. facetDepthSort: boolean;
  25514. facetDepthSortEnabled: boolean;
  25515. depthSortedIndices: IndicesArray;
  25516. depthSortedFacets: {
  25517. ind: number;
  25518. sqDistance: number;
  25519. }[];
  25520. facetDepthSortFunction: (f1: {
  25521. ind: number;
  25522. sqDistance: number;
  25523. }, f2: {
  25524. ind: number;
  25525. sqDistance: number;
  25526. }) => number;
  25527. facetDepthSortFrom: Vector3;
  25528. facetDepthSortOrigin: Vector3;
  25529. invertedMatrix: Matrix;
  25530. }
  25531. /**
  25532. * @hidden
  25533. **/
  25534. class _InternalAbstractMeshDataInfo {
  25535. _hasVertexAlpha: boolean;
  25536. _useVertexColors: boolean;
  25537. _numBoneInfluencers: number;
  25538. _applyFog: boolean;
  25539. _receiveShadows: boolean;
  25540. _facetData: _FacetDataStorage;
  25541. _visibility: number;
  25542. _skeleton: Nullable<Skeleton>;
  25543. _layerMask: number;
  25544. _computeBonesUsingShaders: boolean;
  25545. _isActive: boolean;
  25546. _onlyForInstances: boolean;
  25547. _isActiveIntermediate: boolean;
  25548. _onlyForInstancesIntermediate: boolean;
  25549. }
  25550. /**
  25551. * Class used to store all common mesh properties
  25552. */
  25553. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25554. /** No occlusion */
  25555. static OCCLUSION_TYPE_NONE: number;
  25556. /** Occlusion set to optimisitic */
  25557. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25558. /** Occlusion set to strict */
  25559. static OCCLUSION_TYPE_STRICT: number;
  25560. /** Use an accurante occlusion algorithm */
  25561. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25562. /** Use a conservative occlusion algorithm */
  25563. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25564. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25565. * Test order :
  25566. * Is the bounding sphere outside the frustum ?
  25567. * If not, are the bounding box vertices outside the frustum ?
  25568. * It not, then the cullable object is in the frustum.
  25569. */
  25570. static readonly CULLINGSTRATEGY_STANDARD: number;
  25571. /** Culling strategy : Bounding Sphere Only.
  25572. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25573. * It's also less accurate than the standard because some not visible objects can still be selected.
  25574. * Test : is the bounding sphere outside the frustum ?
  25575. * If not, then the cullable object is in the frustum.
  25576. */
  25577. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25578. /** Culling strategy : Optimistic Inclusion.
  25579. * This in an inclusion test first, then the standard exclusion test.
  25580. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25581. * 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.
  25582. * Anyway, it's as accurate as the standard strategy.
  25583. * Test :
  25584. * Is the cullable object bounding sphere center in the frustum ?
  25585. * If not, apply the default culling strategy.
  25586. */
  25587. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25588. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25589. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25590. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25591. * 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.
  25592. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25593. * Test :
  25594. * Is the cullable object bounding sphere center in the frustum ?
  25595. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25596. */
  25597. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25598. /**
  25599. * No billboard
  25600. */
  25601. static readonly BILLBOARDMODE_NONE: number;
  25602. /** Billboard on X axis */
  25603. static readonly BILLBOARDMODE_X: number;
  25604. /** Billboard on Y axis */
  25605. static readonly BILLBOARDMODE_Y: number;
  25606. /** Billboard on Z axis */
  25607. static readonly BILLBOARDMODE_Z: number;
  25608. /** Billboard on all axes */
  25609. static readonly BILLBOARDMODE_ALL: number;
  25610. /** Billboard on using position instead of orientation */
  25611. static readonly BILLBOARDMODE_USE_POSITION: number;
  25612. /** @hidden */
  25613. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25614. /**
  25615. * The culling strategy to use to check whether the mesh must be rendered or not.
  25616. * This value can be changed at any time and will be used on the next render mesh selection.
  25617. * The possible values are :
  25618. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25619. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25620. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25621. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25622. * Please read each static variable documentation to get details about the culling process.
  25623. * */
  25624. cullingStrategy: number;
  25625. /**
  25626. * Gets the number of facets in the mesh
  25627. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25628. */
  25629. readonly facetNb: number;
  25630. /**
  25631. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25632. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25633. */
  25634. partitioningSubdivisions: number;
  25635. /**
  25636. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25637. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25638. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25639. */
  25640. partitioningBBoxRatio: number;
  25641. /**
  25642. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25643. * Works only for updatable meshes.
  25644. * Doesn't work with multi-materials
  25645. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25646. */
  25647. mustDepthSortFacets: boolean;
  25648. /**
  25649. * The location (Vector3) where the facet depth sort must be computed from.
  25650. * By default, the active camera position.
  25651. * Used only when facet depth sort is enabled
  25652. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25653. */
  25654. facetDepthSortFrom: Vector3;
  25655. /**
  25656. * gets a boolean indicating if facetData is enabled
  25657. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25658. */
  25659. readonly isFacetDataEnabled: boolean;
  25660. /** @hidden */
  25661. _updateNonUniformScalingState(value: boolean): boolean;
  25662. /**
  25663. * An event triggered when this mesh collides with another one
  25664. */
  25665. onCollideObservable: Observable<AbstractMesh>;
  25666. /** Set a function to call when this mesh collides with another one */
  25667. onCollide: () => void;
  25668. /**
  25669. * An event triggered when the collision's position changes
  25670. */
  25671. onCollisionPositionChangeObservable: Observable<Vector3>;
  25672. /** Set a function to call when the collision's position changes */
  25673. onCollisionPositionChange: () => void;
  25674. /**
  25675. * An event triggered when material is changed
  25676. */
  25677. onMaterialChangedObservable: Observable<AbstractMesh>;
  25678. /**
  25679. * Gets or sets the orientation for POV movement & rotation
  25680. */
  25681. definedFacingForward: boolean;
  25682. /** @hidden */
  25683. _occlusionQuery: Nullable<WebGLQuery>;
  25684. /** @hidden */
  25685. _renderingGroup: Nullable<RenderingGroup>;
  25686. /**
  25687. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25688. */
  25689. /**
  25690. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25691. */
  25692. visibility: number;
  25693. /** Gets or sets the alpha index used to sort transparent meshes
  25694. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25695. */
  25696. alphaIndex: number;
  25697. /**
  25698. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25699. */
  25700. isVisible: boolean;
  25701. /**
  25702. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25703. */
  25704. isPickable: boolean;
  25705. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25706. showSubMeshesBoundingBox: boolean;
  25707. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25708. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25709. */
  25710. isBlocker: boolean;
  25711. /**
  25712. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25713. */
  25714. enablePointerMoveEvents: boolean;
  25715. /**
  25716. * Specifies the rendering group id for this mesh (0 by default)
  25717. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25718. */
  25719. renderingGroupId: number;
  25720. private _material;
  25721. /** Gets or sets current material */
  25722. material: Nullable<Material>;
  25723. /**
  25724. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25725. * @see http://doc.babylonjs.com/babylon101/shadows
  25726. */
  25727. receiveShadows: boolean;
  25728. /** Defines color to use when rendering outline */
  25729. outlineColor: Color3;
  25730. /** Define width to use when rendering outline */
  25731. outlineWidth: number;
  25732. /** Defines color to use when rendering overlay */
  25733. overlayColor: Color3;
  25734. /** Defines alpha to use when rendering overlay */
  25735. overlayAlpha: number;
  25736. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25737. hasVertexAlpha: boolean;
  25738. /** 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) */
  25739. useVertexColors: boolean;
  25740. /**
  25741. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25742. */
  25743. computeBonesUsingShaders: boolean;
  25744. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25745. numBoneInfluencers: number;
  25746. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25747. applyFog: boolean;
  25748. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25749. useOctreeForRenderingSelection: boolean;
  25750. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25751. useOctreeForPicking: boolean;
  25752. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25753. useOctreeForCollisions: boolean;
  25754. /**
  25755. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25756. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25757. */
  25758. layerMask: number;
  25759. /**
  25760. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25761. */
  25762. alwaysSelectAsActiveMesh: boolean;
  25763. /**
  25764. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25765. */
  25766. doNotSyncBoundingInfo: boolean;
  25767. /**
  25768. * Gets or sets the current action manager
  25769. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25770. */
  25771. actionManager: Nullable<AbstractActionManager>;
  25772. private _meshCollisionData;
  25773. /**
  25774. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25775. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25776. */
  25777. ellipsoid: Vector3;
  25778. /**
  25779. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25780. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25781. */
  25782. ellipsoidOffset: Vector3;
  25783. /**
  25784. * Gets or sets a collision mask used to mask collisions (default is -1).
  25785. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25786. */
  25787. collisionMask: number;
  25788. /**
  25789. * Gets or sets the current collision group mask (-1 by default).
  25790. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25791. */
  25792. collisionGroup: number;
  25793. /**
  25794. * Defines edge width used when edgesRenderer is enabled
  25795. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25796. */
  25797. edgesWidth: number;
  25798. /**
  25799. * Defines edge color used when edgesRenderer is enabled
  25800. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25801. */
  25802. edgesColor: Color4;
  25803. /** @hidden */
  25804. _edgesRenderer: Nullable<IEdgesRenderer>;
  25805. /** @hidden */
  25806. _masterMesh: Nullable<AbstractMesh>;
  25807. /** @hidden */
  25808. _boundingInfo: Nullable<BoundingInfo>;
  25809. /** @hidden */
  25810. _renderId: number;
  25811. /**
  25812. * Gets or sets the list of subMeshes
  25813. * @see http://doc.babylonjs.com/how_to/multi_materials
  25814. */
  25815. subMeshes: SubMesh[];
  25816. /** @hidden */
  25817. _intersectionsInProgress: AbstractMesh[];
  25818. /** @hidden */
  25819. _unIndexed: boolean;
  25820. /** @hidden */
  25821. _lightSources: Light[];
  25822. /** Gets the list of lights affecting that mesh */
  25823. readonly lightSources: Light[];
  25824. /** @hidden */
  25825. readonly _positions: Nullable<Vector3[]>;
  25826. /** @hidden */
  25827. _waitingData: {
  25828. lods: Nullable<any>;
  25829. actions: Nullable<any>;
  25830. freezeWorldMatrix: Nullable<boolean>;
  25831. };
  25832. /** @hidden */
  25833. _bonesTransformMatrices: Nullable<Float32Array>;
  25834. /** @hidden */
  25835. _transformMatrixTexture: Nullable<RawTexture>;
  25836. /**
  25837. * Gets or sets a skeleton to apply skining transformations
  25838. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25839. */
  25840. skeleton: Nullable<Skeleton>;
  25841. /**
  25842. * An event triggered when the mesh is rebuilt.
  25843. */
  25844. onRebuildObservable: Observable<AbstractMesh>;
  25845. /**
  25846. * Creates a new AbstractMesh
  25847. * @param name defines the name of the mesh
  25848. * @param scene defines the hosting scene
  25849. */
  25850. constructor(name: string, scene?: Nullable<Scene>);
  25851. /**
  25852. * Returns the string "AbstractMesh"
  25853. * @returns "AbstractMesh"
  25854. */
  25855. getClassName(): string;
  25856. /**
  25857. * Gets a string representation of the current mesh
  25858. * @param fullDetails defines a boolean indicating if full details must be included
  25859. * @returns a string representation of the current mesh
  25860. */
  25861. toString(fullDetails?: boolean): string;
  25862. /**
  25863. * @hidden
  25864. */
  25865. protected _getEffectiveParent(): Nullable<Node>;
  25866. /** @hidden */
  25867. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25868. /** @hidden */
  25869. _rebuild(): void;
  25870. /** @hidden */
  25871. _resyncLightSources(): void;
  25872. /** @hidden */
  25873. _resyncLighSource(light: Light): void;
  25874. /** @hidden */
  25875. _unBindEffect(): void;
  25876. /** @hidden */
  25877. _removeLightSource(light: Light): void;
  25878. private _markSubMeshesAsDirty;
  25879. /** @hidden */
  25880. _markSubMeshesAsLightDirty(): void;
  25881. /** @hidden */
  25882. _markSubMeshesAsAttributesDirty(): void;
  25883. /** @hidden */
  25884. _markSubMeshesAsMiscDirty(): void;
  25885. /**
  25886. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25887. */
  25888. scaling: Vector3;
  25889. /**
  25890. * Returns true if the mesh is blocked. Implemented by child classes
  25891. */
  25892. readonly isBlocked: boolean;
  25893. /**
  25894. * Returns the mesh itself by default. Implemented by child classes
  25895. * @param camera defines the camera to use to pick the right LOD level
  25896. * @returns the currentAbstractMesh
  25897. */
  25898. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25899. /**
  25900. * Returns 0 by default. Implemented by child classes
  25901. * @returns an integer
  25902. */
  25903. getTotalVertices(): number;
  25904. /**
  25905. * Returns a positive integer : the total number of indices in this mesh geometry.
  25906. * @returns the numner of indices or zero if the mesh has no geometry.
  25907. */
  25908. getTotalIndices(): number;
  25909. /**
  25910. * Returns null by default. Implemented by child classes
  25911. * @returns null
  25912. */
  25913. getIndices(): Nullable<IndicesArray>;
  25914. /**
  25915. * Returns the array of the requested vertex data kind. Implemented by child classes
  25916. * @param kind defines the vertex data kind to use
  25917. * @returns null
  25918. */
  25919. getVerticesData(kind: string): Nullable<FloatArray>;
  25920. /**
  25921. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25922. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25923. * Note that a new underlying VertexBuffer object is created each call.
  25924. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25925. * @param kind defines vertex data kind:
  25926. * * VertexBuffer.PositionKind
  25927. * * VertexBuffer.UVKind
  25928. * * VertexBuffer.UV2Kind
  25929. * * VertexBuffer.UV3Kind
  25930. * * VertexBuffer.UV4Kind
  25931. * * VertexBuffer.UV5Kind
  25932. * * VertexBuffer.UV6Kind
  25933. * * VertexBuffer.ColorKind
  25934. * * VertexBuffer.MatricesIndicesKind
  25935. * * VertexBuffer.MatricesIndicesExtraKind
  25936. * * VertexBuffer.MatricesWeightsKind
  25937. * * VertexBuffer.MatricesWeightsExtraKind
  25938. * @param data defines the data source
  25939. * @param updatable defines if the data must be flagged as updatable (or static)
  25940. * @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
  25941. * @returns the current mesh
  25942. */
  25943. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25944. /**
  25945. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25946. * If the mesh has no geometry, it is simply returned as it is.
  25947. * @param kind defines vertex data kind:
  25948. * * VertexBuffer.PositionKind
  25949. * * VertexBuffer.UVKind
  25950. * * VertexBuffer.UV2Kind
  25951. * * VertexBuffer.UV3Kind
  25952. * * VertexBuffer.UV4Kind
  25953. * * VertexBuffer.UV5Kind
  25954. * * VertexBuffer.UV6Kind
  25955. * * VertexBuffer.ColorKind
  25956. * * VertexBuffer.MatricesIndicesKind
  25957. * * VertexBuffer.MatricesIndicesExtraKind
  25958. * * VertexBuffer.MatricesWeightsKind
  25959. * * VertexBuffer.MatricesWeightsExtraKind
  25960. * @param data defines the data source
  25961. * @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
  25962. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25963. * @returns the current mesh
  25964. */
  25965. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25966. /**
  25967. * Sets the mesh indices,
  25968. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25969. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25970. * @param totalVertices Defines the total number of vertices
  25971. * @returns the current mesh
  25972. */
  25973. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25974. /**
  25975. * Gets a boolean indicating if specific vertex data is present
  25976. * @param kind defines the vertex data kind to use
  25977. * @returns true is data kind is present
  25978. */
  25979. isVerticesDataPresent(kind: string): boolean;
  25980. /**
  25981. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  25982. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  25983. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  25984. * @returns a BoundingInfo
  25985. */
  25986. getBoundingInfo(): BoundingInfo;
  25987. /**
  25988. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25989. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25990. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25991. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25992. * @returns the current mesh
  25993. */
  25994. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25995. /**
  25996. * Overwrite the current bounding info
  25997. * @param boundingInfo defines the new bounding info
  25998. * @returns the current mesh
  25999. */
  26000. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26001. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26002. readonly useBones: boolean;
  26003. /** @hidden */
  26004. _preActivate(): void;
  26005. /** @hidden */
  26006. _preActivateForIntermediateRendering(renderId: number): void;
  26007. /** @hidden */
  26008. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26009. /** @hidden */
  26010. _postActivate(): void;
  26011. /** @hidden */
  26012. _freeze(): void;
  26013. /** @hidden */
  26014. _unFreeze(): void;
  26015. /**
  26016. * Gets the current world matrix
  26017. * @returns a Matrix
  26018. */
  26019. getWorldMatrix(): Matrix;
  26020. /** @hidden */
  26021. _getWorldMatrixDeterminant(): number;
  26022. /**
  26023. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26024. */
  26025. readonly isAnInstance: boolean;
  26026. /**
  26027. * Gets a boolean indicating if this mesh has instances
  26028. */
  26029. readonly hasInstances: boolean;
  26030. /**
  26031. * Perform relative position change from the point of view of behind the front of the mesh.
  26032. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26033. * Supports definition of mesh facing forward or backward
  26034. * @param amountRight defines the distance on the right axis
  26035. * @param amountUp defines the distance on the up axis
  26036. * @param amountForward defines the distance on the forward axis
  26037. * @returns the current mesh
  26038. */
  26039. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26040. /**
  26041. * Calculate relative position change from the point of view of behind the front of the mesh.
  26042. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26043. * Supports definition of mesh facing forward or backward
  26044. * @param amountRight defines the distance on the right axis
  26045. * @param amountUp defines the distance on the up axis
  26046. * @param amountForward defines the distance on the forward axis
  26047. * @returns the new displacement vector
  26048. */
  26049. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26050. /**
  26051. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26052. * Supports definition of mesh facing forward or backward
  26053. * @param flipBack defines the flip
  26054. * @param twirlClockwise defines the twirl
  26055. * @param tiltRight defines the tilt
  26056. * @returns the current mesh
  26057. */
  26058. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26059. /**
  26060. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26061. * Supports definition of mesh facing forward or backward.
  26062. * @param flipBack defines the flip
  26063. * @param twirlClockwise defines the twirl
  26064. * @param tiltRight defines the tilt
  26065. * @returns the new rotation vector
  26066. */
  26067. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26068. /**
  26069. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26070. * This means the mesh underlying bounding box and sphere are recomputed.
  26071. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26072. * @returns the current mesh
  26073. */
  26074. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26075. /** @hidden */
  26076. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26077. /** @hidden */
  26078. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26079. /** @hidden */
  26080. _updateBoundingInfo(): AbstractMesh;
  26081. /** @hidden */
  26082. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26083. /** @hidden */
  26084. protected _afterComputeWorldMatrix(): void;
  26085. /** @hidden */
  26086. readonly _effectiveMesh: AbstractMesh;
  26087. /**
  26088. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26089. * A mesh is in the frustum if its bounding box intersects the frustum
  26090. * @param frustumPlanes defines the frustum to test
  26091. * @returns true if the mesh is in the frustum planes
  26092. */
  26093. isInFrustum(frustumPlanes: Plane[]): boolean;
  26094. /**
  26095. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26096. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26097. * @param frustumPlanes defines the frustum to test
  26098. * @returns true if the mesh is completely in the frustum planes
  26099. */
  26100. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26101. /**
  26102. * True if the mesh intersects another mesh or a SolidParticle object
  26103. * @param mesh defines a target mesh or SolidParticle to test
  26104. * @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)
  26105. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26106. * @returns true if there is an intersection
  26107. */
  26108. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26109. /**
  26110. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26111. * @param point defines the point to test
  26112. * @returns true if there is an intersection
  26113. */
  26114. intersectsPoint(point: Vector3): boolean;
  26115. /**
  26116. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26117. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26118. */
  26119. checkCollisions: boolean;
  26120. /**
  26121. * Gets Collider object used to compute collisions (not physics)
  26122. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26123. */
  26124. readonly collider: Nullable<Collider>;
  26125. /**
  26126. * Move the mesh using collision engine
  26127. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26128. * @param displacement defines the requested displacement vector
  26129. * @returns the current mesh
  26130. */
  26131. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26132. private _onCollisionPositionChange;
  26133. /** @hidden */
  26134. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26135. /** @hidden */
  26136. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26137. /** @hidden */
  26138. _checkCollision(collider: Collider): AbstractMesh;
  26139. /** @hidden */
  26140. _generatePointsArray(): boolean;
  26141. /**
  26142. * Checks if the passed Ray intersects with the mesh
  26143. * @param ray defines the ray to use
  26144. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26145. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26146. * @returns the picking info
  26147. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26148. */
  26149. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26150. /**
  26151. * Clones the current mesh
  26152. * @param name defines the mesh name
  26153. * @param newParent defines the new mesh parent
  26154. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26155. * @returns the new mesh
  26156. */
  26157. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26158. /**
  26159. * Disposes all the submeshes of the current meshnp
  26160. * @returns the current mesh
  26161. */
  26162. releaseSubMeshes(): AbstractMesh;
  26163. /**
  26164. * Releases resources associated with this abstract mesh.
  26165. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26166. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26167. */
  26168. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26169. /**
  26170. * Adds the passed mesh as a child to the current mesh
  26171. * @param mesh defines the child mesh
  26172. * @returns the current mesh
  26173. */
  26174. addChild(mesh: AbstractMesh): AbstractMesh;
  26175. /**
  26176. * Removes the passed mesh from the current mesh children list
  26177. * @param mesh defines the child mesh
  26178. * @returns the current mesh
  26179. */
  26180. removeChild(mesh: AbstractMesh): AbstractMesh;
  26181. /** @hidden */
  26182. private _initFacetData;
  26183. /**
  26184. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26185. * This method can be called within the render loop.
  26186. * 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
  26187. * @returns the current mesh
  26188. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26189. */
  26190. updateFacetData(): AbstractMesh;
  26191. /**
  26192. * Returns the facetLocalNormals array.
  26193. * The normals are expressed in the mesh local spac
  26194. * @returns an array of Vector3
  26195. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26196. */
  26197. getFacetLocalNormals(): Vector3[];
  26198. /**
  26199. * Returns the facetLocalPositions array.
  26200. * The facet positions are expressed in the mesh local space
  26201. * @returns an array of Vector3
  26202. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26203. */
  26204. getFacetLocalPositions(): Vector3[];
  26205. /**
  26206. * Returns the facetLocalPartioning array
  26207. * @returns an array of array of numbers
  26208. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26209. */
  26210. getFacetLocalPartitioning(): number[][];
  26211. /**
  26212. * Returns the i-th facet position in the world system.
  26213. * This method allocates a new Vector3 per call
  26214. * @param i defines the facet index
  26215. * @returns a new Vector3
  26216. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26217. */
  26218. getFacetPosition(i: number): Vector3;
  26219. /**
  26220. * Sets the reference Vector3 with the i-th facet position in the world system
  26221. * @param i defines the facet index
  26222. * @param ref defines the target vector
  26223. * @returns the current mesh
  26224. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26225. */
  26226. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26227. /**
  26228. * Returns the i-th facet normal in the world system.
  26229. * This method allocates a new Vector3 per call
  26230. * @param i defines the facet index
  26231. * @returns a new Vector3
  26232. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26233. */
  26234. getFacetNormal(i: number): Vector3;
  26235. /**
  26236. * Sets the reference Vector3 with the i-th facet normal in the world system
  26237. * @param i defines the facet index
  26238. * @param ref defines the target vector
  26239. * @returns the current mesh
  26240. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26241. */
  26242. getFacetNormalToRef(i: number, ref: Vector3): this;
  26243. /**
  26244. * 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)
  26245. * @param x defines x coordinate
  26246. * @param y defines y coordinate
  26247. * @param z defines z coordinate
  26248. * @returns the array of facet indexes
  26249. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26250. */
  26251. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26252. /**
  26253. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26254. * @param projected sets as the (x,y,z) world projection on the facet
  26255. * @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
  26256. * @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
  26257. * @param x defines x coordinate
  26258. * @param y defines y coordinate
  26259. * @param z defines z coordinate
  26260. * @returns the face index if found (or null instead)
  26261. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26262. */
  26263. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26264. /**
  26265. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26266. * @param projected sets as the (x,y,z) local projection on the facet
  26267. * @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
  26268. * @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
  26269. * @param x defines x coordinate
  26270. * @param y defines y coordinate
  26271. * @param z defines z coordinate
  26272. * @returns the face index if found (or null instead)
  26273. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26274. */
  26275. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26276. /**
  26277. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26278. * @returns the parameters
  26279. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26280. */
  26281. getFacetDataParameters(): any;
  26282. /**
  26283. * Disables the feature FacetData and frees the related memory
  26284. * @returns the current mesh
  26285. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26286. */
  26287. disableFacetData(): AbstractMesh;
  26288. /**
  26289. * Updates the AbstractMesh indices array
  26290. * @param indices defines the data source
  26291. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26292. * @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)
  26293. * @returns the current mesh
  26294. */
  26295. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26296. /**
  26297. * Creates new normals data for the mesh
  26298. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26299. * @returns the current mesh
  26300. */
  26301. createNormals(updatable: boolean): AbstractMesh;
  26302. /**
  26303. * Align the mesh with a normal
  26304. * @param normal defines the normal to use
  26305. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26306. * @returns the current mesh
  26307. */
  26308. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26309. /** @hidden */
  26310. _checkOcclusionQuery(): boolean;
  26311. /**
  26312. * Disables the mesh edge rendering mode
  26313. * @returns the currentAbstractMesh
  26314. */
  26315. disableEdgesRendering(): AbstractMesh;
  26316. /**
  26317. * Enables the edge rendering mode on the mesh.
  26318. * This mode makes the mesh edges visible
  26319. * @param epsilon defines the maximal distance between two angles to detect a face
  26320. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26321. * @returns the currentAbstractMesh
  26322. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26323. */
  26324. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26325. }
  26326. }
  26327. declare module BABYLON {
  26328. /**
  26329. * Interface used to define ActionEvent
  26330. */
  26331. export interface IActionEvent {
  26332. /** The mesh or sprite that triggered the action */
  26333. source: any;
  26334. /** The X mouse cursor position at the time of the event */
  26335. pointerX: number;
  26336. /** The Y mouse cursor position at the time of the event */
  26337. pointerY: number;
  26338. /** The mesh that is currently pointed at (can be null) */
  26339. meshUnderPointer: Nullable<AbstractMesh>;
  26340. /** the original (browser) event that triggered the ActionEvent */
  26341. sourceEvent?: any;
  26342. /** additional data for the event */
  26343. additionalData?: any;
  26344. }
  26345. /**
  26346. * ActionEvent is the event being sent when an action is triggered.
  26347. */
  26348. export class ActionEvent implements IActionEvent {
  26349. /** The mesh or sprite that triggered the action */
  26350. source: any;
  26351. /** The X mouse cursor position at the time of the event */
  26352. pointerX: number;
  26353. /** The Y mouse cursor position at the time of the event */
  26354. pointerY: number;
  26355. /** The mesh that is currently pointed at (can be null) */
  26356. meshUnderPointer: Nullable<AbstractMesh>;
  26357. /** the original (browser) event that triggered the ActionEvent */
  26358. sourceEvent?: any;
  26359. /** additional data for the event */
  26360. additionalData?: any;
  26361. /**
  26362. * Creates a new ActionEvent
  26363. * @param source The mesh or sprite that triggered the action
  26364. * @param pointerX The X mouse cursor position at the time of the event
  26365. * @param pointerY The Y mouse cursor position at the time of the event
  26366. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26367. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26368. * @param additionalData additional data for the event
  26369. */
  26370. constructor(
  26371. /** The mesh or sprite that triggered the action */
  26372. source: any,
  26373. /** The X mouse cursor position at the time of the event */
  26374. pointerX: number,
  26375. /** The Y mouse cursor position at the time of the event */
  26376. pointerY: number,
  26377. /** The mesh that is currently pointed at (can be null) */
  26378. meshUnderPointer: Nullable<AbstractMesh>,
  26379. /** the original (browser) event that triggered the ActionEvent */
  26380. sourceEvent?: any,
  26381. /** additional data for the event */
  26382. additionalData?: any);
  26383. /**
  26384. * Helper function to auto-create an ActionEvent from a source mesh.
  26385. * @param source The source mesh that triggered the event
  26386. * @param evt The original (browser) event
  26387. * @param additionalData additional data for the event
  26388. * @returns the new ActionEvent
  26389. */
  26390. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26391. /**
  26392. * Helper function to auto-create an ActionEvent from a source sprite
  26393. * @param source The source sprite that triggered the event
  26394. * @param scene Scene associated with the sprite
  26395. * @param evt The original (browser) event
  26396. * @param additionalData additional data for the event
  26397. * @returns the new ActionEvent
  26398. */
  26399. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26400. /**
  26401. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26402. * @param scene the scene where the event occurred
  26403. * @param evt The original (browser) event
  26404. * @returns the new ActionEvent
  26405. */
  26406. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26407. /**
  26408. * Helper function to auto-create an ActionEvent from a primitive
  26409. * @param prim defines the target primitive
  26410. * @param pointerPos defines the pointer position
  26411. * @param evt The original (browser) event
  26412. * @param additionalData additional data for the event
  26413. * @returns the new ActionEvent
  26414. */
  26415. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26416. }
  26417. }
  26418. declare module BABYLON {
  26419. /**
  26420. * Abstract class used to decouple action Manager from scene and meshes.
  26421. * Do not instantiate.
  26422. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26423. */
  26424. export abstract class AbstractActionManager implements IDisposable {
  26425. /** Gets the list of active triggers */
  26426. static Triggers: {
  26427. [key: string]: number;
  26428. };
  26429. /** Gets the cursor to use when hovering items */
  26430. hoverCursor: string;
  26431. /** Gets the list of actions */
  26432. actions: IAction[];
  26433. /**
  26434. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26435. */
  26436. isRecursive: boolean;
  26437. /**
  26438. * Releases all associated resources
  26439. */
  26440. abstract dispose(): void;
  26441. /**
  26442. * Does this action manager has pointer triggers
  26443. */
  26444. abstract readonly hasPointerTriggers: boolean;
  26445. /**
  26446. * Does this action manager has pick triggers
  26447. */
  26448. abstract readonly hasPickTriggers: boolean;
  26449. /**
  26450. * Process a specific trigger
  26451. * @param trigger defines the trigger to process
  26452. * @param evt defines the event details to be processed
  26453. */
  26454. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26455. /**
  26456. * Does this action manager handles actions of any of the given triggers
  26457. * @param triggers defines the triggers to be tested
  26458. * @return a boolean indicating whether one (or more) of the triggers is handled
  26459. */
  26460. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26461. /**
  26462. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26463. * speed.
  26464. * @param triggerA defines the trigger to be tested
  26465. * @param triggerB defines the trigger to be tested
  26466. * @return a boolean indicating whether one (or more) of the triggers is handled
  26467. */
  26468. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26469. /**
  26470. * Does this action manager handles actions of a given trigger
  26471. * @param trigger defines the trigger to be tested
  26472. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26473. * @return whether the trigger is handled
  26474. */
  26475. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26476. /**
  26477. * Serialize this manager to a JSON object
  26478. * @param name defines the property name to store this manager
  26479. * @returns a JSON representation of this manager
  26480. */
  26481. abstract serialize(name: string): any;
  26482. /**
  26483. * Registers an action to this action manager
  26484. * @param action defines the action to be registered
  26485. * @return the action amended (prepared) after registration
  26486. */
  26487. abstract registerAction(action: IAction): Nullable<IAction>;
  26488. /**
  26489. * Unregisters an action to this action manager
  26490. * @param action defines the action to be unregistered
  26491. * @return a boolean indicating whether the action has been unregistered
  26492. */
  26493. abstract unregisterAction(action: IAction): Boolean;
  26494. /**
  26495. * Does exist one action manager with at least one trigger
  26496. **/
  26497. static readonly HasTriggers: boolean;
  26498. /**
  26499. * Does exist one action manager with at least one pick trigger
  26500. **/
  26501. static readonly HasPickTriggers: boolean;
  26502. /**
  26503. * Does exist one action manager that handles actions of a given trigger
  26504. * @param trigger defines the trigger to be tested
  26505. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26506. **/
  26507. static HasSpecificTrigger(trigger: number): boolean;
  26508. }
  26509. }
  26510. declare module BABYLON {
  26511. /**
  26512. * Defines how a node can be built from a string name.
  26513. */
  26514. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26515. /**
  26516. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26517. */
  26518. export class Node implements IBehaviorAware<Node> {
  26519. /** @hidden */
  26520. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26521. private static _NodeConstructors;
  26522. /**
  26523. * Add a new node constructor
  26524. * @param type defines the type name of the node to construct
  26525. * @param constructorFunc defines the constructor function
  26526. */
  26527. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26528. /**
  26529. * Returns a node constructor based on type name
  26530. * @param type defines the type name
  26531. * @param name defines the new node name
  26532. * @param scene defines the hosting scene
  26533. * @param options defines optional options to transmit to constructors
  26534. * @returns the new constructor or null
  26535. */
  26536. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26537. /**
  26538. * Gets or sets the name of the node
  26539. */
  26540. name: string;
  26541. /**
  26542. * Gets or sets the id of the node
  26543. */
  26544. id: string;
  26545. /**
  26546. * Gets or sets the unique id of the node
  26547. */
  26548. uniqueId: number;
  26549. /**
  26550. * Gets or sets a string used to store user defined state for the node
  26551. */
  26552. state: string;
  26553. /**
  26554. * Gets or sets an object used to store user defined information for the node
  26555. */
  26556. metadata: any;
  26557. /**
  26558. * For internal use only. Please do not use.
  26559. */
  26560. reservedDataStore: any;
  26561. /**
  26562. * List of inspectable custom properties (used by the Inspector)
  26563. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26564. */
  26565. inspectableCustomProperties: IInspectable[];
  26566. /**
  26567. * Gets or sets a boolean used to define if the node must be serialized
  26568. */
  26569. doNotSerialize: boolean;
  26570. /** @hidden */
  26571. _isDisposed: boolean;
  26572. /**
  26573. * Gets a list of Animations associated with the node
  26574. */
  26575. animations: Animation[];
  26576. protected _ranges: {
  26577. [name: string]: Nullable<AnimationRange>;
  26578. };
  26579. /**
  26580. * Callback raised when the node is ready to be used
  26581. */
  26582. onReady: Nullable<(node: Node) => void>;
  26583. private _isEnabled;
  26584. private _isParentEnabled;
  26585. private _isReady;
  26586. /** @hidden */
  26587. _currentRenderId: number;
  26588. private _parentUpdateId;
  26589. /** @hidden */
  26590. _childUpdateId: number;
  26591. /** @hidden */
  26592. _waitingParentId: Nullable<string>;
  26593. /** @hidden */
  26594. _scene: Scene;
  26595. /** @hidden */
  26596. _cache: any;
  26597. private _parentNode;
  26598. private _children;
  26599. /** @hidden */
  26600. _worldMatrix: Matrix;
  26601. /** @hidden */
  26602. _worldMatrixDeterminant: number;
  26603. /** @hidden */
  26604. _worldMatrixDeterminantIsDirty: boolean;
  26605. /** @hidden */
  26606. private _sceneRootNodesIndex;
  26607. /**
  26608. * Gets a boolean indicating if the node has been disposed
  26609. * @returns true if the node was disposed
  26610. */
  26611. isDisposed(): boolean;
  26612. /**
  26613. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26614. * @see https://doc.babylonjs.com/how_to/parenting
  26615. */
  26616. parent: Nullable<Node>;
  26617. private addToSceneRootNodes;
  26618. private removeFromSceneRootNodes;
  26619. private _animationPropertiesOverride;
  26620. /**
  26621. * Gets or sets the animation properties override
  26622. */
  26623. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26624. /**
  26625. * Gets a string idenfifying the name of the class
  26626. * @returns "Node" string
  26627. */
  26628. getClassName(): string;
  26629. /** @hidden */
  26630. readonly _isNode: boolean;
  26631. /**
  26632. * An event triggered when the mesh is disposed
  26633. */
  26634. onDisposeObservable: Observable<Node>;
  26635. private _onDisposeObserver;
  26636. /**
  26637. * Sets a callback that will be raised when the node will be disposed
  26638. */
  26639. onDispose: () => void;
  26640. /**
  26641. * Creates a new Node
  26642. * @param name the name and id to be given to this node
  26643. * @param scene the scene this node will be added to
  26644. * @param addToRootNodes the node will be added to scene.rootNodes
  26645. */
  26646. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26647. /**
  26648. * Gets the scene of the node
  26649. * @returns a scene
  26650. */
  26651. getScene(): Scene;
  26652. /**
  26653. * Gets the engine of the node
  26654. * @returns a Engine
  26655. */
  26656. getEngine(): Engine;
  26657. private _behaviors;
  26658. /**
  26659. * Attach a behavior to the node
  26660. * @see http://doc.babylonjs.com/features/behaviour
  26661. * @param behavior defines the behavior to attach
  26662. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26663. * @returns the current Node
  26664. */
  26665. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26666. /**
  26667. * Remove an attached behavior
  26668. * @see http://doc.babylonjs.com/features/behaviour
  26669. * @param behavior defines the behavior to attach
  26670. * @returns the current Node
  26671. */
  26672. removeBehavior(behavior: Behavior<Node>): Node;
  26673. /**
  26674. * Gets the list of attached behaviors
  26675. * @see http://doc.babylonjs.com/features/behaviour
  26676. */
  26677. readonly behaviors: Behavior<Node>[];
  26678. /**
  26679. * Gets an attached behavior by name
  26680. * @param name defines the name of the behavior to look for
  26681. * @see http://doc.babylonjs.com/features/behaviour
  26682. * @returns null if behavior was not found else the requested behavior
  26683. */
  26684. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26685. /**
  26686. * Returns the latest update of the World matrix
  26687. * @returns a Matrix
  26688. */
  26689. getWorldMatrix(): Matrix;
  26690. /** @hidden */
  26691. _getWorldMatrixDeterminant(): number;
  26692. /**
  26693. * Returns directly the latest state of the mesh World matrix.
  26694. * A Matrix is returned.
  26695. */
  26696. readonly worldMatrixFromCache: Matrix;
  26697. /** @hidden */
  26698. _initCache(): void;
  26699. /** @hidden */
  26700. updateCache(force?: boolean): void;
  26701. /** @hidden */
  26702. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26703. /** @hidden */
  26704. _updateCache(ignoreParentClass?: boolean): void;
  26705. /** @hidden */
  26706. _isSynchronized(): boolean;
  26707. /** @hidden */
  26708. _markSyncedWithParent(): void;
  26709. /** @hidden */
  26710. isSynchronizedWithParent(): boolean;
  26711. /** @hidden */
  26712. isSynchronized(): boolean;
  26713. /**
  26714. * Is this node ready to be used/rendered
  26715. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26716. * @return true if the node is ready
  26717. */
  26718. isReady(completeCheck?: boolean): boolean;
  26719. /**
  26720. * Is this node enabled?
  26721. * 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
  26722. * @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
  26723. * @return whether this node (and its parent) is enabled
  26724. */
  26725. isEnabled(checkAncestors?: boolean): boolean;
  26726. /** @hidden */
  26727. protected _syncParentEnabledState(): void;
  26728. /**
  26729. * Set the enabled state of this node
  26730. * @param value defines the new enabled state
  26731. */
  26732. setEnabled(value: boolean): void;
  26733. /**
  26734. * Is this node a descendant of the given node?
  26735. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26736. * @param ancestor defines the parent node to inspect
  26737. * @returns a boolean indicating if this node is a descendant of the given node
  26738. */
  26739. isDescendantOf(ancestor: Node): boolean;
  26740. /** @hidden */
  26741. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26742. /**
  26743. * Will return all nodes that have this node as ascendant
  26744. * @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
  26745. * @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
  26746. * @return all children nodes of all types
  26747. */
  26748. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26749. /**
  26750. * Get all child-meshes of this node
  26751. * @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)
  26752. * @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
  26753. * @returns an array of AbstractMesh
  26754. */
  26755. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26756. /**
  26757. * Get all direct children of this node
  26758. * @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
  26759. * @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)
  26760. * @returns an array of Node
  26761. */
  26762. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26763. /** @hidden */
  26764. _setReady(state: boolean): void;
  26765. /**
  26766. * Get an animation by name
  26767. * @param name defines the name of the animation to look for
  26768. * @returns null if not found else the requested animation
  26769. */
  26770. getAnimationByName(name: string): Nullable<Animation>;
  26771. /**
  26772. * Creates an animation range for this node
  26773. * @param name defines the name of the range
  26774. * @param from defines the starting key
  26775. * @param to defines the end key
  26776. */
  26777. createAnimationRange(name: string, from: number, to: number): void;
  26778. /**
  26779. * Delete a specific animation range
  26780. * @param name defines the name of the range to delete
  26781. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26782. */
  26783. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26784. /**
  26785. * Get an animation range by name
  26786. * @param name defines the name of the animation range to look for
  26787. * @returns null if not found else the requested animation range
  26788. */
  26789. getAnimationRange(name: string): Nullable<AnimationRange>;
  26790. /**
  26791. * Gets the list of all animation ranges defined on this node
  26792. * @returns an array
  26793. */
  26794. getAnimationRanges(): Nullable<AnimationRange>[];
  26795. /**
  26796. * Will start the animation sequence
  26797. * @param name defines the range frames for animation sequence
  26798. * @param loop defines if the animation should loop (false by default)
  26799. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26800. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26801. * @returns the object created for this animation. If range does not exist, it will return null
  26802. */
  26803. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26804. /**
  26805. * Serialize animation ranges into a JSON compatible object
  26806. * @returns serialization object
  26807. */
  26808. serializeAnimationRanges(): any;
  26809. /**
  26810. * Computes the world matrix of the node
  26811. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26812. * @returns the world matrix
  26813. */
  26814. computeWorldMatrix(force?: boolean): Matrix;
  26815. /**
  26816. * Releases resources associated with this node.
  26817. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26818. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26819. */
  26820. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26821. /**
  26822. * Parse animation range data from a serialization object and store them into a given node
  26823. * @param node defines where to store the animation ranges
  26824. * @param parsedNode defines the serialization object to read data from
  26825. * @param scene defines the hosting scene
  26826. */
  26827. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26828. /**
  26829. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26830. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26831. * @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
  26832. * @returns the new bounding vectors
  26833. */
  26834. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26835. min: Vector3;
  26836. max: Vector3;
  26837. };
  26838. }
  26839. }
  26840. declare module BABYLON {
  26841. /**
  26842. * @hidden
  26843. */
  26844. export class _IAnimationState {
  26845. key: number;
  26846. repeatCount: number;
  26847. workValue?: any;
  26848. loopMode?: number;
  26849. offsetValue?: any;
  26850. highLimitValue?: any;
  26851. }
  26852. /**
  26853. * Class used to store any kind of animation
  26854. */
  26855. export class Animation {
  26856. /**Name of the animation */
  26857. name: string;
  26858. /**Property to animate */
  26859. targetProperty: string;
  26860. /**The frames per second of the animation */
  26861. framePerSecond: number;
  26862. /**The data type of the animation */
  26863. dataType: number;
  26864. /**The loop mode of the animation */
  26865. loopMode?: number | undefined;
  26866. /**Specifies if blending should be enabled */
  26867. enableBlending?: boolean | undefined;
  26868. /**
  26869. * Use matrix interpolation instead of using direct key value when animating matrices
  26870. */
  26871. static AllowMatricesInterpolation: boolean;
  26872. /**
  26873. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26874. */
  26875. static AllowMatrixDecomposeForInterpolation: boolean;
  26876. /**
  26877. * Stores the key frames of the animation
  26878. */
  26879. private _keys;
  26880. /**
  26881. * Stores the easing function of the animation
  26882. */
  26883. private _easingFunction;
  26884. /**
  26885. * @hidden Internal use only
  26886. */
  26887. _runtimeAnimations: RuntimeAnimation[];
  26888. /**
  26889. * The set of event that will be linked to this animation
  26890. */
  26891. private _events;
  26892. /**
  26893. * Stores an array of target property paths
  26894. */
  26895. targetPropertyPath: string[];
  26896. /**
  26897. * Stores the blending speed of the animation
  26898. */
  26899. blendingSpeed: number;
  26900. /**
  26901. * Stores the animation ranges for the animation
  26902. */
  26903. private _ranges;
  26904. /**
  26905. * @hidden Internal use
  26906. */
  26907. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26908. /**
  26909. * Sets up an animation
  26910. * @param property The property to animate
  26911. * @param animationType The animation type to apply
  26912. * @param framePerSecond The frames per second of the animation
  26913. * @param easingFunction The easing function used in the animation
  26914. * @returns The created animation
  26915. */
  26916. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26917. /**
  26918. * Create and start an animation on a node
  26919. * @param name defines the name of the global animation that will be run on all nodes
  26920. * @param node defines the root node where the animation will take place
  26921. * @param targetProperty defines property to animate
  26922. * @param framePerSecond defines the number of frame per second yo use
  26923. * @param totalFrame defines the number of frames in total
  26924. * @param from defines the initial value
  26925. * @param to defines the final value
  26926. * @param loopMode defines which loop mode you want to use (off by default)
  26927. * @param easingFunction defines the easing function to use (linear by default)
  26928. * @param onAnimationEnd defines the callback to call when animation end
  26929. * @returns the animatable created for this animation
  26930. */
  26931. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26932. /**
  26933. * Create and start an animation on a node and its descendants
  26934. * @param name defines the name of the global animation that will be run on all nodes
  26935. * @param node defines the root node where the animation will take place
  26936. * @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
  26937. * @param targetProperty defines property to animate
  26938. * @param framePerSecond defines the number of frame per second to use
  26939. * @param totalFrame defines the number of frames in total
  26940. * @param from defines the initial value
  26941. * @param to defines the final value
  26942. * @param loopMode defines which loop mode you want to use (off by default)
  26943. * @param easingFunction defines the easing function to use (linear by default)
  26944. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26945. * @returns the list of animatables created for all nodes
  26946. * @example https://www.babylonjs-playground.com/#MH0VLI
  26947. */
  26948. 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[]>;
  26949. /**
  26950. * Creates a new animation, merges it with the existing animations and starts it
  26951. * @param name Name of the animation
  26952. * @param node Node which contains the scene that begins the animations
  26953. * @param targetProperty Specifies which property to animate
  26954. * @param framePerSecond The frames per second of the animation
  26955. * @param totalFrame The total number of frames
  26956. * @param from The frame at the beginning of the animation
  26957. * @param to The frame at the end of the animation
  26958. * @param loopMode Specifies the loop mode of the animation
  26959. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26960. * @param onAnimationEnd Callback to run once the animation is complete
  26961. * @returns Nullable animation
  26962. */
  26963. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26964. /**
  26965. * Transition property of an host to the target Value
  26966. * @param property The property to transition
  26967. * @param targetValue The target Value of the property
  26968. * @param host The object where the property to animate belongs
  26969. * @param scene Scene used to run the animation
  26970. * @param frameRate Framerate (in frame/s) to use
  26971. * @param transition The transition type we want to use
  26972. * @param duration The duration of the animation, in milliseconds
  26973. * @param onAnimationEnd Callback trigger at the end of the animation
  26974. * @returns Nullable animation
  26975. */
  26976. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26977. /**
  26978. * Return the array of runtime animations currently using this animation
  26979. */
  26980. readonly runtimeAnimations: RuntimeAnimation[];
  26981. /**
  26982. * Specifies if any of the runtime animations are currently running
  26983. */
  26984. readonly hasRunningRuntimeAnimations: boolean;
  26985. /**
  26986. * Initializes the animation
  26987. * @param name Name of the animation
  26988. * @param targetProperty Property to animate
  26989. * @param framePerSecond The frames per second of the animation
  26990. * @param dataType The data type of the animation
  26991. * @param loopMode The loop mode of the animation
  26992. * @param enableBlending Specifies if blending should be enabled
  26993. */
  26994. constructor(
  26995. /**Name of the animation */
  26996. name: string,
  26997. /**Property to animate */
  26998. targetProperty: string,
  26999. /**The frames per second of the animation */
  27000. framePerSecond: number,
  27001. /**The data type of the animation */
  27002. dataType: number,
  27003. /**The loop mode of the animation */
  27004. loopMode?: number | undefined,
  27005. /**Specifies if blending should be enabled */
  27006. enableBlending?: boolean | undefined);
  27007. /**
  27008. * Converts the animation to a string
  27009. * @param fullDetails support for multiple levels of logging within scene loading
  27010. * @returns String form of the animation
  27011. */
  27012. toString(fullDetails?: boolean): string;
  27013. /**
  27014. * Add an event to this animation
  27015. * @param event Event to add
  27016. */
  27017. addEvent(event: AnimationEvent): void;
  27018. /**
  27019. * Remove all events found at the given frame
  27020. * @param frame The frame to remove events from
  27021. */
  27022. removeEvents(frame: number): void;
  27023. /**
  27024. * Retrieves all the events from the animation
  27025. * @returns Events from the animation
  27026. */
  27027. getEvents(): AnimationEvent[];
  27028. /**
  27029. * Creates an animation range
  27030. * @param name Name of the animation range
  27031. * @param from Starting frame of the animation range
  27032. * @param to Ending frame of the animation
  27033. */
  27034. createRange(name: string, from: number, to: number): void;
  27035. /**
  27036. * Deletes an animation range by name
  27037. * @param name Name of the animation range to delete
  27038. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27039. */
  27040. deleteRange(name: string, deleteFrames?: boolean): void;
  27041. /**
  27042. * Gets the animation range by name, or null if not defined
  27043. * @param name Name of the animation range
  27044. * @returns Nullable animation range
  27045. */
  27046. getRange(name: string): Nullable<AnimationRange>;
  27047. /**
  27048. * Gets the key frames from the animation
  27049. * @returns The key frames of the animation
  27050. */
  27051. getKeys(): Array<IAnimationKey>;
  27052. /**
  27053. * Gets the highest frame rate of the animation
  27054. * @returns Highest frame rate of the animation
  27055. */
  27056. getHighestFrame(): number;
  27057. /**
  27058. * Gets the easing function of the animation
  27059. * @returns Easing function of the animation
  27060. */
  27061. getEasingFunction(): IEasingFunction;
  27062. /**
  27063. * Sets the easing function of the animation
  27064. * @param easingFunction A custom mathematical formula for animation
  27065. */
  27066. setEasingFunction(easingFunction: EasingFunction): void;
  27067. /**
  27068. * Interpolates a scalar linearly
  27069. * @param startValue Start value of the animation curve
  27070. * @param endValue End value of the animation curve
  27071. * @param gradient Scalar amount to interpolate
  27072. * @returns Interpolated scalar value
  27073. */
  27074. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27075. /**
  27076. * Interpolates a scalar cubically
  27077. * @param startValue Start value of the animation curve
  27078. * @param outTangent End tangent of the animation
  27079. * @param endValue End value of the animation curve
  27080. * @param inTangent Start tangent of the animation curve
  27081. * @param gradient Scalar amount to interpolate
  27082. * @returns Interpolated scalar value
  27083. */
  27084. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27085. /**
  27086. * Interpolates a quaternion using a spherical linear interpolation
  27087. * @param startValue Start value of the animation curve
  27088. * @param endValue End value of the animation curve
  27089. * @param gradient Scalar amount to interpolate
  27090. * @returns Interpolated quaternion value
  27091. */
  27092. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27093. /**
  27094. * Interpolates a quaternion cubically
  27095. * @param startValue Start value of the animation curve
  27096. * @param outTangent End tangent of the animation curve
  27097. * @param endValue End value of the animation curve
  27098. * @param inTangent Start tangent of the animation curve
  27099. * @param gradient Scalar amount to interpolate
  27100. * @returns Interpolated quaternion value
  27101. */
  27102. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27103. /**
  27104. * Interpolates a Vector3 linearl
  27105. * @param startValue Start value of the animation curve
  27106. * @param endValue End value of the animation curve
  27107. * @param gradient Scalar amount to interpolate
  27108. * @returns Interpolated scalar value
  27109. */
  27110. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27111. /**
  27112. * Interpolates a Vector3 cubically
  27113. * @param startValue Start value of the animation curve
  27114. * @param outTangent End tangent of the animation
  27115. * @param endValue End value of the animation curve
  27116. * @param inTangent Start tangent of the animation curve
  27117. * @param gradient Scalar amount to interpolate
  27118. * @returns InterpolatedVector3 value
  27119. */
  27120. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27121. /**
  27122. * Interpolates a Vector2 linearly
  27123. * @param startValue Start value of the animation curve
  27124. * @param endValue End value of the animation curve
  27125. * @param gradient Scalar amount to interpolate
  27126. * @returns Interpolated Vector2 value
  27127. */
  27128. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27129. /**
  27130. * Interpolates a Vector2 cubically
  27131. * @param startValue Start value of the animation curve
  27132. * @param outTangent End tangent of the animation
  27133. * @param endValue End value of the animation curve
  27134. * @param inTangent Start tangent of the animation curve
  27135. * @param gradient Scalar amount to interpolate
  27136. * @returns Interpolated Vector2 value
  27137. */
  27138. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27139. /**
  27140. * Interpolates a size linearly
  27141. * @param startValue Start value of the animation curve
  27142. * @param endValue End value of the animation curve
  27143. * @param gradient Scalar amount to interpolate
  27144. * @returns Interpolated Size value
  27145. */
  27146. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27147. /**
  27148. * Interpolates a Color3 linearly
  27149. * @param startValue Start value of the animation curve
  27150. * @param endValue End value of the animation curve
  27151. * @param gradient Scalar amount to interpolate
  27152. * @returns Interpolated Color3 value
  27153. */
  27154. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27155. /**
  27156. * @hidden Internal use only
  27157. */
  27158. _getKeyValue(value: any): any;
  27159. /**
  27160. * @hidden Internal use only
  27161. */
  27162. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27163. /**
  27164. * Defines the function to use to interpolate matrices
  27165. * @param startValue defines the start matrix
  27166. * @param endValue defines the end matrix
  27167. * @param gradient defines the gradient between both matrices
  27168. * @param result defines an optional target matrix where to store the interpolation
  27169. * @returns the interpolated matrix
  27170. */
  27171. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27172. /**
  27173. * Makes a copy of the animation
  27174. * @returns Cloned animation
  27175. */
  27176. clone(): Animation;
  27177. /**
  27178. * Sets the key frames of the animation
  27179. * @param values The animation key frames to set
  27180. */
  27181. setKeys(values: Array<IAnimationKey>): void;
  27182. /**
  27183. * Serializes the animation to an object
  27184. * @returns Serialized object
  27185. */
  27186. serialize(): any;
  27187. /**
  27188. * Float animation type
  27189. */
  27190. private static _ANIMATIONTYPE_FLOAT;
  27191. /**
  27192. * Vector3 animation type
  27193. */
  27194. private static _ANIMATIONTYPE_VECTOR3;
  27195. /**
  27196. * Quaternion animation type
  27197. */
  27198. private static _ANIMATIONTYPE_QUATERNION;
  27199. /**
  27200. * Matrix animation type
  27201. */
  27202. private static _ANIMATIONTYPE_MATRIX;
  27203. /**
  27204. * Color3 animation type
  27205. */
  27206. private static _ANIMATIONTYPE_COLOR3;
  27207. /**
  27208. * Vector2 animation type
  27209. */
  27210. private static _ANIMATIONTYPE_VECTOR2;
  27211. /**
  27212. * Size animation type
  27213. */
  27214. private static _ANIMATIONTYPE_SIZE;
  27215. /**
  27216. * Relative Loop Mode
  27217. */
  27218. private static _ANIMATIONLOOPMODE_RELATIVE;
  27219. /**
  27220. * Cycle Loop Mode
  27221. */
  27222. private static _ANIMATIONLOOPMODE_CYCLE;
  27223. /**
  27224. * Constant Loop Mode
  27225. */
  27226. private static _ANIMATIONLOOPMODE_CONSTANT;
  27227. /**
  27228. * Get the float animation type
  27229. */
  27230. static readonly ANIMATIONTYPE_FLOAT: number;
  27231. /**
  27232. * Get the Vector3 animation type
  27233. */
  27234. static readonly ANIMATIONTYPE_VECTOR3: number;
  27235. /**
  27236. * Get the Vector2 animation type
  27237. */
  27238. static readonly ANIMATIONTYPE_VECTOR2: number;
  27239. /**
  27240. * Get the Size animation type
  27241. */
  27242. static readonly ANIMATIONTYPE_SIZE: number;
  27243. /**
  27244. * Get the Quaternion animation type
  27245. */
  27246. static readonly ANIMATIONTYPE_QUATERNION: number;
  27247. /**
  27248. * Get the Matrix animation type
  27249. */
  27250. static readonly ANIMATIONTYPE_MATRIX: number;
  27251. /**
  27252. * Get the Color3 animation type
  27253. */
  27254. static readonly ANIMATIONTYPE_COLOR3: number;
  27255. /**
  27256. * Get the Relative Loop Mode
  27257. */
  27258. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27259. /**
  27260. * Get the Cycle Loop Mode
  27261. */
  27262. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27263. /**
  27264. * Get the Constant Loop Mode
  27265. */
  27266. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27267. /** @hidden */
  27268. static _UniversalLerp(left: any, right: any, amount: number): any;
  27269. /**
  27270. * Parses an animation object and creates an animation
  27271. * @param parsedAnimation Parsed animation object
  27272. * @returns Animation object
  27273. */
  27274. static Parse(parsedAnimation: any): Animation;
  27275. /**
  27276. * Appends the serialized animations from the source animations
  27277. * @param source Source containing the animations
  27278. * @param destination Target to store the animations
  27279. */
  27280. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27281. }
  27282. }
  27283. declare module BABYLON {
  27284. /**
  27285. * Interface containing an array of animations
  27286. */
  27287. export interface IAnimatable {
  27288. /**
  27289. * Array of animations
  27290. */
  27291. animations: Nullable<Array<Animation>>;
  27292. }
  27293. }
  27294. declare module BABYLON {
  27295. /**
  27296. * This represents all the required information to add a fresnel effect on a material:
  27297. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27298. */
  27299. export class FresnelParameters {
  27300. private _isEnabled;
  27301. /**
  27302. * Define if the fresnel effect is enable or not.
  27303. */
  27304. isEnabled: boolean;
  27305. /**
  27306. * Define the color used on edges (grazing angle)
  27307. */
  27308. leftColor: Color3;
  27309. /**
  27310. * Define the color used on center
  27311. */
  27312. rightColor: Color3;
  27313. /**
  27314. * Define bias applied to computed fresnel term
  27315. */
  27316. bias: number;
  27317. /**
  27318. * Defined the power exponent applied to fresnel term
  27319. */
  27320. power: number;
  27321. /**
  27322. * Clones the current fresnel and its valuues
  27323. * @returns a clone fresnel configuration
  27324. */
  27325. clone(): FresnelParameters;
  27326. /**
  27327. * Serializes the current fresnel parameters to a JSON representation.
  27328. * @return the JSON serialization
  27329. */
  27330. serialize(): any;
  27331. /**
  27332. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27333. * @param parsedFresnelParameters Define the JSON representation
  27334. * @returns the parsed parameters
  27335. */
  27336. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27337. }
  27338. }
  27339. declare module BABYLON {
  27340. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27341. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27342. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27343. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27344. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27345. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27346. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27347. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27348. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27349. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27350. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27351. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27352. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27353. /**
  27354. * Decorator used to define property that can be serialized as reference to a camera
  27355. * @param sourceName defines the name of the property to decorate
  27356. */
  27357. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27358. /**
  27359. * Class used to help serialization objects
  27360. */
  27361. export class SerializationHelper {
  27362. /** @hidden */
  27363. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27364. /** @hidden */
  27365. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27366. /** @hidden */
  27367. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27368. /** @hidden */
  27369. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27370. /**
  27371. * Appends the serialized animations from the source animations
  27372. * @param source Source containing the animations
  27373. * @param destination Target to store the animations
  27374. */
  27375. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27376. /**
  27377. * Static function used to serialized a specific entity
  27378. * @param entity defines the entity to serialize
  27379. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27380. * @returns a JSON compatible object representing the serialization of the entity
  27381. */
  27382. static Serialize<T>(entity: T, serializationObject?: any): any;
  27383. /**
  27384. * Creates a new entity from a serialization data object
  27385. * @param creationFunction defines a function used to instanciated the new entity
  27386. * @param source defines the source serialization data
  27387. * @param scene defines the hosting scene
  27388. * @param rootUrl defines the root url for resources
  27389. * @returns a new entity
  27390. */
  27391. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27392. /**
  27393. * Clones an object
  27394. * @param creationFunction defines the function used to instanciate the new object
  27395. * @param source defines the source object
  27396. * @returns the cloned object
  27397. */
  27398. static Clone<T>(creationFunction: () => T, source: T): T;
  27399. /**
  27400. * Instanciates a new object based on a source one (some data will be shared between both object)
  27401. * @param creationFunction defines the function used to instanciate the new object
  27402. * @param source defines the source object
  27403. * @returns the new object
  27404. */
  27405. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27406. }
  27407. }
  27408. declare module BABYLON {
  27409. /**
  27410. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  27411. */
  27412. export interface CubeMapInfo {
  27413. /**
  27414. * The pixel array for the front face.
  27415. * This is stored in format, left to right, up to down format.
  27416. */
  27417. front: Nullable<ArrayBufferView>;
  27418. /**
  27419. * The pixel array for the back face.
  27420. * This is stored in format, left to right, up to down format.
  27421. */
  27422. back: Nullable<ArrayBufferView>;
  27423. /**
  27424. * The pixel array for the left face.
  27425. * This is stored in format, left to right, up to down format.
  27426. */
  27427. left: Nullable<ArrayBufferView>;
  27428. /**
  27429. * The pixel array for the right face.
  27430. * This is stored in format, left to right, up to down format.
  27431. */
  27432. right: Nullable<ArrayBufferView>;
  27433. /**
  27434. * The pixel array for the up face.
  27435. * This is stored in format, left to right, up to down format.
  27436. */
  27437. up: Nullable<ArrayBufferView>;
  27438. /**
  27439. * The pixel array for the down face.
  27440. * This is stored in format, left to right, up to down format.
  27441. */
  27442. down: Nullable<ArrayBufferView>;
  27443. /**
  27444. * The size of the cubemap stored.
  27445. *
  27446. * Each faces will be size * size pixels.
  27447. */
  27448. size: number;
  27449. /**
  27450. * The format of the texture.
  27451. *
  27452. * RGBA, RGB.
  27453. */
  27454. format: number;
  27455. /**
  27456. * The type of the texture data.
  27457. *
  27458. * UNSIGNED_INT, FLOAT.
  27459. */
  27460. type: number;
  27461. /**
  27462. * Specifies whether the texture is in gamma space.
  27463. */
  27464. gammaSpace: boolean;
  27465. }
  27466. /**
  27467. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  27468. */
  27469. export class PanoramaToCubeMapTools {
  27470. private static FACE_FRONT;
  27471. private static FACE_BACK;
  27472. private static FACE_RIGHT;
  27473. private static FACE_LEFT;
  27474. private static FACE_DOWN;
  27475. private static FACE_UP;
  27476. /**
  27477. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27478. *
  27479. * @param float32Array The source data.
  27480. * @param inputWidth The width of the input panorama.
  27481. * @param inputHeight The height of the input panorama.
  27482. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27483. * @return The cubemap data
  27484. */
  27485. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27486. private static CreateCubemapTexture;
  27487. private static CalcProjectionSpherical;
  27488. }
  27489. }
  27490. declare module BABYLON {
  27491. /**
  27492. * Helper class dealing with the extraction of spherical polynomial dataArray
  27493. * from a cube map.
  27494. */
  27495. export class CubeMapToSphericalPolynomialTools {
  27496. private static FileFaces;
  27497. /**
  27498. * Converts a texture to the according Spherical Polynomial data.
  27499. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27500. *
  27501. * @param texture The texture to extract the information from.
  27502. * @return The Spherical Polynomial data.
  27503. */
  27504. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27505. /**
  27506. * Converts a cubemap to the according Spherical Polynomial data.
  27507. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27508. *
  27509. * @param cubeInfo The Cube map to extract the information from.
  27510. * @return The Spherical Polynomial data.
  27511. */
  27512. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27513. }
  27514. }
  27515. declare module BABYLON {
  27516. /**
  27517. * Class used to manipulate GUIDs
  27518. */
  27519. export class GUID {
  27520. /**
  27521. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27522. * Be aware Math.random() could cause collisions, but:
  27523. * "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"
  27524. * @returns a pseudo random id
  27525. */
  27526. static RandomId(): string;
  27527. }
  27528. }
  27529. declare module BABYLON {
  27530. /**
  27531. * Base class of all the textures in babylon.
  27532. * It groups all the common properties the materials, post process, lights... might need
  27533. * in order to make a correct use of the texture.
  27534. */
  27535. export class BaseTexture implements IAnimatable {
  27536. /**
  27537. * Default anisotropic filtering level for the application.
  27538. * It is set to 4 as a good tradeoff between perf and quality.
  27539. */
  27540. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27541. /**
  27542. * Gets or sets the unique id of the texture
  27543. */
  27544. uniqueId: number;
  27545. /**
  27546. * Define the name of the texture.
  27547. */
  27548. name: string;
  27549. /**
  27550. * Gets or sets an object used to store user defined information.
  27551. */
  27552. metadata: any;
  27553. /**
  27554. * For internal use only. Please do not use.
  27555. */
  27556. reservedDataStore: any;
  27557. private _hasAlpha;
  27558. /**
  27559. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27560. */
  27561. hasAlpha: boolean;
  27562. /**
  27563. * Defines if the alpha value should be determined via the rgb values.
  27564. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27565. */
  27566. getAlphaFromRGB: boolean;
  27567. /**
  27568. * Intensity or strength of the texture.
  27569. * It is commonly used by materials to fine tune the intensity of the texture
  27570. */
  27571. level: number;
  27572. /**
  27573. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27574. * This is part of the texture as textures usually maps to one uv set.
  27575. */
  27576. coordinatesIndex: number;
  27577. private _coordinatesMode;
  27578. /**
  27579. * How a texture is mapped.
  27580. *
  27581. * | Value | Type | Description |
  27582. * | ----- | ----------------------------------- | ----------- |
  27583. * | 0 | EXPLICIT_MODE | |
  27584. * | 1 | SPHERICAL_MODE | |
  27585. * | 2 | PLANAR_MODE | |
  27586. * | 3 | CUBIC_MODE | |
  27587. * | 4 | PROJECTION_MODE | |
  27588. * | 5 | SKYBOX_MODE | |
  27589. * | 6 | INVCUBIC_MODE | |
  27590. * | 7 | EQUIRECTANGULAR_MODE | |
  27591. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27592. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27593. */
  27594. coordinatesMode: number;
  27595. /**
  27596. * | Value | Type | Description |
  27597. * | ----- | ------------------ | ----------- |
  27598. * | 0 | CLAMP_ADDRESSMODE | |
  27599. * | 1 | WRAP_ADDRESSMODE | |
  27600. * | 2 | MIRROR_ADDRESSMODE | |
  27601. */
  27602. wrapU: number;
  27603. /**
  27604. * | Value | Type | Description |
  27605. * | ----- | ------------------ | ----------- |
  27606. * | 0 | CLAMP_ADDRESSMODE | |
  27607. * | 1 | WRAP_ADDRESSMODE | |
  27608. * | 2 | MIRROR_ADDRESSMODE | |
  27609. */
  27610. wrapV: number;
  27611. /**
  27612. * | Value | Type | Description |
  27613. * | ----- | ------------------ | ----------- |
  27614. * | 0 | CLAMP_ADDRESSMODE | |
  27615. * | 1 | WRAP_ADDRESSMODE | |
  27616. * | 2 | MIRROR_ADDRESSMODE | |
  27617. */
  27618. wrapR: number;
  27619. /**
  27620. * With compliant hardware and browser (supporting anisotropic filtering)
  27621. * this defines the level of anisotropic filtering in the texture.
  27622. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27623. */
  27624. anisotropicFilteringLevel: number;
  27625. /**
  27626. * Define if the texture is a cube texture or if false a 2d texture.
  27627. */
  27628. isCube: boolean;
  27629. /**
  27630. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27631. */
  27632. is3D: boolean;
  27633. /**
  27634. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27635. * HDR texture are usually stored in linear space.
  27636. * This only impacts the PBR and Background materials
  27637. */
  27638. gammaSpace: boolean;
  27639. /**
  27640. * Gets whether or not the texture contains RGBD data.
  27641. */
  27642. readonly isRGBD: boolean;
  27643. /**
  27644. * Is Z inverted in the texture (useful in a cube texture).
  27645. */
  27646. invertZ: boolean;
  27647. /**
  27648. * Are mip maps generated for this texture or not.
  27649. */
  27650. readonly noMipmap: boolean;
  27651. /**
  27652. * @hidden
  27653. */
  27654. lodLevelInAlpha: boolean;
  27655. /**
  27656. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27657. */
  27658. lodGenerationOffset: number;
  27659. /**
  27660. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27661. */
  27662. lodGenerationScale: number;
  27663. /**
  27664. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27665. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27666. * average roughness values.
  27667. */
  27668. linearSpecularLOD: boolean;
  27669. /**
  27670. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27671. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27672. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27673. */
  27674. irradianceTexture: Nullable<BaseTexture>;
  27675. /**
  27676. * Define if the texture is a render target.
  27677. */
  27678. isRenderTarget: boolean;
  27679. /**
  27680. * Define the unique id of the texture in the scene.
  27681. */
  27682. readonly uid: string;
  27683. /**
  27684. * Return a string representation of the texture.
  27685. * @returns the texture as a string
  27686. */
  27687. toString(): string;
  27688. /**
  27689. * Get the class name of the texture.
  27690. * @returns "BaseTexture"
  27691. */
  27692. getClassName(): string;
  27693. /**
  27694. * Define the list of animation attached to the texture.
  27695. */
  27696. animations: Animation[];
  27697. /**
  27698. * An event triggered when the texture is disposed.
  27699. */
  27700. onDisposeObservable: Observable<BaseTexture>;
  27701. private _onDisposeObserver;
  27702. /**
  27703. * Callback triggered when the texture has been disposed.
  27704. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27705. */
  27706. onDispose: () => void;
  27707. /**
  27708. * Define the current state of the loading sequence when in delayed load mode.
  27709. */
  27710. delayLoadState: number;
  27711. private _scene;
  27712. /** @hidden */
  27713. _texture: Nullable<InternalTexture>;
  27714. private _uid;
  27715. /**
  27716. * Define if the texture is preventinga material to render or not.
  27717. * If not and the texture is not ready, the engine will use a default black texture instead.
  27718. */
  27719. readonly isBlocking: boolean;
  27720. /**
  27721. * Instantiates a new BaseTexture.
  27722. * Base class of all the textures in babylon.
  27723. * It groups all the common properties the materials, post process, lights... might need
  27724. * in order to make a correct use of the texture.
  27725. * @param scene Define the scene the texture blongs to
  27726. */
  27727. constructor(scene: Nullable<Scene>);
  27728. /**
  27729. * Get the scene the texture belongs to.
  27730. * @returns the scene or null if undefined
  27731. */
  27732. getScene(): Nullable<Scene>;
  27733. /**
  27734. * Get the texture transform matrix used to offset tile the texture for istance.
  27735. * @returns the transformation matrix
  27736. */
  27737. getTextureMatrix(): Matrix;
  27738. /**
  27739. * Get the texture reflection matrix used to rotate/transform the reflection.
  27740. * @returns the reflection matrix
  27741. */
  27742. getReflectionTextureMatrix(): Matrix;
  27743. /**
  27744. * Get the underlying lower level texture from Babylon.
  27745. * @returns the insternal texture
  27746. */
  27747. getInternalTexture(): Nullable<InternalTexture>;
  27748. /**
  27749. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27750. * @returns true if ready or not blocking
  27751. */
  27752. isReadyOrNotBlocking(): boolean;
  27753. /**
  27754. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27755. * @returns true if fully ready
  27756. */
  27757. isReady(): boolean;
  27758. private _cachedSize;
  27759. /**
  27760. * Get the size of the texture.
  27761. * @returns the texture size.
  27762. */
  27763. getSize(): ISize;
  27764. /**
  27765. * Get the base size of the texture.
  27766. * It can be different from the size if the texture has been resized for POT for instance
  27767. * @returns the base size
  27768. */
  27769. getBaseSize(): ISize;
  27770. /**
  27771. * Update the sampling mode of the texture.
  27772. * Default is Trilinear mode.
  27773. *
  27774. * | Value | Type | Description |
  27775. * | ----- | ------------------ | ----------- |
  27776. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27777. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27778. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27779. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27780. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27781. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27782. * | 7 | NEAREST_LINEAR | |
  27783. * | 8 | NEAREST_NEAREST | |
  27784. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27785. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27786. * | 11 | LINEAR_LINEAR | |
  27787. * | 12 | LINEAR_NEAREST | |
  27788. *
  27789. * > _mag_: magnification filter (close to the viewer)
  27790. * > _min_: minification filter (far from the viewer)
  27791. * > _mip_: filter used between mip map levels
  27792. *@param samplingMode Define the new sampling mode of the texture
  27793. */
  27794. updateSamplingMode(samplingMode: number): void;
  27795. /**
  27796. * Scales the texture if is `canRescale()`
  27797. * @param ratio the resize factor we want to use to rescale
  27798. */
  27799. scale(ratio: number): void;
  27800. /**
  27801. * Get if the texture can rescale.
  27802. */
  27803. readonly canRescale: boolean;
  27804. /** @hidden */
  27805. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27806. /** @hidden */
  27807. _rebuild(): void;
  27808. /**
  27809. * Triggers the load sequence in delayed load mode.
  27810. */
  27811. delayLoad(): void;
  27812. /**
  27813. * Clones the texture.
  27814. * @returns the cloned texture
  27815. */
  27816. clone(): Nullable<BaseTexture>;
  27817. /**
  27818. * Get the texture underlying type (INT, FLOAT...)
  27819. */
  27820. readonly textureType: number;
  27821. /**
  27822. * Get the texture underlying format (RGB, RGBA...)
  27823. */
  27824. readonly textureFormat: number;
  27825. /**
  27826. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27827. * This will returns an RGBA array buffer containing either in values (0-255) or
  27828. * float values (0-1) depending of the underlying buffer type.
  27829. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27830. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27831. * @param buffer defines a user defined buffer to fill with data (can be null)
  27832. * @returns The Array buffer containing the pixels data.
  27833. */
  27834. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27835. /**
  27836. * Release and destroy the underlying lower level texture aka internalTexture.
  27837. */
  27838. releaseInternalTexture(): void;
  27839. /**
  27840. * Get the polynomial representation of the texture data.
  27841. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27842. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27843. */
  27844. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27845. /** @hidden */
  27846. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27847. /** @hidden */
  27848. readonly _lodTextureMid: Nullable<BaseTexture>;
  27849. /** @hidden */
  27850. readonly _lodTextureLow: Nullable<BaseTexture>;
  27851. /**
  27852. * Dispose the texture and release its associated resources.
  27853. */
  27854. dispose(): void;
  27855. /**
  27856. * Serialize the texture into a JSON representation that can be parsed later on.
  27857. * @returns the JSON representation of the texture
  27858. */
  27859. serialize(): any;
  27860. /**
  27861. * Helper function to be called back once a list of texture contains only ready textures.
  27862. * @param textures Define the list of textures to wait for
  27863. * @param callback Define the callback triggered once the entire list will be ready
  27864. */
  27865. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27866. }
  27867. }
  27868. declare module BABYLON {
  27869. /**
  27870. * Class used to store data associated with WebGL texture data for the engine
  27871. * This class should not be used directly
  27872. */
  27873. export class InternalTexture {
  27874. /** @hidden */
  27875. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  27876. /**
  27877. * The source of the texture data is unknown
  27878. */
  27879. static DATASOURCE_UNKNOWN: number;
  27880. /**
  27881. * Texture data comes from an URL
  27882. */
  27883. static DATASOURCE_URL: number;
  27884. /**
  27885. * Texture data is only used for temporary storage
  27886. */
  27887. static DATASOURCE_TEMP: number;
  27888. /**
  27889. * Texture data comes from raw data (ArrayBuffer)
  27890. */
  27891. static DATASOURCE_RAW: number;
  27892. /**
  27893. * Texture content is dynamic (video or dynamic texture)
  27894. */
  27895. static DATASOURCE_DYNAMIC: number;
  27896. /**
  27897. * Texture content is generated by rendering to it
  27898. */
  27899. static DATASOURCE_RENDERTARGET: number;
  27900. /**
  27901. * Texture content is part of a multi render target process
  27902. */
  27903. static DATASOURCE_MULTIRENDERTARGET: number;
  27904. /**
  27905. * Texture data comes from a cube data file
  27906. */
  27907. static DATASOURCE_CUBE: number;
  27908. /**
  27909. * Texture data comes from a raw cube data
  27910. */
  27911. static DATASOURCE_CUBERAW: number;
  27912. /**
  27913. * Texture data come from a prefiltered cube data file
  27914. */
  27915. static DATASOURCE_CUBEPREFILTERED: number;
  27916. /**
  27917. * Texture content is raw 3D data
  27918. */
  27919. static DATASOURCE_RAW3D: number;
  27920. /**
  27921. * Texture content is a depth texture
  27922. */
  27923. static DATASOURCE_DEPTHTEXTURE: number;
  27924. /**
  27925. * Texture data comes from a raw cube data encoded with RGBD
  27926. */
  27927. static DATASOURCE_CUBERAW_RGBD: number;
  27928. /**
  27929. * Defines if the texture is ready
  27930. */
  27931. isReady: boolean;
  27932. /**
  27933. * Defines if the texture is a cube texture
  27934. */
  27935. isCube: boolean;
  27936. /**
  27937. * Defines if the texture contains 3D data
  27938. */
  27939. is3D: boolean;
  27940. /**
  27941. * Defines if the texture contains multiview data
  27942. */
  27943. isMultiview: boolean;
  27944. /**
  27945. * Gets the URL used to load this texture
  27946. */
  27947. url: string;
  27948. /**
  27949. * Gets the sampling mode of the texture
  27950. */
  27951. samplingMode: number;
  27952. /**
  27953. * Gets a boolean indicating if the texture needs mipmaps generation
  27954. */
  27955. generateMipMaps: boolean;
  27956. /**
  27957. * Gets the number of samples used by the texture (WebGL2+ only)
  27958. */
  27959. samples: number;
  27960. /**
  27961. * Gets the type of the texture (int, float...)
  27962. */
  27963. type: number;
  27964. /**
  27965. * Gets the format of the texture (RGB, RGBA...)
  27966. */
  27967. format: number;
  27968. /**
  27969. * Observable called when the texture is loaded
  27970. */
  27971. onLoadedObservable: Observable<InternalTexture>;
  27972. /**
  27973. * Gets the width of the texture
  27974. */
  27975. width: number;
  27976. /**
  27977. * Gets the height of the texture
  27978. */
  27979. height: number;
  27980. /**
  27981. * Gets the depth of the texture
  27982. */
  27983. depth: number;
  27984. /**
  27985. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  27986. */
  27987. baseWidth: number;
  27988. /**
  27989. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  27990. */
  27991. baseHeight: number;
  27992. /**
  27993. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  27994. */
  27995. baseDepth: number;
  27996. /**
  27997. * Gets a boolean indicating if the texture is inverted on Y axis
  27998. */
  27999. invertY: boolean;
  28000. /** @hidden */
  28001. _invertVScale: boolean;
  28002. /** @hidden */
  28003. _associatedChannel: number;
  28004. /** @hidden */
  28005. _dataSource: number;
  28006. /** @hidden */
  28007. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  28008. /** @hidden */
  28009. _bufferView: Nullable<ArrayBufferView>;
  28010. /** @hidden */
  28011. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28012. /** @hidden */
  28013. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28014. /** @hidden */
  28015. _size: number;
  28016. /** @hidden */
  28017. _extension: string;
  28018. /** @hidden */
  28019. _files: Nullable<string[]>;
  28020. /** @hidden */
  28021. _workingCanvas: Nullable<HTMLCanvasElement>;
  28022. /** @hidden */
  28023. _workingContext: Nullable<CanvasRenderingContext2D>;
  28024. /** @hidden */
  28025. _framebuffer: Nullable<WebGLFramebuffer>;
  28026. /** @hidden */
  28027. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28028. /** @hidden */
  28029. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28030. /** @hidden */
  28031. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28032. /** @hidden */
  28033. _attachments: Nullable<number[]>;
  28034. /** @hidden */
  28035. _cachedCoordinatesMode: Nullable<number>;
  28036. /** @hidden */
  28037. _cachedWrapU: Nullable<number>;
  28038. /** @hidden */
  28039. _cachedWrapV: Nullable<number>;
  28040. /** @hidden */
  28041. _cachedWrapR: Nullable<number>;
  28042. /** @hidden */
  28043. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28044. /** @hidden */
  28045. _isDisabled: boolean;
  28046. /** @hidden */
  28047. _compression: Nullable<string>;
  28048. /** @hidden */
  28049. _generateStencilBuffer: boolean;
  28050. /** @hidden */
  28051. _generateDepthBuffer: boolean;
  28052. /** @hidden */
  28053. _comparisonFunction: number;
  28054. /** @hidden */
  28055. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28056. /** @hidden */
  28057. _lodGenerationScale: number;
  28058. /** @hidden */
  28059. _lodGenerationOffset: number;
  28060. /** @hidden */
  28061. _colorTextureArray: Nullable<WebGLTexture>;
  28062. /** @hidden */
  28063. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28064. /** @hidden */
  28065. _lodTextureHigh: Nullable<BaseTexture>;
  28066. /** @hidden */
  28067. _lodTextureMid: Nullable<BaseTexture>;
  28068. /** @hidden */
  28069. _lodTextureLow: Nullable<BaseTexture>;
  28070. /** @hidden */
  28071. _isRGBD: boolean;
  28072. /** @hidden */
  28073. _linearSpecularLOD: boolean;
  28074. /** @hidden */
  28075. _irradianceTexture: Nullable<BaseTexture>;
  28076. /** @hidden */
  28077. _webGLTexture: Nullable<WebGLTexture>;
  28078. /** @hidden */
  28079. _references: number;
  28080. private _engine;
  28081. /**
  28082. * Gets the Engine the texture belongs to.
  28083. * @returns The babylon engine
  28084. */
  28085. getEngine(): Engine;
  28086. /**
  28087. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28088. */
  28089. readonly dataSource: number;
  28090. /**
  28091. * Creates a new InternalTexture
  28092. * @param engine defines the engine to use
  28093. * @param dataSource defines the type of data that will be used
  28094. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28095. */
  28096. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28097. /**
  28098. * Increments the number of references (ie. the number of Texture that point to it)
  28099. */
  28100. incrementReferences(): void;
  28101. /**
  28102. * Change the size of the texture (not the size of the content)
  28103. * @param width defines the new width
  28104. * @param height defines the new height
  28105. * @param depth defines the new depth (1 by default)
  28106. */
  28107. updateSize(width: int, height: int, depth?: int): void;
  28108. /** @hidden */
  28109. _rebuild(): void;
  28110. /** @hidden */
  28111. _swapAndDie(target: InternalTexture): void;
  28112. /**
  28113. * Dispose the current allocated resources
  28114. */
  28115. dispose(): void;
  28116. }
  28117. }
  28118. declare module BABYLON {
  28119. /**
  28120. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28121. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28122. */
  28123. export class EffectFallbacks {
  28124. private _defines;
  28125. private _currentRank;
  28126. private _maxRank;
  28127. private _mesh;
  28128. /**
  28129. * Removes the fallback from the bound mesh.
  28130. */
  28131. unBindMesh(): void;
  28132. /**
  28133. * Adds a fallback on the specified property.
  28134. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28135. * @param define The name of the define in the shader
  28136. */
  28137. addFallback(rank: number, define: string): void;
  28138. /**
  28139. * Sets the mesh to use CPU skinning when needing to fallback.
  28140. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28141. * @param mesh The mesh to use the fallbacks.
  28142. */
  28143. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28144. /**
  28145. * Checks to see if more fallbacks are still availible.
  28146. */
  28147. readonly isMoreFallbacks: boolean;
  28148. /**
  28149. * Removes the defines that should be removed when falling back.
  28150. * @param currentDefines defines the current define statements for the shader.
  28151. * @param effect defines the current effect we try to compile
  28152. * @returns The resulting defines with defines of the current rank removed.
  28153. */
  28154. reduce(currentDefines: string, effect: Effect): string;
  28155. }
  28156. /**
  28157. * Options to be used when creating an effect.
  28158. */
  28159. export class EffectCreationOptions {
  28160. /**
  28161. * Atrributes that will be used in the shader.
  28162. */
  28163. attributes: string[];
  28164. /**
  28165. * Uniform varible names that will be set in the shader.
  28166. */
  28167. uniformsNames: string[];
  28168. /**
  28169. * Uniform buffer varible names that will be set in the shader.
  28170. */
  28171. uniformBuffersNames: string[];
  28172. /**
  28173. * Sampler texture variable names that will be set in the shader.
  28174. */
  28175. samplers: string[];
  28176. /**
  28177. * Define statements that will be set in the shader.
  28178. */
  28179. defines: any;
  28180. /**
  28181. * Possible fallbacks for this effect to improve performance when needed.
  28182. */
  28183. fallbacks: Nullable<EffectFallbacks>;
  28184. /**
  28185. * Callback that will be called when the shader is compiled.
  28186. */
  28187. onCompiled: Nullable<(effect: Effect) => void>;
  28188. /**
  28189. * Callback that will be called if an error occurs during shader compilation.
  28190. */
  28191. onError: Nullable<(effect: Effect, errors: string) => void>;
  28192. /**
  28193. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28194. */
  28195. indexParameters: any;
  28196. /**
  28197. * Max number of lights that can be used in the shader.
  28198. */
  28199. maxSimultaneousLights: number;
  28200. /**
  28201. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28202. */
  28203. transformFeedbackVaryings: Nullable<string[]>;
  28204. }
  28205. /**
  28206. * Effect containing vertex and fragment shader that can be executed on an object.
  28207. */
  28208. export class Effect implements IDisposable {
  28209. /**
  28210. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28211. */
  28212. static ShadersRepository: string;
  28213. /**
  28214. * Name of the effect.
  28215. */
  28216. name: any;
  28217. /**
  28218. * String container all the define statements that should be set on the shader.
  28219. */
  28220. defines: string;
  28221. /**
  28222. * Callback that will be called when the shader is compiled.
  28223. */
  28224. onCompiled: Nullable<(effect: Effect) => void>;
  28225. /**
  28226. * Callback that will be called if an error occurs during shader compilation.
  28227. */
  28228. onError: Nullable<(effect: Effect, errors: string) => void>;
  28229. /**
  28230. * Callback that will be called when effect is bound.
  28231. */
  28232. onBind: Nullable<(effect: Effect) => void>;
  28233. /**
  28234. * Unique ID of the effect.
  28235. */
  28236. uniqueId: number;
  28237. /**
  28238. * Observable that will be called when the shader is compiled.
  28239. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28240. */
  28241. onCompileObservable: Observable<Effect>;
  28242. /**
  28243. * Observable that will be called if an error occurs during shader compilation.
  28244. */
  28245. onErrorObservable: Observable<Effect>;
  28246. /** @hidden */
  28247. _onBindObservable: Nullable<Observable<Effect>>;
  28248. /**
  28249. * Observable that will be called when effect is bound.
  28250. */
  28251. readonly onBindObservable: Observable<Effect>;
  28252. /** @hidden */
  28253. _bonesComputationForcedToCPU: boolean;
  28254. private static _uniqueIdSeed;
  28255. private _engine;
  28256. private _uniformBuffersNames;
  28257. private _uniformsNames;
  28258. private _samplerList;
  28259. private _samplers;
  28260. private _isReady;
  28261. private _compilationError;
  28262. private _attributesNames;
  28263. private _attributes;
  28264. private _uniforms;
  28265. /**
  28266. * Key for the effect.
  28267. * @hidden
  28268. */
  28269. _key: string;
  28270. private _indexParameters;
  28271. private _fallbacks;
  28272. private _vertexSourceCode;
  28273. private _fragmentSourceCode;
  28274. private _vertexSourceCodeOverride;
  28275. private _fragmentSourceCodeOverride;
  28276. private _transformFeedbackVaryings;
  28277. /**
  28278. * Compiled shader to webGL program.
  28279. * @hidden
  28280. */
  28281. _pipelineContext: Nullable<IPipelineContext>;
  28282. private _valueCache;
  28283. private static _baseCache;
  28284. /**
  28285. * Instantiates an effect.
  28286. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28287. * @param baseName Name of the effect.
  28288. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28289. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28290. * @param samplers List of sampler variables that will be passed to the shader.
  28291. * @param engine Engine to be used to render the effect
  28292. * @param defines Define statements to be added to the shader.
  28293. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28294. * @param onCompiled Callback that will be called when the shader is compiled.
  28295. * @param onError Callback that will be called if an error occurs during shader compilation.
  28296. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28297. */
  28298. 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);
  28299. private _useFinalCode;
  28300. /**
  28301. * Unique key for this effect
  28302. */
  28303. readonly key: string;
  28304. /**
  28305. * If the effect has been compiled and prepared.
  28306. * @returns if the effect is compiled and prepared.
  28307. */
  28308. isReady(): boolean;
  28309. /**
  28310. * The engine the effect was initialized with.
  28311. * @returns the engine.
  28312. */
  28313. getEngine(): Engine;
  28314. /**
  28315. * The pipeline context for this effect
  28316. * @returns the associated pipeline context
  28317. */
  28318. getPipelineContext(): Nullable<IPipelineContext>;
  28319. /**
  28320. * The set of names of attribute variables for the shader.
  28321. * @returns An array of attribute names.
  28322. */
  28323. getAttributesNames(): string[];
  28324. /**
  28325. * Returns the attribute at the given index.
  28326. * @param index The index of the attribute.
  28327. * @returns The location of the attribute.
  28328. */
  28329. getAttributeLocation(index: number): number;
  28330. /**
  28331. * Returns the attribute based on the name of the variable.
  28332. * @param name of the attribute to look up.
  28333. * @returns the attribute location.
  28334. */
  28335. getAttributeLocationByName(name: string): number;
  28336. /**
  28337. * The number of attributes.
  28338. * @returns the numnber of attributes.
  28339. */
  28340. getAttributesCount(): number;
  28341. /**
  28342. * Gets the index of a uniform variable.
  28343. * @param uniformName of the uniform to look up.
  28344. * @returns the index.
  28345. */
  28346. getUniformIndex(uniformName: string): number;
  28347. /**
  28348. * Returns the attribute based on the name of the variable.
  28349. * @param uniformName of the uniform to look up.
  28350. * @returns the location of the uniform.
  28351. */
  28352. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28353. /**
  28354. * Returns an array of sampler variable names
  28355. * @returns The array of sampler variable neames.
  28356. */
  28357. getSamplers(): string[];
  28358. /**
  28359. * The error from the last compilation.
  28360. * @returns the error string.
  28361. */
  28362. getCompilationError(): string;
  28363. /**
  28364. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28365. * @param func The callback to be used.
  28366. */
  28367. executeWhenCompiled(func: (effect: Effect) => void): void;
  28368. private _checkIsReady;
  28369. /** @hidden */
  28370. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28371. /** @hidden */
  28372. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28373. /** @hidden */
  28374. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28375. /**
  28376. * Recompiles the webGL program
  28377. * @param vertexSourceCode The source code for the vertex shader.
  28378. * @param fragmentSourceCode The source code for the fragment shader.
  28379. * @param onCompiled Callback called when completed.
  28380. * @param onError Callback called on error.
  28381. * @hidden
  28382. */
  28383. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28384. /**
  28385. * Prepares the effect
  28386. * @hidden
  28387. */
  28388. _prepareEffect(): void;
  28389. private _processCompilationErrors;
  28390. /**
  28391. * Checks if the effect is supported. (Must be called after compilation)
  28392. */
  28393. readonly isSupported: boolean;
  28394. /**
  28395. * Binds a texture to the engine to be used as output of the shader.
  28396. * @param channel Name of the output variable.
  28397. * @param texture Texture to bind.
  28398. * @hidden
  28399. */
  28400. _bindTexture(channel: string, texture: InternalTexture): void;
  28401. /**
  28402. * Sets a texture on the engine to be used in the shader.
  28403. * @param channel Name of the sampler variable.
  28404. * @param texture Texture to set.
  28405. */
  28406. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28407. /**
  28408. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28409. * @param channel Name of the sampler variable.
  28410. * @param texture Texture to set.
  28411. */
  28412. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28413. /**
  28414. * Sets an array of textures on the engine to be used in the shader.
  28415. * @param channel Name of the variable.
  28416. * @param textures Textures to set.
  28417. */
  28418. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28419. /**
  28420. * 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)
  28421. * @param channel Name of the sampler variable.
  28422. * @param postProcess Post process to get the input texture from.
  28423. */
  28424. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28425. /**
  28426. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28427. * 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)
  28428. * @param channel Name of the sampler variable.
  28429. * @param postProcess Post process to get the output texture from.
  28430. */
  28431. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28432. /** @hidden */
  28433. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28434. /** @hidden */
  28435. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28436. /** @hidden */
  28437. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28438. /** @hidden */
  28439. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28440. /**
  28441. * Binds a buffer to a uniform.
  28442. * @param buffer Buffer to bind.
  28443. * @param name Name of the uniform variable to bind to.
  28444. */
  28445. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28446. /**
  28447. * Binds block to a uniform.
  28448. * @param blockName Name of the block to bind.
  28449. * @param index Index to bind.
  28450. */
  28451. bindUniformBlock(blockName: string, index: number): void;
  28452. /**
  28453. * Sets an interger value on a uniform variable.
  28454. * @param uniformName Name of the variable.
  28455. * @param value Value to be set.
  28456. * @returns this effect.
  28457. */
  28458. setInt(uniformName: string, value: number): Effect;
  28459. /**
  28460. * Sets an int array on a uniform variable.
  28461. * @param uniformName Name of the variable.
  28462. * @param array array to be set.
  28463. * @returns this effect.
  28464. */
  28465. setIntArray(uniformName: string, array: Int32Array): Effect;
  28466. /**
  28467. * 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)
  28468. * @param uniformName Name of the variable.
  28469. * @param array array to be set.
  28470. * @returns this effect.
  28471. */
  28472. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28473. /**
  28474. * 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)
  28475. * @param uniformName Name of the variable.
  28476. * @param array array to be set.
  28477. * @returns this effect.
  28478. */
  28479. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28480. /**
  28481. * 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)
  28482. * @param uniformName Name of the variable.
  28483. * @param array array to be set.
  28484. * @returns this effect.
  28485. */
  28486. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28487. /**
  28488. * Sets an float array on a uniform variable.
  28489. * @param uniformName Name of the variable.
  28490. * @param array array to be set.
  28491. * @returns this effect.
  28492. */
  28493. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28494. /**
  28495. * 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)
  28496. * @param uniformName Name of the variable.
  28497. * @param array array to be set.
  28498. * @returns this effect.
  28499. */
  28500. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28501. /**
  28502. * 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)
  28503. * @param uniformName Name of the variable.
  28504. * @param array array to be set.
  28505. * @returns this effect.
  28506. */
  28507. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28508. /**
  28509. * 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)
  28510. * @param uniformName Name of the variable.
  28511. * @param array array to be set.
  28512. * @returns this effect.
  28513. */
  28514. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28515. /**
  28516. * Sets an array on a uniform variable.
  28517. * @param uniformName Name of the variable.
  28518. * @param array array to be set.
  28519. * @returns this effect.
  28520. */
  28521. setArray(uniformName: string, array: number[]): Effect;
  28522. /**
  28523. * 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)
  28524. * @param uniformName Name of the variable.
  28525. * @param array array to be set.
  28526. * @returns this effect.
  28527. */
  28528. setArray2(uniformName: string, array: number[]): Effect;
  28529. /**
  28530. * 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)
  28531. * @param uniformName Name of the variable.
  28532. * @param array array to be set.
  28533. * @returns this effect.
  28534. */
  28535. setArray3(uniformName: string, array: number[]): Effect;
  28536. /**
  28537. * 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)
  28538. * @param uniformName Name of the variable.
  28539. * @param array array to be set.
  28540. * @returns this effect.
  28541. */
  28542. setArray4(uniformName: string, array: number[]): Effect;
  28543. /**
  28544. * Sets matrices on a uniform variable.
  28545. * @param uniformName Name of the variable.
  28546. * @param matrices matrices to be set.
  28547. * @returns this effect.
  28548. */
  28549. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28550. /**
  28551. * Sets matrix on a uniform variable.
  28552. * @param uniformName Name of the variable.
  28553. * @param matrix matrix to be set.
  28554. * @returns this effect.
  28555. */
  28556. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28557. /**
  28558. * 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)
  28559. * @param uniformName Name of the variable.
  28560. * @param matrix matrix to be set.
  28561. * @returns this effect.
  28562. */
  28563. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28564. /**
  28565. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28566. * @param uniformName Name of the variable.
  28567. * @param matrix matrix to be set.
  28568. * @returns this effect.
  28569. */
  28570. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28571. /**
  28572. * Sets a float on a uniform variable.
  28573. * @param uniformName Name of the variable.
  28574. * @param value value to be set.
  28575. * @returns this effect.
  28576. */
  28577. setFloat(uniformName: string, value: number): Effect;
  28578. /**
  28579. * Sets a boolean on a uniform variable.
  28580. * @param uniformName Name of the variable.
  28581. * @param bool value to be set.
  28582. * @returns this effect.
  28583. */
  28584. setBool(uniformName: string, bool: boolean): Effect;
  28585. /**
  28586. * Sets a Vector2 on a uniform variable.
  28587. * @param uniformName Name of the variable.
  28588. * @param vector2 vector2 to be set.
  28589. * @returns this effect.
  28590. */
  28591. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28592. /**
  28593. * Sets a float2 on a uniform variable.
  28594. * @param uniformName Name of the variable.
  28595. * @param x First float in float2.
  28596. * @param y Second float in float2.
  28597. * @returns this effect.
  28598. */
  28599. setFloat2(uniformName: string, x: number, y: number): Effect;
  28600. /**
  28601. * Sets a Vector3 on a uniform variable.
  28602. * @param uniformName Name of the variable.
  28603. * @param vector3 Value to be set.
  28604. * @returns this effect.
  28605. */
  28606. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28607. /**
  28608. * Sets a float3 on a uniform variable.
  28609. * @param uniformName Name of the variable.
  28610. * @param x First float in float3.
  28611. * @param y Second float in float3.
  28612. * @param z Third float in float3.
  28613. * @returns this effect.
  28614. */
  28615. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28616. /**
  28617. * Sets a Vector4 on a uniform variable.
  28618. * @param uniformName Name of the variable.
  28619. * @param vector4 Value to be set.
  28620. * @returns this effect.
  28621. */
  28622. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28623. /**
  28624. * Sets a float4 on a uniform variable.
  28625. * @param uniformName Name of the variable.
  28626. * @param x First float in float4.
  28627. * @param y Second float in float4.
  28628. * @param z Third float in float4.
  28629. * @param w Fourth float in float4.
  28630. * @returns this effect.
  28631. */
  28632. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28633. /**
  28634. * Sets a Color3 on a uniform variable.
  28635. * @param uniformName Name of the variable.
  28636. * @param color3 Value to be set.
  28637. * @returns this effect.
  28638. */
  28639. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28640. /**
  28641. * Sets a Color4 on a uniform variable.
  28642. * @param uniformName Name of the variable.
  28643. * @param color3 Value to be set.
  28644. * @param alpha Alpha value to be set.
  28645. * @returns this effect.
  28646. */
  28647. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28648. /**
  28649. * Sets a Color4 on a uniform variable
  28650. * @param uniformName defines the name of the variable
  28651. * @param color4 defines the value to be set
  28652. * @returns this effect.
  28653. */
  28654. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28655. /** Release all associated resources */
  28656. dispose(): void;
  28657. /**
  28658. * This function will add a new shader to the shader store
  28659. * @param name the name of the shader
  28660. * @param pixelShader optional pixel shader content
  28661. * @param vertexShader optional vertex shader content
  28662. */
  28663. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28664. /**
  28665. * Store of each shader (The can be looked up using effect.key)
  28666. */
  28667. static ShadersStore: {
  28668. [key: string]: string;
  28669. };
  28670. /**
  28671. * Store of each included file for a shader (The can be looked up using effect.key)
  28672. */
  28673. static IncludesShadersStore: {
  28674. [key: string]: string;
  28675. };
  28676. /**
  28677. * Resets the cache of effects.
  28678. */
  28679. static ResetCache(): void;
  28680. }
  28681. }
  28682. declare module BABYLON {
  28683. /**
  28684. * Uniform buffer objects.
  28685. *
  28686. * Handles blocks of uniform on the GPU.
  28687. *
  28688. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28689. *
  28690. * For more information, please refer to :
  28691. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28692. */
  28693. export class UniformBuffer {
  28694. private _engine;
  28695. private _buffer;
  28696. private _data;
  28697. private _bufferData;
  28698. private _dynamic?;
  28699. private _uniformLocations;
  28700. private _uniformSizes;
  28701. private _uniformLocationPointer;
  28702. private _needSync;
  28703. private _noUBO;
  28704. private _currentEffect;
  28705. private static _MAX_UNIFORM_SIZE;
  28706. private static _tempBuffer;
  28707. /**
  28708. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  28709. * This is dynamic to allow compat with webgl 1 and 2.
  28710. * You will need to pass the name of the uniform as well as the value.
  28711. */
  28712. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  28713. /**
  28714. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  28715. * This is dynamic to allow compat with webgl 1 and 2.
  28716. * You will need to pass the name of the uniform as well as the value.
  28717. */
  28718. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  28719. /**
  28720. * Lambda to Update a single float in a uniform buffer.
  28721. * This is dynamic to allow compat with webgl 1 and 2.
  28722. * You will need to pass the name of the uniform as well as the value.
  28723. */
  28724. updateFloat: (name: string, x: number) => void;
  28725. /**
  28726. * Lambda to Update a vec2 of float in a uniform buffer.
  28727. * This is dynamic to allow compat with webgl 1 and 2.
  28728. * You will need to pass the name of the uniform as well as the value.
  28729. */
  28730. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  28731. /**
  28732. * Lambda to Update a vec3 of float in a uniform buffer.
  28733. * This is dynamic to allow compat with webgl 1 and 2.
  28734. * You will need to pass the name of the uniform as well as the value.
  28735. */
  28736. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  28737. /**
  28738. * Lambda to Update a vec4 of float in a uniform buffer.
  28739. * This is dynamic to allow compat with webgl 1 and 2.
  28740. * You will need to pass the name of the uniform as well as the value.
  28741. */
  28742. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  28743. /**
  28744. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  28745. * This is dynamic to allow compat with webgl 1 and 2.
  28746. * You will need to pass the name of the uniform as well as the value.
  28747. */
  28748. updateMatrix: (name: string, mat: Matrix) => void;
  28749. /**
  28750. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  28751. * This is dynamic to allow compat with webgl 1 and 2.
  28752. * You will need to pass the name of the uniform as well as the value.
  28753. */
  28754. updateVector3: (name: string, vector: Vector3) => void;
  28755. /**
  28756. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  28757. * This is dynamic to allow compat with webgl 1 and 2.
  28758. * You will need to pass the name of the uniform as well as the value.
  28759. */
  28760. updateVector4: (name: string, vector: Vector4) => void;
  28761. /**
  28762. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  28763. * This is dynamic to allow compat with webgl 1 and 2.
  28764. * You will need to pass the name of the uniform as well as the value.
  28765. */
  28766. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  28767. /**
  28768. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  28769. * This is dynamic to allow compat with webgl 1 and 2.
  28770. * You will need to pass the name of the uniform as well as the value.
  28771. */
  28772. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  28773. /**
  28774. * Instantiates a new Uniform buffer objects.
  28775. *
  28776. * Handles blocks of uniform on the GPU.
  28777. *
  28778. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28779. *
  28780. * For more information, please refer to :
  28781. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28782. * @param engine Define the engine the buffer is associated with
  28783. * @param data Define the data contained in the buffer
  28784. * @param dynamic Define if the buffer is updatable
  28785. */
  28786. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  28787. /**
  28788. * Indicates if the buffer is using the WebGL2 UBO implementation,
  28789. * or just falling back on setUniformXXX calls.
  28790. */
  28791. readonly useUbo: boolean;
  28792. /**
  28793. * Indicates if the WebGL underlying uniform buffer is in sync
  28794. * with the javascript cache data.
  28795. */
  28796. readonly isSync: boolean;
  28797. /**
  28798. * Indicates if the WebGL underlying uniform buffer is dynamic.
  28799. * Also, a dynamic UniformBuffer will disable cache verification and always
  28800. * update the underlying WebGL uniform buffer to the GPU.
  28801. * @returns if Dynamic, otherwise false
  28802. */
  28803. isDynamic(): boolean;
  28804. /**
  28805. * The data cache on JS side.
  28806. * @returns the underlying data as a float array
  28807. */
  28808. getData(): Float32Array;
  28809. /**
  28810. * The underlying WebGL Uniform buffer.
  28811. * @returns the webgl buffer
  28812. */
  28813. getBuffer(): Nullable<DataBuffer>;
  28814. /**
  28815. * std140 layout specifies how to align data within an UBO structure.
  28816. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  28817. * for specs.
  28818. */
  28819. private _fillAlignment;
  28820. /**
  28821. * Adds an uniform in the buffer.
  28822. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  28823. * for the layout to be correct !
  28824. * @param name Name of the uniform, as used in the uniform block in the shader.
  28825. * @param size Data size, or data directly.
  28826. */
  28827. addUniform(name: string, size: number | number[]): void;
  28828. /**
  28829. * Adds a Matrix 4x4 to the uniform buffer.
  28830. * @param name Name of the uniform, as used in the uniform block in the shader.
  28831. * @param mat A 4x4 matrix.
  28832. */
  28833. addMatrix(name: string, mat: Matrix): void;
  28834. /**
  28835. * Adds a vec2 to the uniform buffer.
  28836. * @param name Name of the uniform, as used in the uniform block in the shader.
  28837. * @param x Define the x component value of the vec2
  28838. * @param y Define the y component value of the vec2
  28839. */
  28840. addFloat2(name: string, x: number, y: number): void;
  28841. /**
  28842. * Adds a vec3 to the uniform buffer.
  28843. * @param name Name of the uniform, as used in the uniform block in the shader.
  28844. * @param x Define the x component value of the vec3
  28845. * @param y Define the y component value of the vec3
  28846. * @param z Define the z component value of the vec3
  28847. */
  28848. addFloat3(name: string, x: number, y: number, z: number): void;
  28849. /**
  28850. * Adds a vec3 to the uniform buffer.
  28851. * @param name Name of the uniform, as used in the uniform block in the shader.
  28852. * @param color Define the vec3 from a Color
  28853. */
  28854. addColor3(name: string, color: Color3): void;
  28855. /**
  28856. * Adds a vec4 to the uniform buffer.
  28857. * @param name Name of the uniform, as used in the uniform block in the shader.
  28858. * @param color Define the rgb components from a Color
  28859. * @param alpha Define the a component of the vec4
  28860. */
  28861. addColor4(name: string, color: Color3, alpha: number): void;
  28862. /**
  28863. * Adds a vec3 to the uniform buffer.
  28864. * @param name Name of the uniform, as used in the uniform block in the shader.
  28865. * @param vector Define the vec3 components from a Vector
  28866. */
  28867. addVector3(name: string, vector: Vector3): void;
  28868. /**
  28869. * Adds a Matrix 3x3 to the uniform buffer.
  28870. * @param name Name of the uniform, as used in the uniform block in the shader.
  28871. */
  28872. addMatrix3x3(name: string): void;
  28873. /**
  28874. * Adds a Matrix 2x2 to the uniform buffer.
  28875. * @param name Name of the uniform, as used in the uniform block in the shader.
  28876. */
  28877. addMatrix2x2(name: string): void;
  28878. /**
  28879. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  28880. */
  28881. create(): void;
  28882. /** @hidden */
  28883. _rebuild(): void;
  28884. /**
  28885. * Updates the WebGL Uniform Buffer on the GPU.
  28886. * If the `dynamic` flag is set to true, no cache comparison is done.
  28887. * Otherwise, the buffer will be updated only if the cache differs.
  28888. */
  28889. update(): void;
  28890. /**
  28891. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  28892. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28893. * @param data Define the flattened data
  28894. * @param size Define the size of the data.
  28895. */
  28896. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  28897. private _valueCache;
  28898. private _cacheMatrix;
  28899. private _updateMatrix3x3ForUniform;
  28900. private _updateMatrix3x3ForEffect;
  28901. private _updateMatrix2x2ForEffect;
  28902. private _updateMatrix2x2ForUniform;
  28903. private _updateFloatForEffect;
  28904. private _updateFloatForUniform;
  28905. private _updateFloat2ForEffect;
  28906. private _updateFloat2ForUniform;
  28907. private _updateFloat3ForEffect;
  28908. private _updateFloat3ForUniform;
  28909. private _updateFloat4ForEffect;
  28910. private _updateFloat4ForUniform;
  28911. private _updateMatrixForEffect;
  28912. private _updateMatrixForUniform;
  28913. private _updateVector3ForEffect;
  28914. private _updateVector3ForUniform;
  28915. private _updateVector4ForEffect;
  28916. private _updateVector4ForUniform;
  28917. private _updateColor3ForEffect;
  28918. private _updateColor3ForUniform;
  28919. private _updateColor4ForEffect;
  28920. private _updateColor4ForUniform;
  28921. /**
  28922. * Sets a sampler uniform on the effect.
  28923. * @param name Define the name of the sampler.
  28924. * @param texture Define the texture to set in the sampler
  28925. */
  28926. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  28927. /**
  28928. * Directly updates the value of the uniform in the cache AND on the GPU.
  28929. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28930. * @param data Define the flattened data
  28931. */
  28932. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  28933. /**
  28934. * Binds this uniform buffer to an effect.
  28935. * @param effect Define the effect to bind the buffer to
  28936. * @param name Name of the uniform block in the shader.
  28937. */
  28938. bindToEffect(effect: Effect, name: string): void;
  28939. /**
  28940. * Disposes the uniform buffer.
  28941. */
  28942. dispose(): void;
  28943. }
  28944. }
  28945. declare module BABYLON {
  28946. /**
  28947. * Class used to work with sound analyzer using fast fourier transform (FFT)
  28948. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28949. */
  28950. export class Analyser {
  28951. /**
  28952. * Gets or sets the smoothing
  28953. * @ignorenaming
  28954. */
  28955. SMOOTHING: number;
  28956. /**
  28957. * Gets or sets the FFT table size
  28958. * @ignorenaming
  28959. */
  28960. FFT_SIZE: number;
  28961. /**
  28962. * Gets or sets the bar graph amplitude
  28963. * @ignorenaming
  28964. */
  28965. BARGRAPHAMPLITUDE: number;
  28966. /**
  28967. * Gets or sets the position of the debug canvas
  28968. * @ignorenaming
  28969. */
  28970. DEBUGCANVASPOS: {
  28971. x: number;
  28972. y: number;
  28973. };
  28974. /**
  28975. * Gets or sets the debug canvas size
  28976. * @ignorenaming
  28977. */
  28978. DEBUGCANVASSIZE: {
  28979. width: number;
  28980. height: number;
  28981. };
  28982. private _byteFreqs;
  28983. private _byteTime;
  28984. private _floatFreqs;
  28985. private _webAudioAnalyser;
  28986. private _debugCanvas;
  28987. private _debugCanvasContext;
  28988. private _scene;
  28989. private _registerFunc;
  28990. private _audioEngine;
  28991. /**
  28992. * Creates a new analyser
  28993. * @param scene defines hosting scene
  28994. */
  28995. constructor(scene: Scene);
  28996. /**
  28997. * Get the number of data values you will have to play with for the visualization
  28998. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  28999. * @returns a number
  29000. */
  29001. getFrequencyBinCount(): number;
  29002. /**
  29003. * Gets the current frequency data as a byte array
  29004. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29005. * @returns a Uint8Array
  29006. */
  29007. getByteFrequencyData(): Uint8Array;
  29008. /**
  29009. * Gets the current waveform as a byte array
  29010. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29011. * @returns a Uint8Array
  29012. */
  29013. getByteTimeDomainData(): Uint8Array;
  29014. /**
  29015. * Gets the current frequency data as a float array
  29016. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29017. * @returns a Float32Array
  29018. */
  29019. getFloatFrequencyData(): Float32Array;
  29020. /**
  29021. * Renders the debug canvas
  29022. */
  29023. drawDebugCanvas(): void;
  29024. /**
  29025. * Stops rendering the debug canvas and removes it
  29026. */
  29027. stopDebugCanvas(): void;
  29028. /**
  29029. * Connects two audio nodes
  29030. * @param inputAudioNode defines first node to connect
  29031. * @param outputAudioNode defines second node to connect
  29032. */
  29033. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29034. /**
  29035. * Releases all associated resources
  29036. */
  29037. dispose(): void;
  29038. }
  29039. }
  29040. declare module BABYLON {
  29041. /**
  29042. * This represents an audio engine and it is responsible
  29043. * to play, synchronize and analyse sounds throughout the application.
  29044. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29045. */
  29046. export interface IAudioEngine extends IDisposable {
  29047. /**
  29048. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29049. */
  29050. readonly canUseWebAudio: boolean;
  29051. /**
  29052. * Gets the current AudioContext if available.
  29053. */
  29054. readonly audioContext: Nullable<AudioContext>;
  29055. /**
  29056. * The master gain node defines the global audio volume of your audio engine.
  29057. */
  29058. readonly masterGain: GainNode;
  29059. /**
  29060. * Gets whether or not mp3 are supported by your browser.
  29061. */
  29062. readonly isMP3supported: boolean;
  29063. /**
  29064. * Gets whether or not ogg are supported by your browser.
  29065. */
  29066. readonly isOGGsupported: boolean;
  29067. /**
  29068. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29069. * @ignoreNaming
  29070. */
  29071. WarnedWebAudioUnsupported: boolean;
  29072. /**
  29073. * Defines if the audio engine relies on a custom unlocked button.
  29074. * In this case, the embedded button will not be displayed.
  29075. */
  29076. useCustomUnlockedButton: boolean;
  29077. /**
  29078. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29079. */
  29080. readonly unlocked: 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. * Flags the audio engine in Locked state.
  29091. * This happens due to new browser policies preventing audio to autoplay.
  29092. */
  29093. lock(): void;
  29094. /**
  29095. * Unlocks the audio engine once a user action has been done on the dom.
  29096. * This is helpful to resume play once browser policies have been satisfied.
  29097. */
  29098. unlock(): void;
  29099. }
  29100. /**
  29101. * This represents the default audio engine used in babylon.
  29102. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29103. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29104. */
  29105. export class AudioEngine implements IAudioEngine {
  29106. private _audioContext;
  29107. private _audioContextInitialized;
  29108. private _muteButton;
  29109. private _hostElement;
  29110. /**
  29111. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29112. */
  29113. canUseWebAudio: boolean;
  29114. /**
  29115. * The master gain node defines the global audio volume of your audio engine.
  29116. */
  29117. masterGain: GainNode;
  29118. /**
  29119. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29120. * @ignoreNaming
  29121. */
  29122. WarnedWebAudioUnsupported: boolean;
  29123. /**
  29124. * Gets whether or not mp3 are supported by your browser.
  29125. */
  29126. isMP3supported: boolean;
  29127. /**
  29128. * Gets whether or not ogg are supported by your browser.
  29129. */
  29130. isOGGsupported: boolean;
  29131. /**
  29132. * Gets whether audio has been unlocked on the device.
  29133. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29134. * a user interaction has happened.
  29135. */
  29136. unlocked: boolean;
  29137. /**
  29138. * Defines if the audio engine relies on a custom unlocked button.
  29139. * In this case, the embedded button will not be displayed.
  29140. */
  29141. useCustomUnlockedButton: boolean;
  29142. /**
  29143. * Event raised when audio has been unlocked on the browser.
  29144. */
  29145. onAudioUnlockedObservable: Observable<AudioEngine>;
  29146. /**
  29147. * Event raised when audio has been locked on the browser.
  29148. */
  29149. onAudioLockedObservable: Observable<AudioEngine>;
  29150. /**
  29151. * Gets the current AudioContext if available.
  29152. */
  29153. readonly audioContext: Nullable<AudioContext>;
  29154. private _connectedAnalyser;
  29155. /**
  29156. * Instantiates a new audio engine.
  29157. *
  29158. * There should be only one per page as some browsers restrict the number
  29159. * of audio contexts you can create.
  29160. * @param hostElement defines the host element where to display the mute icon if necessary
  29161. */
  29162. constructor(hostElement?: Nullable<HTMLElement>);
  29163. /**
  29164. * Flags the audio engine in Locked state.
  29165. * This happens due to new browser policies preventing audio to autoplay.
  29166. */
  29167. lock(): void;
  29168. /**
  29169. * Unlocks the audio engine once a user action has been done on the dom.
  29170. * This is helpful to resume play once browser policies have been satisfied.
  29171. */
  29172. unlock(): void;
  29173. private _resumeAudioContext;
  29174. private _initializeAudioContext;
  29175. private _tryToRun;
  29176. private _triggerRunningState;
  29177. private _triggerSuspendedState;
  29178. private _displayMuteButton;
  29179. private _moveButtonToTopLeft;
  29180. private _onResize;
  29181. private _hideMuteButton;
  29182. /**
  29183. * Destroy and release the resources associated with the audio ccontext.
  29184. */
  29185. dispose(): void;
  29186. /**
  29187. * Gets the global volume sets on the master gain.
  29188. * @returns the global volume if set or -1 otherwise
  29189. */
  29190. getGlobalVolume(): number;
  29191. /**
  29192. * Sets the global volume of your experience (sets on the master gain).
  29193. * @param newVolume Defines the new global volume of the application
  29194. */
  29195. setGlobalVolume(newVolume: number): void;
  29196. /**
  29197. * Connect the audio engine to an audio analyser allowing some amazing
  29198. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  29199. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  29200. * @param analyser The analyser to connect to the engine
  29201. */
  29202. connectToAnalyser(analyser: Analyser): void;
  29203. }
  29204. }
  29205. declare module BABYLON {
  29206. /**
  29207. * Interface used to present a loading screen while loading a scene
  29208. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29209. */
  29210. export interface ILoadingScreen {
  29211. /**
  29212. * Function called to display the loading screen
  29213. */
  29214. displayLoadingUI: () => void;
  29215. /**
  29216. * Function called to hide the loading screen
  29217. */
  29218. hideLoadingUI: () => void;
  29219. /**
  29220. * Gets or sets the color to use for the background
  29221. */
  29222. loadingUIBackgroundColor: string;
  29223. /**
  29224. * Gets or sets the text to display while loading
  29225. */
  29226. loadingUIText: string;
  29227. }
  29228. /**
  29229. * Class used for the default loading screen
  29230. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29231. */
  29232. export class DefaultLoadingScreen implements ILoadingScreen {
  29233. private _renderingCanvas;
  29234. private _loadingText;
  29235. private _loadingDivBackgroundColor;
  29236. private _loadingDiv;
  29237. private _loadingTextDiv;
  29238. /** Gets or sets the logo url to use for the default loading screen */
  29239. static DefaultLogoUrl: string;
  29240. /** Gets or sets the spinner url to use for the default loading screen */
  29241. static DefaultSpinnerUrl: string;
  29242. /**
  29243. * Creates a new default loading screen
  29244. * @param _renderingCanvas defines the canvas used to render the scene
  29245. * @param _loadingText defines the default text to display
  29246. * @param _loadingDivBackgroundColor defines the default background color
  29247. */
  29248. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  29249. /**
  29250. * Function called to display the loading screen
  29251. */
  29252. displayLoadingUI(): void;
  29253. /**
  29254. * Function called to hide the loading screen
  29255. */
  29256. hideLoadingUI(): void;
  29257. /**
  29258. * Gets or sets the text to display while loading
  29259. */
  29260. loadingUIText: string;
  29261. /**
  29262. * Gets or sets the color to use for the background
  29263. */
  29264. loadingUIBackgroundColor: string;
  29265. private _resizeLoadingUI;
  29266. }
  29267. }
  29268. declare module BABYLON {
  29269. /** @hidden */
  29270. export class WebGLPipelineContext implements IPipelineContext {
  29271. engine: Engine;
  29272. program: Nullable<WebGLProgram>;
  29273. context?: WebGLRenderingContext;
  29274. vertexShader?: WebGLShader;
  29275. fragmentShader?: WebGLShader;
  29276. isParallelCompiled: boolean;
  29277. onCompiled?: () => void;
  29278. transformFeedback?: WebGLTransformFeedback | null;
  29279. readonly isAsync: boolean;
  29280. readonly isReady: boolean;
  29281. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  29282. }
  29283. }
  29284. declare module BABYLON {
  29285. /** @hidden */
  29286. export class WebGLDataBuffer extends DataBuffer {
  29287. private _buffer;
  29288. constructor(resource: WebGLBuffer);
  29289. readonly underlyingResource: any;
  29290. }
  29291. }
  29292. declare module BABYLON {
  29293. /** @hidden */
  29294. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29295. attributeProcessor(attribute: string): string;
  29296. varyingProcessor(varying: string, isFragment: boolean): string;
  29297. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29298. }
  29299. }
  29300. declare module BABYLON {
  29301. /**
  29302. * This class is used to track a performance counter which is number based.
  29303. * The user has access to many properties which give statistics of different nature.
  29304. *
  29305. * The implementer can track two kinds of Performance Counter: time and count.
  29306. * 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.
  29307. * 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.
  29308. */
  29309. export class PerfCounter {
  29310. /**
  29311. * Gets or sets a global boolean to turn on and off all the counters
  29312. */
  29313. static Enabled: boolean;
  29314. /**
  29315. * Returns the smallest value ever
  29316. */
  29317. readonly min: number;
  29318. /**
  29319. * Returns the biggest value ever
  29320. */
  29321. readonly max: number;
  29322. /**
  29323. * Returns the average value since the performance counter is running
  29324. */
  29325. readonly average: number;
  29326. /**
  29327. * Returns the average value of the last second the counter was monitored
  29328. */
  29329. readonly lastSecAverage: number;
  29330. /**
  29331. * Returns the current value
  29332. */
  29333. readonly current: number;
  29334. /**
  29335. * Gets the accumulated total
  29336. */
  29337. readonly total: number;
  29338. /**
  29339. * Gets the total value count
  29340. */
  29341. readonly count: number;
  29342. /**
  29343. * Creates a new counter
  29344. */
  29345. constructor();
  29346. /**
  29347. * Call this method to start monitoring a new frame.
  29348. * 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.
  29349. */
  29350. fetchNewFrame(): void;
  29351. /**
  29352. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29353. * @param newCount the count value to add to the monitored count
  29354. * @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.
  29355. */
  29356. addCount(newCount: number, fetchResult: boolean): void;
  29357. /**
  29358. * Start monitoring this performance counter
  29359. */
  29360. beginMonitoring(): void;
  29361. /**
  29362. * Compute the time lapsed since the previous beginMonitoring() call.
  29363. * @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
  29364. */
  29365. endMonitoring(newFrame?: boolean): void;
  29366. private _fetchResult;
  29367. private _startMonitoringTime;
  29368. private _min;
  29369. private _max;
  29370. private _average;
  29371. private _current;
  29372. private _totalValueCount;
  29373. private _totalAccumulated;
  29374. private _lastSecAverage;
  29375. private _lastSecAccumulated;
  29376. private _lastSecTime;
  29377. private _lastSecValueCount;
  29378. }
  29379. }
  29380. declare module BABYLON {
  29381. /**
  29382. * Interface for any object that can request an animation frame
  29383. */
  29384. export interface ICustomAnimationFrameRequester {
  29385. /**
  29386. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  29387. */
  29388. renderFunction?: Function;
  29389. /**
  29390. * Called to request the next frame to render to
  29391. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  29392. */
  29393. requestAnimationFrame: Function;
  29394. /**
  29395. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  29396. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  29397. */
  29398. requestID?: number;
  29399. }
  29400. }
  29401. declare module BABYLON {
  29402. /**
  29403. * Settings for finer control over video usage
  29404. */
  29405. export interface VideoTextureSettings {
  29406. /**
  29407. * Applies `autoplay` to video, if specified
  29408. */
  29409. autoPlay?: boolean;
  29410. /**
  29411. * Applies `loop` to video, if specified
  29412. */
  29413. loop?: boolean;
  29414. /**
  29415. * Automatically updates internal texture from video at every frame in the render loop
  29416. */
  29417. autoUpdateTexture: boolean;
  29418. /**
  29419. * Image src displayed during the video loading or until the user interacts with the video.
  29420. */
  29421. poster?: string;
  29422. }
  29423. /**
  29424. * If you want to display a video in your scene, this is the special texture for that.
  29425. * This special texture works similar to other textures, with the exception of a few parameters.
  29426. * @see https://doc.babylonjs.com/how_to/video_texture
  29427. */
  29428. export class VideoTexture extends Texture {
  29429. /**
  29430. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29431. */
  29432. readonly autoUpdateTexture: boolean;
  29433. /**
  29434. * The video instance used by the texture internally
  29435. */
  29436. readonly video: HTMLVideoElement;
  29437. private _onUserActionRequestedObservable;
  29438. /**
  29439. * Event triggerd when a dom action is required by the user to play the video.
  29440. * This happens due to recent changes in browser policies preventing video to auto start.
  29441. */
  29442. readonly onUserActionRequestedObservable: Observable<Texture>;
  29443. private _generateMipMaps;
  29444. private _engine;
  29445. private _stillImageCaptured;
  29446. private _displayingPosterTexture;
  29447. private _settings;
  29448. private _createInternalTextureOnEvent;
  29449. /**
  29450. * Creates a video texture.
  29451. * If you want to display a video in your scene, this is the special texture for that.
  29452. * This special texture works similar to other textures, with the exception of a few parameters.
  29453. * @see https://doc.babylonjs.com/how_to/video_texture
  29454. * @param name optional name, will detect from video source, if not defined
  29455. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29456. * @param scene is obviously the current scene.
  29457. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29458. * @param invertY is false by default but can be used to invert video on Y axis
  29459. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29460. * @param settings allows finer control over video usage
  29461. */
  29462. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29463. private _getName;
  29464. private _getVideo;
  29465. private _createInternalTexture;
  29466. private reset;
  29467. /**
  29468. * @hidden Internal method to initiate `update`.
  29469. */
  29470. _rebuild(): void;
  29471. /**
  29472. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29473. */
  29474. update(): void;
  29475. /**
  29476. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29477. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29478. */
  29479. updateTexture(isVisible: boolean): void;
  29480. protected _updateInternalTexture: () => void;
  29481. /**
  29482. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29483. * @param url New url.
  29484. */
  29485. updateURL(url: string): void;
  29486. /**
  29487. * Dispose the texture and release its associated resources.
  29488. */
  29489. dispose(): void;
  29490. /**
  29491. * Creates a video texture straight from a stream.
  29492. * @param scene Define the scene the texture should be created in
  29493. * @param stream Define the stream the texture should be created from
  29494. * @returns The created video texture as a promise
  29495. */
  29496. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29497. /**
  29498. * Creates a video texture straight from your WebCam video feed.
  29499. * @param scene Define the scene the texture should be created in
  29500. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29501. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29502. * @returns The created video texture as a promise
  29503. */
  29504. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29505. minWidth: number;
  29506. maxWidth: number;
  29507. minHeight: number;
  29508. maxHeight: number;
  29509. deviceId: string;
  29510. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29511. /**
  29512. * Creates a video texture straight from your WebCam video feed.
  29513. * @param scene Define the scene the texture should be created in
  29514. * @param onReady Define a callback to triggered once the texture will be ready
  29515. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29516. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29517. */
  29518. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29519. minWidth: number;
  29520. maxWidth: number;
  29521. minHeight: number;
  29522. maxHeight: number;
  29523. deviceId: string;
  29524. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29525. }
  29526. }
  29527. declare module BABYLON {
  29528. /**
  29529. * Defines the interface used by objects containing a viewport (like a camera)
  29530. */
  29531. interface IViewportOwnerLike {
  29532. /**
  29533. * Gets or sets the viewport
  29534. */
  29535. viewport: IViewportLike;
  29536. }
  29537. /**
  29538. * Interface for attribute information associated with buffer instanciation
  29539. */
  29540. export class InstancingAttributeInfo {
  29541. /**
  29542. * Index/offset of the attribute in the vertex shader
  29543. */
  29544. index: number;
  29545. /**
  29546. * size of the attribute, 1, 2, 3 or 4
  29547. */
  29548. attributeSize: number;
  29549. /**
  29550. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29551. * default is FLOAT
  29552. */
  29553. attribyteType: number;
  29554. /**
  29555. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29556. */
  29557. normalized: boolean;
  29558. /**
  29559. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29560. */
  29561. offset: number;
  29562. /**
  29563. * Name of the GLSL attribute, for debugging purpose only
  29564. */
  29565. attributeName: string;
  29566. }
  29567. /**
  29568. * Define options used to create a depth texture
  29569. */
  29570. export class DepthTextureCreationOptions {
  29571. /** Specifies whether or not a stencil should be allocated in the texture */
  29572. generateStencil?: boolean;
  29573. /** Specifies whether or not bilinear filtering is enable on the texture */
  29574. bilinearFiltering?: boolean;
  29575. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  29576. comparisonFunction?: number;
  29577. /** Specifies if the created texture is a cube texture */
  29578. isCube?: boolean;
  29579. }
  29580. /**
  29581. * Class used to describe the capabilities of the engine relatively to the current browser
  29582. */
  29583. export class EngineCapabilities {
  29584. /** Maximum textures units per fragment shader */
  29585. maxTexturesImageUnits: number;
  29586. /** Maximum texture units per vertex shader */
  29587. maxVertexTextureImageUnits: number;
  29588. /** Maximum textures units in the entire pipeline */
  29589. maxCombinedTexturesImageUnits: number;
  29590. /** Maximum texture size */
  29591. maxTextureSize: number;
  29592. /** Maximum cube texture size */
  29593. maxCubemapTextureSize: number;
  29594. /** Maximum render texture size */
  29595. maxRenderTextureSize: number;
  29596. /** Maximum number of vertex attributes */
  29597. maxVertexAttribs: number;
  29598. /** Maximum number of varyings */
  29599. maxVaryingVectors: number;
  29600. /** Maximum number of uniforms per vertex shader */
  29601. maxVertexUniformVectors: number;
  29602. /** Maximum number of uniforms per fragment shader */
  29603. maxFragmentUniformVectors: number;
  29604. /** Defines if standard derivates (dx/dy) are supported */
  29605. standardDerivatives: boolean;
  29606. /** Defines if s3tc texture compression is supported */
  29607. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29608. /** Defines if pvrtc texture compression is supported */
  29609. pvrtc: any;
  29610. /** Defines if etc1 texture compression is supported */
  29611. etc1: any;
  29612. /** Defines if etc2 texture compression is supported */
  29613. etc2: any;
  29614. /** Defines if astc texture compression is supported */
  29615. astc: any;
  29616. /** Defines if float textures are supported */
  29617. textureFloat: boolean;
  29618. /** Defines if vertex array objects are supported */
  29619. vertexArrayObject: boolean;
  29620. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29621. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29622. /** Gets the maximum level of anisotropy supported */
  29623. maxAnisotropy: number;
  29624. /** Defines if instancing is supported */
  29625. instancedArrays: boolean;
  29626. /** Defines if 32 bits indices are supported */
  29627. uintIndices: boolean;
  29628. /** Defines if high precision shaders are supported */
  29629. highPrecisionShaderSupported: boolean;
  29630. /** Defines if depth reading in the fragment shader is supported */
  29631. fragmentDepthSupported: boolean;
  29632. /** Defines if float texture linear filtering is supported*/
  29633. textureFloatLinearFiltering: boolean;
  29634. /** Defines if rendering to float textures is supported */
  29635. textureFloatRender: boolean;
  29636. /** Defines if half float textures are supported*/
  29637. textureHalfFloat: boolean;
  29638. /** Defines if half float texture linear filtering is supported*/
  29639. textureHalfFloatLinearFiltering: boolean;
  29640. /** Defines if rendering to half float textures is supported */
  29641. textureHalfFloatRender: boolean;
  29642. /** Defines if textureLOD shader command is supported */
  29643. textureLOD: boolean;
  29644. /** Defines if draw buffers extension is supported */
  29645. drawBuffersExtension: boolean;
  29646. /** Defines if depth textures are supported */
  29647. depthTextureExtension: boolean;
  29648. /** Defines if float color buffer are supported */
  29649. colorBufferFloat: boolean;
  29650. /** Gets disjoint timer query extension (null if not supported) */
  29651. timerQuery: EXT_disjoint_timer_query;
  29652. /** Defines if timestamp can be used with timer query */
  29653. canUseTimestampForTimerQuery: boolean;
  29654. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29655. multiview: any;
  29656. /** Function used to let the system compiles shaders in background */
  29657. parallelShaderCompile: {
  29658. COMPLETION_STATUS_KHR: number;
  29659. };
  29660. /** Max number of texture samples for MSAA */
  29661. maxMSAASamples: number;
  29662. }
  29663. /** Interface defining initialization parameters for Engine class */
  29664. export interface EngineOptions extends WebGLContextAttributes {
  29665. /**
  29666. * Defines if the engine should no exceed a specified device ratio
  29667. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29668. */
  29669. limitDeviceRatio?: number;
  29670. /**
  29671. * Defines if webvr should be enabled automatically
  29672. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29673. */
  29674. autoEnableWebVR?: boolean;
  29675. /**
  29676. * Defines if webgl2 should be turned off even if supported
  29677. * @see http://doc.babylonjs.com/features/webgl2
  29678. */
  29679. disableWebGL2Support?: boolean;
  29680. /**
  29681. * Defines if webaudio should be initialized as well
  29682. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29683. */
  29684. audioEngine?: boolean;
  29685. /**
  29686. * Defines if animations should run using a deterministic lock step
  29687. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29688. */
  29689. deterministicLockstep?: boolean;
  29690. /** Defines the maximum steps to use with deterministic lock step mode */
  29691. lockstepMaxSteps?: number;
  29692. /**
  29693. * Defines that engine should ignore context lost events
  29694. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29695. */
  29696. doNotHandleContextLost?: boolean;
  29697. /**
  29698. * Defines that engine should ignore modifying touch action attribute and style
  29699. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29700. */
  29701. doNotHandleTouchAction?: boolean;
  29702. /**
  29703. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29704. */
  29705. useHighPrecisionFloats?: boolean;
  29706. }
  29707. /**
  29708. * Defines the interface used by display changed events
  29709. */
  29710. export interface IDisplayChangedEventArgs {
  29711. /** Gets the vrDisplay object (if any) */
  29712. vrDisplay: Nullable<any>;
  29713. /** Gets a boolean indicating if webVR is supported */
  29714. vrSupported: boolean;
  29715. }
  29716. /**
  29717. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  29718. */
  29719. export class Engine {
  29720. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29721. static ExceptionList: ({
  29722. key: string;
  29723. capture: string;
  29724. captureConstraint: number;
  29725. targets: string[];
  29726. } | {
  29727. key: string;
  29728. capture: null;
  29729. captureConstraint: null;
  29730. targets: string[];
  29731. })[];
  29732. /** Gets the list of created engines */
  29733. static readonly Instances: Engine[];
  29734. /**
  29735. * Gets the latest created engine
  29736. */
  29737. static readonly LastCreatedEngine: Nullable<Engine>;
  29738. /**
  29739. * Gets the latest created scene
  29740. */
  29741. static readonly LastCreatedScene: Nullable<Scene>;
  29742. /**
  29743. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  29744. * @param flag defines which part of the materials must be marked as dirty
  29745. * @param predicate defines a predicate used to filter which materials should be affected
  29746. */
  29747. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  29748. /** @hidden */
  29749. static _TextureLoaders: IInternalTextureLoader[];
  29750. /** Defines that alpha blending is disabled */
  29751. static readonly ALPHA_DISABLE: number;
  29752. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  29753. static readonly ALPHA_ADD: number;
  29754. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  29755. static readonly ALPHA_COMBINE: number;
  29756. /** Defines that alpha blending to DEST - SRC * DEST */
  29757. static readonly ALPHA_SUBTRACT: number;
  29758. /** Defines that alpha blending to SRC * DEST */
  29759. static readonly ALPHA_MULTIPLY: number;
  29760. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  29761. static readonly ALPHA_MAXIMIZED: number;
  29762. /** Defines that alpha blending to SRC + DEST */
  29763. static readonly ALPHA_ONEONE: number;
  29764. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  29765. static readonly ALPHA_PREMULTIPLIED: number;
  29766. /**
  29767. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  29768. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  29769. */
  29770. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  29771. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  29772. static readonly ALPHA_INTERPOLATE: number;
  29773. /**
  29774. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  29775. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  29776. */
  29777. static readonly ALPHA_SCREENMODE: number;
  29778. /** Defines that the ressource is not delayed*/
  29779. static readonly DELAYLOADSTATE_NONE: number;
  29780. /** Defines that the ressource was successfully delay loaded */
  29781. static readonly DELAYLOADSTATE_LOADED: number;
  29782. /** Defines that the ressource is currently delay loading */
  29783. static readonly DELAYLOADSTATE_LOADING: number;
  29784. /** Defines that the ressource is delayed and has not started loading */
  29785. static readonly DELAYLOADSTATE_NOTLOADED: number;
  29786. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  29787. static readonly NEVER: number;
  29788. /** 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 */
  29789. static readonly ALWAYS: number;
  29790. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  29791. static readonly LESS: number;
  29792. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  29793. static readonly EQUAL: number;
  29794. /** 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 */
  29795. static readonly LEQUAL: number;
  29796. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  29797. static readonly GREATER: number;
  29798. /** 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 */
  29799. static readonly GEQUAL: number;
  29800. /** 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 */
  29801. static readonly NOTEQUAL: number;
  29802. /** Passed to stencilOperation to specify that stencil value must be kept */
  29803. static readonly KEEP: number;
  29804. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29805. static readonly REPLACE: number;
  29806. /** Passed to stencilOperation to specify that stencil value must be incremented */
  29807. static readonly INCR: number;
  29808. /** Passed to stencilOperation to specify that stencil value must be decremented */
  29809. static readonly DECR: number;
  29810. /** Passed to stencilOperation to specify that stencil value must be inverted */
  29811. static readonly INVERT: number;
  29812. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  29813. static readonly INCR_WRAP: number;
  29814. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  29815. static readonly DECR_WRAP: number;
  29816. /** Texture is not repeating outside of 0..1 UVs */
  29817. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  29818. /** Texture is repeating outside of 0..1 UVs */
  29819. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  29820. /** Texture is repeating and mirrored */
  29821. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  29822. /** ALPHA */
  29823. static readonly TEXTUREFORMAT_ALPHA: number;
  29824. /** LUMINANCE */
  29825. static readonly TEXTUREFORMAT_LUMINANCE: number;
  29826. /** LUMINANCE_ALPHA */
  29827. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  29828. /** RGB */
  29829. static readonly TEXTUREFORMAT_RGB: number;
  29830. /** RGBA */
  29831. static readonly TEXTUREFORMAT_RGBA: number;
  29832. /** RED */
  29833. static readonly TEXTUREFORMAT_RED: number;
  29834. /** RED (2nd reference) */
  29835. static readonly TEXTUREFORMAT_R: number;
  29836. /** RG */
  29837. static readonly TEXTUREFORMAT_RG: number;
  29838. /** RED_INTEGER */
  29839. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  29840. /** RED_INTEGER (2nd reference) */
  29841. static readonly TEXTUREFORMAT_R_INTEGER: number;
  29842. /** RG_INTEGER */
  29843. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  29844. /** RGB_INTEGER */
  29845. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  29846. /** RGBA_INTEGER */
  29847. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  29848. /** UNSIGNED_BYTE */
  29849. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  29850. /** UNSIGNED_BYTE (2nd reference) */
  29851. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  29852. /** FLOAT */
  29853. static readonly TEXTURETYPE_FLOAT: number;
  29854. /** HALF_FLOAT */
  29855. static readonly TEXTURETYPE_HALF_FLOAT: number;
  29856. /** BYTE */
  29857. static readonly TEXTURETYPE_BYTE: number;
  29858. /** SHORT */
  29859. static readonly TEXTURETYPE_SHORT: number;
  29860. /** UNSIGNED_SHORT */
  29861. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  29862. /** INT */
  29863. static readonly TEXTURETYPE_INT: number;
  29864. /** UNSIGNED_INT */
  29865. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  29866. /** UNSIGNED_SHORT_4_4_4_4 */
  29867. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  29868. /** UNSIGNED_SHORT_5_5_5_1 */
  29869. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  29870. /** UNSIGNED_SHORT_5_6_5 */
  29871. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  29872. /** UNSIGNED_INT_2_10_10_10_REV */
  29873. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  29874. /** UNSIGNED_INT_24_8 */
  29875. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  29876. /** UNSIGNED_INT_10F_11F_11F_REV */
  29877. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  29878. /** UNSIGNED_INT_5_9_9_9_REV */
  29879. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  29880. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  29881. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  29882. /** nearest is mag = nearest and min = nearest and mip = linear */
  29883. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  29884. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29885. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  29886. /** Trilinear is mag = linear and min = linear and mip = linear */
  29887. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  29888. /** nearest is mag = nearest and min = nearest and mip = linear */
  29889. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  29890. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29891. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  29892. /** Trilinear is mag = linear and min = linear and mip = linear */
  29893. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  29894. /** mag = nearest and min = nearest and mip = nearest */
  29895. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  29896. /** mag = nearest and min = linear and mip = nearest */
  29897. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  29898. /** mag = nearest and min = linear and mip = linear */
  29899. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  29900. /** mag = nearest and min = linear and mip = none */
  29901. static readonly TEXTURE_NEAREST_LINEAR: number;
  29902. /** mag = nearest and min = nearest and mip = none */
  29903. static readonly TEXTURE_NEAREST_NEAREST: number;
  29904. /** mag = linear and min = nearest and mip = nearest */
  29905. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  29906. /** mag = linear and min = nearest and mip = linear */
  29907. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  29908. /** mag = linear and min = linear and mip = none */
  29909. static readonly TEXTURE_LINEAR_LINEAR: number;
  29910. /** mag = linear and min = nearest and mip = none */
  29911. static readonly TEXTURE_LINEAR_NEAREST: number;
  29912. /** Explicit coordinates mode */
  29913. static readonly TEXTURE_EXPLICIT_MODE: number;
  29914. /** Spherical coordinates mode */
  29915. static readonly TEXTURE_SPHERICAL_MODE: number;
  29916. /** Planar coordinates mode */
  29917. static readonly TEXTURE_PLANAR_MODE: number;
  29918. /** Cubic coordinates mode */
  29919. static readonly TEXTURE_CUBIC_MODE: number;
  29920. /** Projection coordinates mode */
  29921. static readonly TEXTURE_PROJECTION_MODE: number;
  29922. /** Skybox coordinates mode */
  29923. static readonly TEXTURE_SKYBOX_MODE: number;
  29924. /** Inverse Cubic coordinates mode */
  29925. static readonly TEXTURE_INVCUBIC_MODE: number;
  29926. /** Equirectangular coordinates mode */
  29927. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  29928. /** Equirectangular Fixed coordinates mode */
  29929. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  29930. /** Equirectangular Fixed Mirrored coordinates mode */
  29931. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29932. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  29933. static readonly SCALEMODE_FLOOR: number;
  29934. /** Defines that texture rescaling will look for the nearest power of 2 size */
  29935. static readonly SCALEMODE_NEAREST: number;
  29936. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  29937. static readonly SCALEMODE_CEILING: number;
  29938. /**
  29939. * Returns the current npm package of the sdk
  29940. */
  29941. static readonly NpmPackage: string;
  29942. /**
  29943. * Returns the current version of the framework
  29944. */
  29945. static readonly Version: string;
  29946. /**
  29947. * Returns a string describing the current engine
  29948. */
  29949. readonly description: string;
  29950. /**
  29951. * Gets or sets the epsilon value used by collision engine
  29952. */
  29953. static CollisionsEpsilon: number;
  29954. /**
  29955. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29956. */
  29957. static ShadersRepository: string;
  29958. /**
  29959. * Method called to create the default loading screen.
  29960. * This can be overriden in your own app.
  29961. * @param canvas The rendering canvas element
  29962. * @returns The loading screen
  29963. */
  29964. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  29965. /**
  29966. * Method called to create the default rescale post process on each engine.
  29967. */
  29968. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  29969. /** @hidden */
  29970. _shaderProcessor: IShaderProcessor;
  29971. /**
  29972. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29973. */
  29974. forcePOTTextures: boolean;
  29975. /**
  29976. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29977. */
  29978. isFullscreen: boolean;
  29979. /**
  29980. * Gets a boolean indicating if the pointer is currently locked
  29981. */
  29982. isPointerLock: boolean;
  29983. /**
  29984. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29985. */
  29986. cullBackFaces: boolean;
  29987. /**
  29988. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29989. */
  29990. renderEvenInBackground: boolean;
  29991. /**
  29992. * Gets or sets a boolean indicating that cache can be kept between frames
  29993. */
  29994. preventCacheWipeBetweenFrames: boolean;
  29995. /**
  29996. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  29997. **/
  29998. enableOfflineSupport: boolean;
  29999. /**
  30000. * 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)
  30001. **/
  30002. disableManifestCheck: boolean;
  30003. /**
  30004. * Gets the list of created scenes
  30005. */
  30006. scenes: Scene[];
  30007. /**
  30008. * Event raised when a new scene is created
  30009. */
  30010. onNewSceneAddedObservable: Observable<Scene>;
  30011. /**
  30012. * Gets the list of created postprocesses
  30013. */
  30014. postProcesses: PostProcess[];
  30015. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30016. validateShaderPrograms: boolean;
  30017. /**
  30018. * Observable event triggered each time the rendering canvas is resized
  30019. */
  30020. onResizeObservable: Observable<Engine>;
  30021. /**
  30022. * Observable event triggered each time the canvas loses focus
  30023. */
  30024. onCanvasBlurObservable: Observable<Engine>;
  30025. /**
  30026. * Observable event triggered each time the canvas gains focus
  30027. */
  30028. onCanvasFocusObservable: Observable<Engine>;
  30029. /**
  30030. * Observable event triggered each time the canvas receives pointerout event
  30031. */
  30032. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30033. /**
  30034. * Observable event triggered before each texture is initialized
  30035. */
  30036. onBeforeTextureInitObservable: Observable<Texture>;
  30037. /**
  30038. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30039. */
  30040. disableUniformBuffers: boolean;
  30041. /** @hidden */
  30042. _uniformBuffers: UniformBuffer[];
  30043. /**
  30044. * Gets a boolean indicating that the engine supports uniform buffers
  30045. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30046. */
  30047. readonly supportsUniformBuffers: boolean;
  30048. /**
  30049. * Observable raised when the engine begins a new frame
  30050. */
  30051. onBeginFrameObservable: Observable<Engine>;
  30052. /**
  30053. * If set, will be used to request the next animation frame for the render loop
  30054. */
  30055. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30056. /**
  30057. * Observable raised when the engine ends the current frame
  30058. */
  30059. onEndFrameObservable: Observable<Engine>;
  30060. /**
  30061. * Observable raised when the engine is about to compile a shader
  30062. */
  30063. onBeforeShaderCompilationObservable: Observable<Engine>;
  30064. /**
  30065. * Observable raised when the engine has jsut compiled a shader
  30066. */
  30067. onAfterShaderCompilationObservable: Observable<Engine>;
  30068. /** @hidden */
  30069. _gl: WebGLRenderingContext;
  30070. private _renderingCanvas;
  30071. private _windowIsBackground;
  30072. private _webGLVersion;
  30073. protected _highPrecisionShadersAllowed: boolean;
  30074. /** @hidden */
  30075. readonly _shouldUseHighPrecisionShader: boolean;
  30076. /**
  30077. * Gets a boolean indicating that only power of 2 textures are supported
  30078. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30079. */
  30080. readonly needPOTTextures: boolean;
  30081. /** @hidden */
  30082. _badOS: boolean;
  30083. /** @hidden */
  30084. _badDesktopOS: boolean;
  30085. /**
  30086. * Gets the audio engine
  30087. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30088. * @ignorenaming
  30089. */
  30090. static audioEngine: IAudioEngine;
  30091. /**
  30092. * Default AudioEngine factory responsible of creating the Audio Engine.
  30093. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30094. */
  30095. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30096. /**
  30097. * Default offline support factory responsible of creating a tool used to store data locally.
  30098. * By default, this will create a Database object if the workload has been embedded.
  30099. */
  30100. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30101. private _onFocus;
  30102. private _onBlur;
  30103. private _onCanvasPointerOut;
  30104. private _onCanvasBlur;
  30105. private _onCanvasFocus;
  30106. private _onFullscreenChange;
  30107. private _onPointerLockChange;
  30108. private _hardwareScalingLevel;
  30109. /** @hidden */
  30110. _caps: EngineCapabilities;
  30111. private _pointerLockRequested;
  30112. private _isStencilEnable;
  30113. private _colorWrite;
  30114. private _loadingScreen;
  30115. /** @hidden */
  30116. _drawCalls: PerfCounter;
  30117. private _glVersion;
  30118. private _glRenderer;
  30119. private _glVendor;
  30120. private _videoTextureSupported;
  30121. private _renderingQueueLaunched;
  30122. private _activeRenderLoops;
  30123. private _deterministicLockstep;
  30124. private _lockstepMaxSteps;
  30125. /**
  30126. * Observable signaled when a context lost event is raised
  30127. */
  30128. onContextLostObservable: Observable<Engine>;
  30129. /**
  30130. * Observable signaled when a context restored event is raised
  30131. */
  30132. onContextRestoredObservable: Observable<Engine>;
  30133. private _onContextLost;
  30134. private _onContextRestored;
  30135. private _contextWasLost;
  30136. /** @hidden */
  30137. _doNotHandleContextLost: boolean;
  30138. /**
  30139. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30140. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30141. */
  30142. doNotHandleContextLost: boolean;
  30143. private _performanceMonitor;
  30144. private _fps;
  30145. private _deltaTime;
  30146. /**
  30147. * Turn this value on if you want to pause FPS computation when in background
  30148. */
  30149. disablePerformanceMonitorInBackground: boolean;
  30150. /**
  30151. * Gets the performance monitor attached to this engine
  30152. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30153. */
  30154. readonly performanceMonitor: PerformanceMonitor;
  30155. /**
  30156. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30157. */
  30158. disableVertexArrayObjects: boolean;
  30159. /** @hidden */
  30160. protected _depthCullingState: _DepthCullingState;
  30161. /** @hidden */
  30162. protected _stencilState: _StencilState;
  30163. /** @hidden */
  30164. protected _alphaState: _AlphaState;
  30165. /** @hidden */
  30166. protected _alphaMode: number;
  30167. /** @hidden */
  30168. _internalTexturesCache: InternalTexture[];
  30169. /** @hidden */
  30170. protected _activeChannel: number;
  30171. private _currentTextureChannel;
  30172. /** @hidden */
  30173. protected _boundTexturesCache: {
  30174. [key: string]: Nullable<InternalTexture>;
  30175. };
  30176. /** @hidden */
  30177. protected _currentEffect: Nullable<Effect>;
  30178. /** @hidden */
  30179. protected _currentProgram: Nullable<WebGLProgram>;
  30180. private _compiledEffects;
  30181. private _vertexAttribArraysEnabled;
  30182. /** @hidden */
  30183. protected _cachedViewport: Nullable<IViewportLike>;
  30184. private _cachedVertexArrayObject;
  30185. /** @hidden */
  30186. protected _cachedVertexBuffers: any;
  30187. /** @hidden */
  30188. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30189. /** @hidden */
  30190. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30191. /** @hidden */
  30192. _currentRenderTarget: Nullable<InternalTexture>;
  30193. private _uintIndicesCurrentlySet;
  30194. private _currentBoundBuffer;
  30195. /** @hidden */
  30196. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30197. private _currentBufferPointers;
  30198. private _currentInstanceLocations;
  30199. private _currentInstanceBuffers;
  30200. private _textureUnits;
  30201. /** @hidden */
  30202. _workingCanvas: Nullable<HTMLCanvasElement>;
  30203. /** @hidden */
  30204. _workingContext: Nullable<CanvasRenderingContext2D>;
  30205. private _rescalePostProcess;
  30206. private _dummyFramebuffer;
  30207. private _externalData;
  30208. /** @hidden */
  30209. _bindedRenderFunction: any;
  30210. private _vaoRecordInProgress;
  30211. private _mustWipeVertexAttributes;
  30212. private _emptyTexture;
  30213. private _emptyCubeTexture;
  30214. private _emptyTexture3D;
  30215. /** @hidden */
  30216. _frameHandler: number;
  30217. private _nextFreeTextureSlots;
  30218. private _maxSimultaneousTextures;
  30219. private _activeRequests;
  30220. private _texturesSupported;
  30221. /** @hidden */
  30222. _textureFormatInUse: Nullable<string>;
  30223. /**
  30224. * Gets the list of texture formats supported
  30225. */
  30226. readonly texturesSupported: Array<string>;
  30227. /**
  30228. * Gets the list of texture formats in use
  30229. */
  30230. readonly textureFormatInUse: Nullable<string>;
  30231. /**
  30232. * Gets the current viewport
  30233. */
  30234. readonly currentViewport: Nullable<IViewportLike>;
  30235. /**
  30236. * Gets the default empty texture
  30237. */
  30238. readonly emptyTexture: InternalTexture;
  30239. /**
  30240. * Gets the default empty 3D texture
  30241. */
  30242. readonly emptyTexture3D: InternalTexture;
  30243. /**
  30244. * Gets the default empty cube texture
  30245. */
  30246. readonly emptyCubeTexture: InternalTexture;
  30247. /**
  30248. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30249. */
  30250. readonly premultipliedAlpha: boolean;
  30251. /**
  30252. * Creates a new engine
  30253. * @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
  30254. * @param antialias defines enable antialiasing (default: false)
  30255. * @param options defines further options to be sent to the getContext() function
  30256. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30257. */
  30258. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30259. /**
  30260. * Initializes a webVR display and starts listening to display change events
  30261. * The onVRDisplayChangedObservable will be notified upon these changes
  30262. * @returns The onVRDisplayChangedObservable
  30263. */
  30264. initWebVR(): Observable<IDisplayChangedEventArgs>;
  30265. /** @hidden */
  30266. _prepareVRComponent(): void;
  30267. /** @hidden */
  30268. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  30269. /** @hidden */
  30270. _submitVRFrame(): void;
  30271. /**
  30272. * Call this function to leave webVR mode
  30273. * Will do nothing if webVR is not supported or if there is no webVR device
  30274. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30275. */
  30276. disableVR(): void;
  30277. /**
  30278. * Gets a boolean indicating that the system is in VR mode and is presenting
  30279. * @returns true if VR mode is engaged
  30280. */
  30281. isVRPresenting(): boolean;
  30282. /** @hidden */
  30283. _requestVRFrame(): void;
  30284. private _disableTouchAction;
  30285. private _rebuildInternalTextures;
  30286. private _rebuildEffects;
  30287. /**
  30288. * Gets a boolean indicating if all created effects are ready
  30289. * @returns true if all effects are ready
  30290. */
  30291. areAllEffectsReady(): boolean;
  30292. private _rebuildBuffers;
  30293. private _initGLContext;
  30294. /**
  30295. * Gets version of the current webGL context
  30296. */
  30297. readonly webGLVersion: number;
  30298. /**
  30299. * Gets a string idenfifying the name of the class
  30300. * @returns "Engine" string
  30301. */
  30302. getClassName(): string;
  30303. /**
  30304. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30305. */
  30306. readonly isStencilEnable: boolean;
  30307. /** @hidden */
  30308. _prepareWorkingCanvas(): void;
  30309. /**
  30310. * Reset the texture cache to empty state
  30311. */
  30312. resetTextureCache(): void;
  30313. /**
  30314. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  30315. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30316. * @returns true if engine is in deterministic lock step mode
  30317. */
  30318. isDeterministicLockStep(): boolean;
  30319. /**
  30320. * Gets the max steps when engine is running in deterministic lock step
  30321. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30322. * @returns the max steps
  30323. */
  30324. getLockstepMaxSteps(): number;
  30325. /**
  30326. * Gets an object containing information about the current webGL context
  30327. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30328. */
  30329. getGlInfo(): {
  30330. vendor: string;
  30331. renderer: string;
  30332. version: string;
  30333. };
  30334. /**
  30335. * Gets current aspect ratio
  30336. * @param viewportOwner defines the camera to use to get the aspect ratio
  30337. * @param useScreen defines if screen size must be used (or the current render target if any)
  30338. * @returns a number defining the aspect ratio
  30339. */
  30340. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  30341. /**
  30342. * Gets current screen aspect ratio
  30343. * @returns a number defining the aspect ratio
  30344. */
  30345. getScreenAspectRatio(): number;
  30346. /**
  30347. * Gets the current render width
  30348. * @param useScreen defines if screen size must be used (or the current render target if any)
  30349. * @returns a number defining the current render width
  30350. */
  30351. getRenderWidth(useScreen?: boolean): number;
  30352. /**
  30353. * Gets the current render height
  30354. * @param useScreen defines if screen size must be used (or the current render target if any)
  30355. * @returns a number defining the current render height
  30356. */
  30357. getRenderHeight(useScreen?: boolean): number;
  30358. /**
  30359. * Gets the HTML canvas attached with the current webGL context
  30360. * @returns a HTML canvas
  30361. */
  30362. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30363. /**
  30364. * Gets host window
  30365. * @returns the host window object
  30366. */
  30367. getHostWindow(): Window;
  30368. /**
  30369. * Gets host document
  30370. * @returns the host document object
  30371. */
  30372. getHostDocument(): Document;
  30373. /**
  30374. * Gets the client rect of the HTML canvas attached with the current webGL context
  30375. * @returns a client rectanglee
  30376. */
  30377. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  30378. /**
  30379. * Defines the hardware scaling level.
  30380. * By default the hardware scaling level is computed from the window device ratio.
  30381. * 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.
  30382. * @param level defines the level to use
  30383. */
  30384. setHardwareScalingLevel(level: number): void;
  30385. /**
  30386. * Gets the current hardware scaling level.
  30387. * By default the hardware scaling level is computed from the window device ratio.
  30388. * 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.
  30389. * @returns a number indicating the current hardware scaling level
  30390. */
  30391. getHardwareScalingLevel(): number;
  30392. /**
  30393. * Gets the list of loaded textures
  30394. * @returns an array containing all loaded textures
  30395. */
  30396. getLoadedTexturesCache(): InternalTexture[];
  30397. /**
  30398. * Gets the object containing all engine capabilities
  30399. * @returns the EngineCapabilities object
  30400. */
  30401. getCaps(): EngineCapabilities;
  30402. /**
  30403. * Gets the current depth function
  30404. * @returns a number defining the depth function
  30405. */
  30406. getDepthFunction(): Nullable<number>;
  30407. /**
  30408. * Sets the current depth function
  30409. * @param depthFunc defines the function to use
  30410. */
  30411. setDepthFunction(depthFunc: number): void;
  30412. /**
  30413. * Sets the current depth function to GREATER
  30414. */
  30415. setDepthFunctionToGreater(): void;
  30416. /**
  30417. * Sets the current depth function to GEQUAL
  30418. */
  30419. setDepthFunctionToGreaterOrEqual(): void;
  30420. /**
  30421. * Sets the current depth function to LESS
  30422. */
  30423. setDepthFunctionToLess(): void;
  30424. private _cachedStencilBuffer;
  30425. private _cachedStencilFunction;
  30426. private _cachedStencilMask;
  30427. private _cachedStencilOperationPass;
  30428. private _cachedStencilOperationFail;
  30429. private _cachedStencilOperationDepthFail;
  30430. private _cachedStencilReference;
  30431. /**
  30432. * Caches the the state of the stencil buffer
  30433. */
  30434. cacheStencilState(): void;
  30435. /**
  30436. * Restores the state of the stencil buffer
  30437. */
  30438. restoreStencilState(): void;
  30439. /**
  30440. * Sets the current depth function to LEQUAL
  30441. */
  30442. setDepthFunctionToLessOrEqual(): void;
  30443. /**
  30444. * Gets a boolean indicating if stencil buffer is enabled
  30445. * @returns the current stencil buffer state
  30446. */
  30447. getStencilBuffer(): boolean;
  30448. /**
  30449. * Enable or disable the stencil buffer
  30450. * @param enable defines if the stencil buffer must be enabled or disabled
  30451. */
  30452. setStencilBuffer(enable: boolean): void;
  30453. /**
  30454. * Gets the current stencil mask
  30455. * @returns a number defining the new stencil mask to use
  30456. */
  30457. getStencilMask(): number;
  30458. /**
  30459. * Sets the current stencil mask
  30460. * @param mask defines the new stencil mask to use
  30461. */
  30462. setStencilMask(mask: number): void;
  30463. /**
  30464. * Gets the current stencil function
  30465. * @returns a number defining the stencil function to use
  30466. */
  30467. getStencilFunction(): number;
  30468. /**
  30469. * Gets the current stencil reference value
  30470. * @returns a number defining the stencil reference value to use
  30471. */
  30472. getStencilFunctionReference(): number;
  30473. /**
  30474. * Gets the current stencil mask
  30475. * @returns a number defining the stencil mask to use
  30476. */
  30477. getStencilFunctionMask(): number;
  30478. /**
  30479. * Sets the current stencil function
  30480. * @param stencilFunc defines the new stencil function to use
  30481. */
  30482. setStencilFunction(stencilFunc: number): void;
  30483. /**
  30484. * Sets the current stencil reference
  30485. * @param reference defines the new stencil reference to use
  30486. */
  30487. setStencilFunctionReference(reference: number): void;
  30488. /**
  30489. * Sets the current stencil mask
  30490. * @param mask defines the new stencil mask to use
  30491. */
  30492. setStencilFunctionMask(mask: number): void;
  30493. /**
  30494. * Gets the current stencil operation when stencil fails
  30495. * @returns a number defining stencil operation to use when stencil fails
  30496. */
  30497. getStencilOperationFail(): number;
  30498. /**
  30499. * Gets the current stencil operation when depth fails
  30500. * @returns a number defining stencil operation to use when depth fails
  30501. */
  30502. getStencilOperationDepthFail(): number;
  30503. /**
  30504. * Gets the current stencil operation when stencil passes
  30505. * @returns a number defining stencil operation to use when stencil passes
  30506. */
  30507. getStencilOperationPass(): number;
  30508. /**
  30509. * Sets the stencil operation to use when stencil fails
  30510. * @param operation defines the stencil operation to use when stencil fails
  30511. */
  30512. setStencilOperationFail(operation: number): void;
  30513. /**
  30514. * Sets the stencil operation to use when depth fails
  30515. * @param operation defines the stencil operation to use when depth fails
  30516. */
  30517. setStencilOperationDepthFail(operation: number): void;
  30518. /**
  30519. * Sets the stencil operation to use when stencil passes
  30520. * @param operation defines the stencil operation to use when stencil passes
  30521. */
  30522. setStencilOperationPass(operation: number): void;
  30523. /**
  30524. * Sets a boolean indicating if the dithering state is enabled or disabled
  30525. * @param value defines the dithering state
  30526. */
  30527. setDitheringState(value: boolean): void;
  30528. /**
  30529. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  30530. * @param value defines the rasterizer state
  30531. */
  30532. setRasterizerState(value: boolean): void;
  30533. /**
  30534. * stop executing a render loop function and remove it from the execution array
  30535. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30536. */
  30537. stopRenderLoop(renderFunction?: () => void): void;
  30538. /** @hidden */
  30539. _renderLoop(): void;
  30540. /**
  30541. * Register and execute a render loop. The engine can have more than one render function
  30542. * @param renderFunction defines the function to continuously execute
  30543. */
  30544. runRenderLoop(renderFunction: () => void): void;
  30545. /**
  30546. * Toggle full screen mode
  30547. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30548. */
  30549. switchFullscreen(requestPointerLock: boolean): void;
  30550. /**
  30551. * Enters full screen mode
  30552. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30553. */
  30554. enterFullscreen(requestPointerLock: boolean): void;
  30555. /**
  30556. * Exits full screen mode
  30557. */
  30558. exitFullscreen(): void;
  30559. /**
  30560. * Enters Pointerlock mode
  30561. */
  30562. enterPointerlock(): void;
  30563. /**
  30564. * Exits Pointerlock mode
  30565. */
  30566. exitPointerlock(): void;
  30567. /**
  30568. * Clear the current render buffer or the current render target (if any is set up)
  30569. * @param color defines the color to use
  30570. * @param backBuffer defines if the back buffer must be cleared
  30571. * @param depth defines if the depth buffer must be cleared
  30572. * @param stencil defines if the stencil buffer must be cleared
  30573. */
  30574. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30575. /**
  30576. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  30577. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30578. * @param y defines the y-coordinate of the corner of the clear rectangle
  30579. * @param width defines the width of the clear rectangle
  30580. * @param height defines the height of the clear rectangle
  30581. * @param clearColor defines the clear color
  30582. */
  30583. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  30584. /**
  30585. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  30586. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30587. * @param y defines the y-coordinate of the corner of the clear rectangle
  30588. * @param width defines the width of the clear rectangle
  30589. * @param height defines the height of the clear rectangle
  30590. */
  30591. enableScissor(x: number, y: number, width: number, height: number): void;
  30592. /**
  30593. * Disable previously set scissor test rectangle
  30594. */
  30595. disableScissor(): void;
  30596. private _viewportCached;
  30597. /** @hidden */
  30598. _viewport(x: number, y: number, width: number, height: number): void;
  30599. /**
  30600. * Set the WebGL's viewport
  30601. * @param viewport defines the viewport element to be used
  30602. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30603. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30604. */
  30605. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30606. /**
  30607. * Directly set the WebGL Viewport
  30608. * @param x defines the x coordinate of the viewport (in screen space)
  30609. * @param y defines the y coordinate of the viewport (in screen space)
  30610. * @param width defines the width of the viewport (in screen space)
  30611. * @param height defines the height of the viewport (in screen space)
  30612. * @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
  30613. */
  30614. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  30615. /**
  30616. * Begin a new frame
  30617. */
  30618. beginFrame(): void;
  30619. /**
  30620. * Enf the current frame
  30621. */
  30622. endFrame(): void;
  30623. /**
  30624. * Resize the view according to the canvas' size
  30625. */
  30626. resize(): void;
  30627. /**
  30628. * Force a specific size of the canvas
  30629. * @param width defines the new canvas' width
  30630. * @param height defines the new canvas' height
  30631. */
  30632. setSize(width: number, height: number): void;
  30633. /**
  30634. * Binds the frame buffer to the specified texture.
  30635. * @param texture The texture to render to or null for the default canvas
  30636. * @param faceIndex The face of the texture to render to in case of cube texture
  30637. * @param requiredWidth The width of the target to render to
  30638. * @param requiredHeight The height of the target to render to
  30639. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30640. * @param depthStencilTexture The depth stencil texture to use to render
  30641. * @param lodLevel defines le lod level to bind to the frame buffer
  30642. */
  30643. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30644. /** @hidden */
  30645. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30646. /**
  30647. * Unbind the current render target texture from the webGL context
  30648. * @param texture defines the render target texture to unbind
  30649. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30650. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30651. */
  30652. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30653. /**
  30654. * Force the mipmap generation for the given render target texture
  30655. * @param texture defines the render target texture to use
  30656. */
  30657. generateMipMapsForCubemap(texture: InternalTexture): void;
  30658. /**
  30659. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30660. */
  30661. flushFramebuffer(): void;
  30662. /**
  30663. * Unbind the current render target and bind the default framebuffer
  30664. */
  30665. restoreDefaultFramebuffer(): void;
  30666. /**
  30667. * Create an uniform buffer
  30668. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30669. * @param elements defines the content of the uniform buffer
  30670. * @returns the webGL uniform buffer
  30671. */
  30672. createUniformBuffer(elements: FloatArray): DataBuffer;
  30673. /**
  30674. * Create a dynamic uniform buffer
  30675. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30676. * @param elements defines the content of the uniform buffer
  30677. * @returns the webGL uniform buffer
  30678. */
  30679. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  30680. /**
  30681. * Update an existing uniform buffer
  30682. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30683. * @param uniformBuffer defines the target uniform buffer
  30684. * @param elements defines the content to update
  30685. * @param offset defines the offset in the uniform buffer where update should start
  30686. * @param count defines the size of the data to update
  30687. */
  30688. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  30689. private _resetVertexBufferBinding;
  30690. /**
  30691. * Creates a vertex buffer
  30692. * @param data the data for the vertex buffer
  30693. * @returns the new WebGL static buffer
  30694. */
  30695. createVertexBuffer(data: DataArray): DataBuffer;
  30696. /**
  30697. * Creates a dynamic vertex buffer
  30698. * @param data the data for the dynamic vertex buffer
  30699. * @returns the new WebGL dynamic buffer
  30700. */
  30701. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30702. /**
  30703. * Update a dynamic index buffer
  30704. * @param indexBuffer defines the target index buffer
  30705. * @param indices defines the data to update
  30706. * @param offset defines the offset in the target index buffer where update should start
  30707. */
  30708. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  30709. /**
  30710. * Updates a dynamic vertex buffer.
  30711. * @param vertexBuffer the vertex buffer to update
  30712. * @param data the data used to update the vertex buffer
  30713. * @param byteOffset the byte offset of the data
  30714. * @param byteLength the byte length of the data
  30715. */
  30716. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30717. private _resetIndexBufferBinding;
  30718. /**
  30719. * Creates a new index buffer
  30720. * @param indices defines the content of the index buffer
  30721. * @param updatable defines if the index buffer must be updatable
  30722. * @returns a new webGL buffer
  30723. */
  30724. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30725. /**
  30726. * Bind a webGL buffer to the webGL context
  30727. * @param buffer defines the buffer to bind
  30728. */
  30729. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30730. /**
  30731. * Bind an uniform buffer to the current webGL context
  30732. * @param buffer defines the buffer to bind
  30733. */
  30734. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  30735. /**
  30736. * Bind a buffer to the current webGL context at a given location
  30737. * @param buffer defines the buffer to bind
  30738. * @param location defines the index where to bind the buffer
  30739. */
  30740. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  30741. /**
  30742. * Bind a specific block at a given index in a specific shader program
  30743. * @param pipelineContext defines the pipeline context to use
  30744. * @param blockName defines the block name
  30745. * @param index defines the index where to bind the block
  30746. */
  30747. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  30748. private bindIndexBuffer;
  30749. private bindBuffer;
  30750. /**
  30751. * update the bound buffer with the given data
  30752. * @param data defines the data to update
  30753. */
  30754. updateArrayBuffer(data: Float32Array): void;
  30755. private _vertexAttribPointer;
  30756. private _bindIndexBufferWithCache;
  30757. private _bindVertexBuffersAttributes;
  30758. /**
  30759. * Records a vertex array object
  30760. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30761. * @param vertexBuffers defines the list of vertex buffers to store
  30762. * @param indexBuffer defines the index buffer to store
  30763. * @param effect defines the effect to store
  30764. * @returns the new vertex array object
  30765. */
  30766. recordVertexArrayObject(vertexBuffers: {
  30767. [key: string]: VertexBuffer;
  30768. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30769. /**
  30770. * Bind a specific vertex array object
  30771. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30772. * @param vertexArrayObject defines the vertex array object to bind
  30773. * @param indexBuffer defines the index buffer to bind
  30774. */
  30775. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30776. /**
  30777. * Bind webGl buffers directly to the webGL context
  30778. * @param vertexBuffer defines the vertex buffer to bind
  30779. * @param indexBuffer defines the index buffer to bind
  30780. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30781. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30782. * @param effect defines the effect associated with the vertex buffer
  30783. */
  30784. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30785. private _unbindVertexArrayObject;
  30786. /**
  30787. * Bind a list of vertex buffers to the webGL context
  30788. * @param vertexBuffers defines the list of vertex buffers to bind
  30789. * @param indexBuffer defines the index buffer to bind
  30790. * @param effect defines the effect associated with the vertex buffers
  30791. */
  30792. bindBuffers(vertexBuffers: {
  30793. [key: string]: Nullable<VertexBuffer>;
  30794. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30795. /**
  30796. * Unbind all instance attributes
  30797. */
  30798. unbindInstanceAttributes(): void;
  30799. /**
  30800. * Release and free the memory of a vertex array object
  30801. * @param vao defines the vertex array object to delete
  30802. */
  30803. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30804. /** @hidden */
  30805. _releaseBuffer(buffer: DataBuffer): boolean;
  30806. /**
  30807. * Creates a webGL buffer to use with instanciation
  30808. * @param capacity defines the size of the buffer
  30809. * @returns the webGL buffer
  30810. */
  30811. createInstancesBuffer(capacity: number): DataBuffer;
  30812. /**
  30813. * Delete a webGL buffer used with instanciation
  30814. * @param buffer defines the webGL buffer to delete
  30815. */
  30816. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30817. /**
  30818. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30819. * @param instancesBuffer defines the webGL buffer to update and bind
  30820. * @param data defines the data to store in the buffer
  30821. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30822. */
  30823. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30824. /**
  30825. * Apply all cached states (depth, culling, stencil and alpha)
  30826. */
  30827. applyStates(): void;
  30828. /**
  30829. * Send a draw order
  30830. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30831. * @param indexStart defines the starting index
  30832. * @param indexCount defines the number of index to draw
  30833. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30834. */
  30835. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30836. /**
  30837. * Draw a list of points
  30838. * @param verticesStart defines the index of first vertex to draw
  30839. * @param verticesCount defines the count of vertices to draw
  30840. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30841. */
  30842. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30843. /**
  30844. * Draw a list of unindexed primitives
  30845. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30846. * @param verticesStart defines the index of first vertex to draw
  30847. * @param verticesCount defines the count of vertices to draw
  30848. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30849. */
  30850. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30851. /**
  30852. * Draw a list of indexed primitives
  30853. * @param fillMode defines the primitive to use
  30854. * @param indexStart defines the starting index
  30855. * @param indexCount defines the number of index to draw
  30856. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30857. */
  30858. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30859. /**
  30860. * Draw a list of unindexed primitives
  30861. * @param fillMode defines the primitive to use
  30862. * @param verticesStart defines the index of first vertex to draw
  30863. * @param verticesCount defines the count of vertices to draw
  30864. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30865. */
  30866. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30867. private _drawMode;
  30868. /** @hidden */
  30869. _releaseEffect(effect: Effect): void;
  30870. /** @hidden */
  30871. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30872. /**
  30873. * Create a new effect (used to store vertex/fragment shaders)
  30874. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30875. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30876. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30877. * @param samplers defines an array of string used to represent textures
  30878. * @param defines defines the string containing the defines to use to compile the shaders
  30879. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30880. * @param onCompiled defines a function to call when the effect creation is successful
  30881. * @param onError defines a function to call when the effect creation has failed
  30882. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30883. * @returns the new Effect
  30884. */
  30885. 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;
  30886. private _compileShader;
  30887. private _compileRawShader;
  30888. /**
  30889. * Directly creates a webGL program
  30890. * @param pipelineContext defines the pipeline context to attach to
  30891. * @param vertexCode defines the vertex shader code to use
  30892. * @param fragmentCode defines the fragment shader code to use
  30893. * @param context defines the webGL context to use (if not set, the current one will be used)
  30894. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30895. * @returns the new webGL program
  30896. */
  30897. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30898. /**
  30899. * Creates a webGL program
  30900. * @param pipelineContext defines the pipeline context to attach to
  30901. * @param vertexCode defines the vertex shader code to use
  30902. * @param fragmentCode defines the fragment shader code to use
  30903. * @param defines defines the string containing the defines to use to compile the shaders
  30904. * @param context defines the webGL context to use (if not set, the current one will be used)
  30905. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30906. * @returns the new webGL program
  30907. */
  30908. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30909. /**
  30910. * Creates a new pipeline context
  30911. * @returns the new pipeline
  30912. */
  30913. createPipelineContext(): WebGLPipelineContext;
  30914. private _createShaderProgram;
  30915. private _finalizePipelineContext;
  30916. /** @hidden */
  30917. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30918. /** @hidden */
  30919. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30920. /** @hidden */
  30921. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30922. /**
  30923. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30924. * @param pipelineContext defines the pipeline context to use
  30925. * @param uniformsNames defines the list of uniform names
  30926. * @returns an array of webGL uniform locations
  30927. */
  30928. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30929. /**
  30930. * Gets the lsit of active attributes for a given webGL program
  30931. * @param pipelineContext defines the pipeline context to use
  30932. * @param attributesNames defines the list of attribute names to get
  30933. * @returns an array of indices indicating the offset of each attribute
  30934. */
  30935. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30936. /**
  30937. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30938. * @param effect defines the effect to activate
  30939. */
  30940. enableEffect(effect: Nullable<Effect>): void;
  30941. /**
  30942. * Set the value of an uniform to an array of int32
  30943. * @param uniform defines the webGL uniform location where to store the value
  30944. * @param array defines the array of int32 to store
  30945. */
  30946. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30947. /**
  30948. * Set the value of an uniform to an array of int32 (stored as vec2)
  30949. * @param uniform defines the webGL uniform location where to store the value
  30950. * @param array defines the array of int32 to store
  30951. */
  30952. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30953. /**
  30954. * Set the value of an uniform to an array of int32 (stored as vec3)
  30955. * @param uniform defines the webGL uniform location where to store the value
  30956. * @param array defines the array of int32 to store
  30957. */
  30958. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30959. /**
  30960. * Set the value of an uniform to an array of int32 (stored as vec4)
  30961. * @param uniform defines the webGL uniform location where to store the value
  30962. * @param array defines the array of int32 to store
  30963. */
  30964. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30965. /**
  30966. * Set the value of an uniform to an array of float32
  30967. * @param uniform defines the webGL uniform location where to store the value
  30968. * @param array defines the array of float32 to store
  30969. */
  30970. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30971. /**
  30972. * Set the value of an uniform to an array of float32 (stored as vec2)
  30973. * @param uniform defines the webGL uniform location where to store the value
  30974. * @param array defines the array of float32 to store
  30975. */
  30976. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30977. /**
  30978. * Set the value of an uniform to an array of float32 (stored as vec3)
  30979. * @param uniform defines the webGL uniform location where to store the value
  30980. * @param array defines the array of float32 to store
  30981. */
  30982. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30983. /**
  30984. * Set the value of an uniform to an array of float32 (stored as vec4)
  30985. * @param uniform defines the webGL uniform location where to store the value
  30986. * @param array defines the array of float32 to store
  30987. */
  30988. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30989. /**
  30990. * Set the value of an uniform to an array of number
  30991. * @param uniform defines the webGL uniform location where to store the value
  30992. * @param array defines the array of number to store
  30993. */
  30994. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30995. /**
  30996. * Set the value of an uniform to an array of number (stored as vec2)
  30997. * @param uniform defines the webGL uniform location where to store the value
  30998. * @param array defines the array of number to store
  30999. */
  31000. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31001. /**
  31002. * Set the value of an uniform to an array of number (stored as vec3)
  31003. * @param uniform defines the webGL uniform location where to store the value
  31004. * @param array defines the array of number to store
  31005. */
  31006. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31007. /**
  31008. * Set the value of an uniform to an array of number (stored as vec4)
  31009. * @param uniform defines the webGL uniform location where to store the value
  31010. * @param array defines the array of number to store
  31011. */
  31012. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31013. /**
  31014. * Set the value of an uniform to an array of float32 (stored as matrices)
  31015. * @param uniform defines the webGL uniform location where to store the value
  31016. * @param matrices defines the array of float32 to store
  31017. */
  31018. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31019. /**
  31020. * Set the value of an uniform to a matrix (3x3)
  31021. * @param uniform defines the webGL uniform location where to store the value
  31022. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31023. */
  31024. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31025. /**
  31026. * Set the value of an uniform to a matrix (2x2)
  31027. * @param uniform defines the webGL uniform location where to store the value
  31028. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31029. */
  31030. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31031. /**
  31032. * Set the value of an uniform to a number (int)
  31033. * @param uniform defines the webGL uniform location where to store the value
  31034. * @param value defines the int number to store
  31035. */
  31036. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31037. /**
  31038. * Set the value of an uniform to a number (float)
  31039. * @param uniform defines the webGL uniform location where to store the value
  31040. * @param value defines the float number to store
  31041. */
  31042. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31043. /**
  31044. * Set the value of an uniform to a vec2
  31045. * @param uniform defines the webGL uniform location where to store the value
  31046. * @param x defines the 1st component of the value
  31047. * @param y defines the 2nd component of the value
  31048. */
  31049. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31050. /**
  31051. * Set the value of an uniform to a vec3
  31052. * @param uniform defines the webGL uniform location where to store the value
  31053. * @param x defines the 1st component of the value
  31054. * @param y defines the 2nd component of the value
  31055. * @param z defines the 3rd component of the value
  31056. */
  31057. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31058. /**
  31059. * Set the value of an uniform to a boolean
  31060. * @param uniform defines the webGL uniform location where to store the value
  31061. * @param bool defines the boolean to store
  31062. */
  31063. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31064. /**
  31065. * Set the value of an uniform to a vec4
  31066. * @param uniform defines the webGL uniform location where to store the value
  31067. * @param x defines the 1st component of the value
  31068. * @param y defines the 2nd component of the value
  31069. * @param z defines the 3rd component of the value
  31070. * @param w defines the 4th component of the value
  31071. */
  31072. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31073. /**
  31074. * Sets a Color4 on a uniform variable
  31075. * @param uniform defines the uniform location
  31076. * @param color4 defines the value to be set
  31077. */
  31078. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31079. /**
  31080. * Set various states to the webGL context
  31081. * @param culling defines backface culling state
  31082. * @param zOffset defines the value to apply to zOffset (0 by default)
  31083. * @param force defines if states must be applied even if cache is up to date
  31084. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31085. */
  31086. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31087. /**
  31088. * Set the z offset to apply to current rendering
  31089. * @param value defines the offset to apply
  31090. */
  31091. setZOffset(value: number): void;
  31092. /**
  31093. * Gets the current value of the zOffset
  31094. * @returns the current zOffset state
  31095. */
  31096. getZOffset(): number;
  31097. /**
  31098. * Enable or disable depth buffering
  31099. * @param enable defines the state to set
  31100. */
  31101. setDepthBuffer(enable: boolean): void;
  31102. /**
  31103. * Gets a boolean indicating if depth writing is enabled
  31104. * @returns the current depth writing state
  31105. */
  31106. getDepthWrite(): boolean;
  31107. /**
  31108. * Enable or disable depth writing
  31109. * @param enable defines the state to set
  31110. */
  31111. setDepthWrite(enable: boolean): void;
  31112. /**
  31113. * Enable or disable color writing
  31114. * @param enable defines the state to set
  31115. */
  31116. setColorWrite(enable: boolean): void;
  31117. /**
  31118. * Gets a boolean indicating if color writing is enabled
  31119. * @returns the current color writing state
  31120. */
  31121. getColorWrite(): boolean;
  31122. /**
  31123. * Sets alpha constants used by some alpha blending modes
  31124. * @param r defines the red component
  31125. * @param g defines the green component
  31126. * @param b defines the blue component
  31127. * @param a defines the alpha component
  31128. */
  31129. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31130. /**
  31131. * Sets the current alpha mode
  31132. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31133. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31134. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31135. */
  31136. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31137. /**
  31138. * Gets the current alpha mode
  31139. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31140. * @returns the current alpha mode
  31141. */
  31142. getAlphaMode(): number;
  31143. /**
  31144. * Clears the list of texture accessible through engine.
  31145. * This can help preventing texture load conflict due to name collision.
  31146. */
  31147. clearInternalTexturesCache(): void;
  31148. /**
  31149. * Force the entire cache to be cleared
  31150. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31151. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31152. */
  31153. wipeCaches(bruteForce?: boolean): void;
  31154. /**
  31155. * Set the compressed texture format to use, based on the formats you have, and the formats
  31156. * supported by the hardware / browser.
  31157. *
  31158. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31159. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31160. * to API arguments needed to compressed textures. This puts the burden on the container
  31161. * generator to house the arcane code for determining these for current & future formats.
  31162. *
  31163. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31164. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31165. *
  31166. * Note: The result of this call is not taken into account when a texture is base64.
  31167. *
  31168. * @param formatsAvailable defines the list of those format families you have created
  31169. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31170. *
  31171. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31172. * @returns The extension selected.
  31173. */
  31174. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31175. /** @hidden */
  31176. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31177. min: number;
  31178. mag: number;
  31179. };
  31180. /** @hidden */
  31181. _createTexture(): WebGLTexture;
  31182. /**
  31183. * Usually called from Texture.ts.
  31184. * Passed information to create a WebGLTexture
  31185. * @param urlArg defines a value which contains one of the following:
  31186. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31187. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31188. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31189. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31190. * @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)
  31191. * @param scene needed for loading to the correct scene
  31192. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31193. * @param onLoad optional callback to be called upon successful completion
  31194. * @param onError optional callback to be called upon failure
  31195. * @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
  31196. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31197. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31198. * @param forcedExtension defines the extension to use to pick the right loader
  31199. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31200. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31201. */
  31202. 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;
  31203. /**
  31204. * @hidden
  31205. * Rescales a texture
  31206. * @param source input texutre
  31207. * @param destination destination texture
  31208. * @param scene scene to use to render the resize
  31209. * @param internalFormat format to use when resizing
  31210. * @param onComplete callback to be called when resize has completed
  31211. */
  31212. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  31213. private _unpackFlipYCached;
  31214. /**
  31215. * In case you are sharing the context with other applications, it might
  31216. * be interested to not cache the unpack flip y state to ensure a consistent
  31217. * value would be set.
  31218. */
  31219. enableUnpackFlipYCached: boolean;
  31220. /** @hidden */
  31221. _unpackFlipY(value: boolean): void;
  31222. /** @hidden */
  31223. _getUnpackAlignement(): number;
  31224. /**
  31225. * Creates a dynamic texture
  31226. * @param width defines the width of the texture
  31227. * @param height defines the height of the texture
  31228. * @param generateMipMaps defines if the engine should generate the mip levels
  31229. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31230. * @returns the dynamic texture inside an InternalTexture
  31231. */
  31232. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  31233. /**
  31234. * Update the sampling mode of a given texture
  31235. * @param samplingMode defines the required sampling mode
  31236. * @param texture defines the texture to update
  31237. */
  31238. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  31239. /**
  31240. * Update the content of a dynamic texture
  31241. * @param texture defines the texture to update
  31242. * @param canvas defines the canvas containing the source
  31243. * @param invertY defines if data must be stored with Y axis inverted
  31244. * @param premulAlpha defines if alpha is stored as premultiplied
  31245. * @param format defines the format of the data
  31246. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  31247. */
  31248. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  31249. /**
  31250. * Update a video texture
  31251. * @param texture defines the texture to update
  31252. * @param video defines the video element to use
  31253. * @param invertY defines if data must be stored with Y axis inverted
  31254. */
  31255. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31256. /**
  31257. * Updates a depth texture Comparison Mode and Function.
  31258. * If the comparison Function is equal to 0, the mode will be set to none.
  31259. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31260. * @param texture The texture to set the comparison function for
  31261. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31262. */
  31263. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  31264. /** @hidden */
  31265. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31266. width: number;
  31267. height: number;
  31268. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31269. /**
  31270. * Creates a depth stencil texture.
  31271. * This is only available in WebGL 2 or with the depth texture extension available.
  31272. * @param size The size of face edge in the texture.
  31273. * @param options The options defining the texture.
  31274. * @returns The texture
  31275. */
  31276. createDepthStencilTexture(size: number | {
  31277. width: number;
  31278. height: number;
  31279. }, options: DepthTextureCreationOptions): InternalTexture;
  31280. /**
  31281. * Creates a depth stencil texture.
  31282. * This is only available in WebGL 2 or with the depth texture extension available.
  31283. * @param size The size of face edge in the texture.
  31284. * @param options The options defining the texture.
  31285. * @returns The texture
  31286. */
  31287. private _createDepthStencilTexture;
  31288. /**
  31289. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31290. * @param renderTarget The render target to set the frame buffer for
  31291. */
  31292. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31293. /**
  31294. * Creates a new render target texture
  31295. * @param size defines the size of the texture
  31296. * @param options defines the options used to create the texture
  31297. * @returns a new render target texture stored in an InternalTexture
  31298. */
  31299. createRenderTargetTexture(size: number | {
  31300. width: number;
  31301. height: number;
  31302. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  31303. /** @hidden */
  31304. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31305. /**
  31306. * Updates the sample count of a render target texture
  31307. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31308. * @param texture defines the texture to update
  31309. * @param samples defines the sample count to set
  31310. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31311. */
  31312. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31313. /** @hidden */
  31314. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31315. /** @hidden */
  31316. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31317. /** @hidden */
  31318. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31319. /** @hidden */
  31320. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  31321. /**
  31322. * @hidden
  31323. */
  31324. _setCubeMapTextureParams(loadMipmap: boolean): void;
  31325. private _prepareWebGLTextureContinuation;
  31326. private _prepareWebGLTexture;
  31327. /** @hidden */
  31328. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31329. /** @hidden */
  31330. _releaseFramebufferObjects(texture: InternalTexture): void;
  31331. /** @hidden */
  31332. _releaseTexture(texture: InternalTexture): void;
  31333. private setProgram;
  31334. private _boundUniforms;
  31335. /**
  31336. * Binds an effect to the webGL context
  31337. * @param effect defines the effect to bind
  31338. */
  31339. bindSamplers(effect: Effect): void;
  31340. private _activateCurrentTexture;
  31341. /** @hidden */
  31342. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31343. /** @hidden */
  31344. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31345. /**
  31346. * Sets a texture to the webGL context from a postprocess
  31347. * @param channel defines the channel to use
  31348. * @param postProcess defines the source postprocess
  31349. */
  31350. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31351. /**
  31352. * Binds the output of the passed in post process to the texture channel specified
  31353. * @param channel The channel the texture should be bound to
  31354. * @param postProcess The post process which's output should be bound
  31355. */
  31356. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31357. /**
  31358. * Unbind all textures from the webGL context
  31359. */
  31360. unbindAllTextures(): void;
  31361. /**
  31362. * Sets a texture to the according uniform.
  31363. * @param channel The texture channel
  31364. * @param uniform The uniform to set
  31365. * @param texture The texture to apply
  31366. */
  31367. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31368. /**
  31369. * Sets a depth stencil texture from a render target to the according uniform.
  31370. * @param channel The texture channel
  31371. * @param uniform The uniform to set
  31372. * @param texture The render target texture containing the depth stencil texture to apply
  31373. */
  31374. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31375. private _bindSamplerUniformToChannel;
  31376. private _getTextureWrapMode;
  31377. private _setTexture;
  31378. /**
  31379. * Sets an array of texture to the webGL context
  31380. * @param channel defines the channel where the texture array must be set
  31381. * @param uniform defines the associated uniform location
  31382. * @param textures defines the array of textures to bind
  31383. */
  31384. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31385. /** @hidden */
  31386. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31387. private _setTextureParameterFloat;
  31388. private _setTextureParameterInteger;
  31389. /**
  31390. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31391. * @param x defines the x coordinate of the rectangle where pixels must be read
  31392. * @param y defines the y coordinate of the rectangle where pixels must be read
  31393. * @param width defines the width of the rectangle where pixels must be read
  31394. * @param height defines the height of the rectangle where pixels must be read
  31395. * @returns a Uint8Array containing RGBA colors
  31396. */
  31397. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31398. /**
  31399. * Add an externaly attached data from its key.
  31400. * This method call will fail and return false, if such key already exists.
  31401. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  31402. * @param key the unique key that identifies the data
  31403. * @param data the data object to associate to the key for this Engine instance
  31404. * @return true if no such key were already present and the data was added successfully, false otherwise
  31405. */
  31406. addExternalData<T>(key: string, data: T): boolean;
  31407. /**
  31408. * Get an externaly attached data from its key
  31409. * @param key the unique key that identifies the data
  31410. * @return the associated data, if present (can be null), or undefined if not present
  31411. */
  31412. getExternalData<T>(key: string): T;
  31413. /**
  31414. * Get an externaly attached data from its key, create it using a factory if it's not already present
  31415. * @param key the unique key that identifies the data
  31416. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  31417. * @return the associated data, can be null if the factory returned null.
  31418. */
  31419. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  31420. /**
  31421. * Remove an externaly attached data from the Engine instance
  31422. * @param key the unique key that identifies the data
  31423. * @return true if the data was successfully removed, false if it doesn't exist
  31424. */
  31425. removeExternalData(key: string): boolean;
  31426. /**
  31427. * Unbind all vertex attributes from the webGL context
  31428. */
  31429. unbindAllAttributes(): void;
  31430. /**
  31431. * 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
  31432. */
  31433. releaseEffects(): void;
  31434. /**
  31435. * Dispose and release all associated resources
  31436. */
  31437. dispose(): void;
  31438. /**
  31439. * Display the loading screen
  31440. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31441. */
  31442. displayLoadingUI(): void;
  31443. /**
  31444. * Hide the loading screen
  31445. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31446. */
  31447. hideLoadingUI(): void;
  31448. /**
  31449. * Gets the current loading screen object
  31450. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31451. */
  31452. /**
  31453. * Sets the current loading screen object
  31454. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31455. */
  31456. loadingScreen: ILoadingScreen;
  31457. /**
  31458. * Sets the current loading screen text
  31459. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31460. */
  31461. loadingUIText: string;
  31462. /**
  31463. * Sets the current loading screen background color
  31464. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31465. */
  31466. loadingUIBackgroundColor: string;
  31467. /**
  31468. * Attach a new callback raised when context lost event is fired
  31469. * @param callback defines the callback to call
  31470. */
  31471. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31472. /**
  31473. * Attach a new callback raised when context restored event is fired
  31474. * @param callback defines the callback to call
  31475. */
  31476. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31477. /**
  31478. * Gets the source code of the vertex shader associated with a specific webGL program
  31479. * @param program defines the program to use
  31480. * @returns a string containing the source code of the vertex shader associated with the program
  31481. */
  31482. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31483. /**
  31484. * Gets the source code of the fragment shader associated with a specific webGL program
  31485. * @param program defines the program to use
  31486. * @returns a string containing the source code of the fragment shader associated with the program
  31487. */
  31488. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31489. /**
  31490. * Get the current error code of the webGL context
  31491. * @returns the error code
  31492. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31493. */
  31494. getError(): number;
  31495. /**
  31496. * Gets the current framerate
  31497. * @returns a number representing the framerate
  31498. */
  31499. getFps(): number;
  31500. /**
  31501. * Gets the time spent between current and previous frame
  31502. * @returns a number representing the delta time in ms
  31503. */
  31504. getDeltaTime(): number;
  31505. private _measureFps;
  31506. /** @hidden */
  31507. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31508. private _canRenderToFloatFramebuffer;
  31509. private _canRenderToHalfFloatFramebuffer;
  31510. private _canRenderToFramebuffer;
  31511. /** @hidden */
  31512. _getWebGLTextureType(type: number): number;
  31513. /** @hidden */
  31514. _getInternalFormat(format: number): number;
  31515. /** @hidden */
  31516. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31517. /** @hidden */
  31518. _getRGBAMultiSampleBufferFormat(type: number): number;
  31519. /** @hidden */
  31520. _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;
  31521. /** @hidden */
  31522. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31523. /**
  31524. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31525. * @returns true if the engine can be created
  31526. * @ignorenaming
  31527. */
  31528. static isSupported(): boolean;
  31529. /**
  31530. * Find the next highest power of two.
  31531. * @param x Number to start search from.
  31532. * @return Next highest power of two.
  31533. */
  31534. static CeilingPOT(x: number): number;
  31535. /**
  31536. * Find the next lowest power of two.
  31537. * @param x Number to start search from.
  31538. * @return Next lowest power of two.
  31539. */
  31540. static FloorPOT(x: number): number;
  31541. /**
  31542. * Find the nearest power of two.
  31543. * @param x Number to start search from.
  31544. * @return Next nearest power of two.
  31545. */
  31546. static NearestPOT(x: number): number;
  31547. /**
  31548. * Get the closest exponent of two
  31549. * @param value defines the value to approximate
  31550. * @param max defines the maximum value to return
  31551. * @param mode defines how to define the closest value
  31552. * @returns closest exponent of two of the given value
  31553. */
  31554. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31555. /**
  31556. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31557. * @param func - the function to be called
  31558. * @param requester - the object that will request the next frame. Falls back to window.
  31559. * @returns frame number
  31560. */
  31561. static QueueNewFrame(func: () => void, requester?: any): number;
  31562. /**
  31563. * Ask the browser to promote the current element to pointerlock mode
  31564. * @param element defines the DOM element to promote
  31565. */
  31566. static _RequestPointerlock(element: HTMLElement): void;
  31567. /**
  31568. * Asks the browser to exit pointerlock mode
  31569. */
  31570. static _ExitPointerlock(): void;
  31571. /**
  31572. * Ask the browser to promote the current element to fullscreen rendering mode
  31573. * @param element defines the DOM element to promote
  31574. */
  31575. static _RequestFullscreen(element: HTMLElement): void;
  31576. /**
  31577. * Asks the browser to exit fullscreen mode
  31578. */
  31579. static _ExitFullscreen(): void;
  31580. }
  31581. }
  31582. declare module BABYLON {
  31583. /**
  31584. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31585. * during the life time of the application.
  31586. */
  31587. export class EngineStore {
  31588. /** Gets the list of created engines */
  31589. static Instances: Engine[];
  31590. /** @hidden */
  31591. static _LastCreatedScene: Nullable<Scene>;
  31592. /**
  31593. * Gets the latest created engine
  31594. */
  31595. static readonly LastCreatedEngine: Nullable<Engine>;
  31596. /**
  31597. * Gets the latest created scene
  31598. */
  31599. static readonly LastCreatedScene: Nullable<Scene>;
  31600. /**
  31601. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31602. * @ignorenaming
  31603. */
  31604. static UseFallbackTexture: boolean;
  31605. /**
  31606. * Texture content used if a texture cannot loaded
  31607. * @ignorenaming
  31608. */
  31609. static FallbackTexture: string;
  31610. }
  31611. }
  31612. declare module BABYLON {
  31613. /**
  31614. * Helper class that provides a small promise polyfill
  31615. */
  31616. export class PromisePolyfill {
  31617. /**
  31618. * Static function used to check if the polyfill is required
  31619. * If this is the case then the function will inject the polyfill to window.Promise
  31620. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31621. */
  31622. static Apply(force?: boolean): void;
  31623. }
  31624. }
  31625. declare module BABYLON {
  31626. /**
  31627. * Interface for screenshot methods with describe argument called `size` as object with options
  31628. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31629. */
  31630. export interface IScreenshotSize {
  31631. /**
  31632. * number in pixels for canvas height
  31633. */
  31634. height?: number;
  31635. /**
  31636. * multiplier allowing render at a higher or lower resolution
  31637. * If value is defined then height and width will be ignored and taken from camera
  31638. */
  31639. precision?: number;
  31640. /**
  31641. * number in pixels for canvas width
  31642. */
  31643. width?: number;
  31644. }
  31645. }
  31646. declare module BABYLON {
  31647. interface IColor4Like {
  31648. r: float;
  31649. g: float;
  31650. b: float;
  31651. a: float;
  31652. }
  31653. /**
  31654. * Class containing a set of static utilities functions
  31655. */
  31656. export class Tools {
  31657. /**
  31658. * Gets or sets the base URL to use to load assets
  31659. */
  31660. static BaseUrl: string;
  31661. /**
  31662. * Enable/Disable Custom HTTP Request Headers globally.
  31663. * default = false
  31664. * @see CustomRequestHeaders
  31665. */
  31666. static UseCustomRequestHeaders: boolean;
  31667. /**
  31668. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31669. * i.e. when loading files, where the server/service expects an Authorization header
  31670. */
  31671. static CustomRequestHeaders: {
  31672. [key: string]: string;
  31673. };
  31674. /**
  31675. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31676. */
  31677. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31678. /**
  31679. * Default behaviour for cors in the application.
  31680. * It can be a string if the expected behavior is identical in the entire app.
  31681. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31682. */
  31683. static CorsBehavior: string | ((url: string | string[]) => string);
  31684. /**
  31685. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31686. * @ignorenaming
  31687. */
  31688. static UseFallbackTexture: boolean;
  31689. /**
  31690. * Use this object to register external classes like custom textures or material
  31691. * to allow the laoders to instantiate them
  31692. */
  31693. static RegisteredExternalClasses: {
  31694. [key: string]: Object;
  31695. };
  31696. /**
  31697. * Texture content used if a texture cannot loaded
  31698. * @ignorenaming
  31699. */
  31700. static fallbackTexture: string;
  31701. /**
  31702. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31703. * @param u defines the coordinate on X axis
  31704. * @param v defines the coordinate on Y axis
  31705. * @param width defines the width of the source data
  31706. * @param height defines the height of the source data
  31707. * @param pixels defines the source byte array
  31708. * @param color defines the output color
  31709. */
  31710. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31711. /**
  31712. * Interpolates between a and b via alpha
  31713. * @param a The lower value (returned when alpha = 0)
  31714. * @param b The upper value (returned when alpha = 1)
  31715. * @param alpha The interpolation-factor
  31716. * @return The mixed value
  31717. */
  31718. static Mix(a: number, b: number, alpha: number): number;
  31719. /**
  31720. * Tries to instantiate a new object from a given class name
  31721. * @param className defines the class name to instantiate
  31722. * @returns the new object or null if the system was not able to do the instantiation
  31723. */
  31724. static Instantiate(className: string): any;
  31725. /**
  31726. * Provides a slice function that will work even on IE
  31727. * @param data defines the array to slice
  31728. * @param start defines the start of the data (optional)
  31729. * @param end defines the end of the data (optional)
  31730. * @returns the new sliced array
  31731. */
  31732. static Slice<T>(data: T, start?: number, end?: number): T;
  31733. /**
  31734. * Polyfill for setImmediate
  31735. * @param action defines the action to execute after the current execution block
  31736. */
  31737. static SetImmediate(action: () => void): void;
  31738. /**
  31739. * Function indicating if a number is an exponent of 2
  31740. * @param value defines the value to test
  31741. * @returns true if the value is an exponent of 2
  31742. */
  31743. static IsExponentOfTwo(value: number): boolean;
  31744. private static _tmpFloatArray;
  31745. /**
  31746. * Returns the nearest 32-bit single precision float representation of a Number
  31747. * @param value A Number. If the parameter is of a different type, it will get converted
  31748. * to a number or to NaN if it cannot be converted
  31749. * @returns number
  31750. */
  31751. static FloatRound(value: number): number;
  31752. /**
  31753. * Extracts the filename from a path
  31754. * @param path defines the path to use
  31755. * @returns the filename
  31756. */
  31757. static GetFilename(path: string): string;
  31758. /**
  31759. * Extracts the "folder" part of a path (everything before the filename).
  31760. * @param uri The URI to extract the info from
  31761. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31762. * @returns The "folder" part of the path
  31763. */
  31764. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31765. /**
  31766. * Extracts text content from a DOM element hierarchy
  31767. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31768. */
  31769. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31770. /**
  31771. * Convert an angle in radians to degrees
  31772. * @param angle defines the angle to convert
  31773. * @returns the angle in degrees
  31774. */
  31775. static ToDegrees(angle: number): number;
  31776. /**
  31777. * Convert an angle in degrees to radians
  31778. * @param angle defines the angle to convert
  31779. * @returns the angle in radians
  31780. */
  31781. static ToRadians(angle: number): number;
  31782. /**
  31783. * Encode a buffer to a base64 string
  31784. * @param buffer defines the buffer to encode
  31785. * @returns the encoded string
  31786. */
  31787. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31788. /**
  31789. * Returns an array if obj is not an array
  31790. * @param obj defines the object to evaluate as an array
  31791. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31792. * @returns either obj directly if obj is an array or a new array containing obj
  31793. */
  31794. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31795. /**
  31796. * Gets the pointer prefix to use
  31797. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31798. */
  31799. static GetPointerPrefix(): string;
  31800. /**
  31801. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31802. * @param url define the url we are trying
  31803. * @param element define the dom element where to configure the cors policy
  31804. */
  31805. static SetCorsBehavior(url: string | string[], element: {
  31806. crossOrigin: string | null;
  31807. }): void;
  31808. /**
  31809. * Removes unwanted characters from an url
  31810. * @param url defines the url to clean
  31811. * @returns the cleaned url
  31812. */
  31813. static CleanUrl(url: string): string;
  31814. /**
  31815. * Gets or sets a function used to pre-process url before using them to load assets
  31816. */
  31817. static PreprocessUrl: (url: string) => string;
  31818. /**
  31819. * Loads an image as an HTMLImageElement.
  31820. * @param input url string, ArrayBuffer, or Blob to load
  31821. * @param onLoad callback called when the image successfully loads
  31822. * @param onError callback called when the image fails to load
  31823. * @param offlineProvider offline provider for caching
  31824. * @returns the HTMLImageElement of the loaded image
  31825. */
  31826. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31827. /**
  31828. * Loads a file
  31829. * @param url url string, ArrayBuffer, or Blob to load
  31830. * @param onSuccess callback called when the file successfully loads
  31831. * @param onProgress callback called while file is loading (if the server supports this mode)
  31832. * @param offlineProvider defines the offline provider for caching
  31833. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31834. * @param onError callback called when the file fails to load
  31835. * @returns a file request object
  31836. */
  31837. 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;
  31838. /**
  31839. * Loads a file from a url
  31840. * @param url the file url to load
  31841. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31842. */
  31843. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31844. /**
  31845. * Load a script (identified by an url). When the url returns, the
  31846. * content of this file is added into a new script element, attached to the DOM (body element)
  31847. * @param scriptUrl defines the url of the script to laod
  31848. * @param onSuccess defines the callback called when the script is loaded
  31849. * @param onError defines the callback to call if an error occurs
  31850. * @param scriptId defines the id of the script element
  31851. */
  31852. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31853. /**
  31854. * Load an asynchronous script (identified by an url). When the url returns, the
  31855. * content of this file is added into a new script element, attached to the DOM (body element)
  31856. * @param scriptUrl defines the url of the script to laod
  31857. * @param scriptId defines the id of the script element
  31858. * @returns a promise request object
  31859. */
  31860. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31861. /**
  31862. * Loads a file from a blob
  31863. * @param fileToLoad defines the blob to use
  31864. * @param callback defines the callback to call when data is loaded
  31865. * @param progressCallback defines the callback to call during loading process
  31866. * @returns a file request object
  31867. */
  31868. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31869. /**
  31870. * Loads a file
  31871. * @param fileToLoad defines the file to load
  31872. * @param callback defines the callback to call when data is loaded
  31873. * @param progressCallBack defines the callback to call during loading process
  31874. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31875. * @returns a file request object
  31876. */
  31877. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31878. /**
  31879. * Creates a data url from a given string content
  31880. * @param content defines the content to convert
  31881. * @returns the new data url link
  31882. */
  31883. static FileAsURL(content: string): string;
  31884. /**
  31885. * Format the given number to a specific decimal format
  31886. * @param value defines the number to format
  31887. * @param decimals defines the number of decimals to use
  31888. * @returns the formatted string
  31889. */
  31890. static Format(value: number, decimals?: number): string;
  31891. /**
  31892. * Tries to copy an object by duplicating every property
  31893. * @param source defines the source object
  31894. * @param destination defines the target object
  31895. * @param doNotCopyList defines a list of properties to avoid
  31896. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31897. */
  31898. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31899. /**
  31900. * Gets a boolean indicating if the given object has no own property
  31901. * @param obj defines the object to test
  31902. * @returns true if object has no own property
  31903. */
  31904. static IsEmpty(obj: any): boolean;
  31905. /**
  31906. * Function used to register events at window level
  31907. * @param windowElement defines the Window object to use
  31908. * @param events defines the events to register
  31909. */
  31910. static RegisterTopRootEvents(windowElement: Window, events: {
  31911. name: string;
  31912. handler: Nullable<(e: FocusEvent) => any>;
  31913. }[]): void;
  31914. /**
  31915. * Function used to unregister events from window level
  31916. * @param windowElement defines the Window object to use
  31917. * @param events defines the events to unregister
  31918. */
  31919. static UnregisterTopRootEvents(windowElement: Window, events: {
  31920. name: string;
  31921. handler: Nullable<(e: FocusEvent) => any>;
  31922. }[]): void;
  31923. /**
  31924. * @ignore
  31925. */
  31926. static _ScreenshotCanvas: HTMLCanvasElement;
  31927. /**
  31928. * Dumps the current bound framebuffer
  31929. * @param width defines the rendering width
  31930. * @param height defines the rendering height
  31931. * @param engine defines the hosting engine
  31932. * @param successCallback defines the callback triggered once the data are available
  31933. * @param mimeType defines the mime type of the result
  31934. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31935. */
  31936. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31937. /**
  31938. * Converts the canvas data to blob.
  31939. * This acts as a polyfill for browsers not supporting the to blob function.
  31940. * @param canvas Defines the canvas to extract the data from
  31941. * @param successCallback Defines the callback triggered once the data are available
  31942. * @param mimeType Defines the mime type of the result
  31943. */
  31944. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31945. /**
  31946. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31947. * @param successCallback defines the callback triggered once the data are available
  31948. * @param mimeType defines the mime type of the result
  31949. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31950. */
  31951. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31952. /**
  31953. * Downloads a blob in the browser
  31954. * @param blob defines the blob to download
  31955. * @param fileName defines the name of the downloaded file
  31956. */
  31957. static Download(blob: Blob, fileName: string): void;
  31958. /**
  31959. * Captures a screenshot of the current rendering
  31960. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31961. * @param engine defines the rendering engine
  31962. * @param camera defines the source camera
  31963. * @param size This parameter can be set to a single number or to an object with the
  31964. * following (optional) properties: precision, width, height. If a single number is passed,
  31965. * it will be used for both width and height. If an object is passed, the screenshot size
  31966. * will be derived from the parameters. The precision property is a multiplier allowing
  31967. * rendering at a higher or lower resolution
  31968. * @param successCallback defines the callback receives a single parameter which contains the
  31969. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31970. * src parameter of an <img> to display it
  31971. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31972. * Check your browser for supported MIME types
  31973. */
  31974. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  31975. /**
  31976. * Captures a screenshot of the current rendering
  31977. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31978. * @param engine defines the rendering engine
  31979. * @param camera defines the source camera
  31980. * @param size This parameter can be set to a single number or to an object with the
  31981. * following (optional) properties: precision, width, height. If a single number is passed,
  31982. * it will be used for both width and height. If an object is passed, the screenshot size
  31983. * will be derived from the parameters. The precision property is a multiplier allowing
  31984. * rendering at a higher or lower resolution
  31985. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31986. * Check your browser for supported MIME types
  31987. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31988. * to the src parameter of an <img> to display it
  31989. */
  31990. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  31991. /**
  31992. * Generates an image screenshot from the specified camera.
  31993. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31994. * @param engine The engine to use for rendering
  31995. * @param camera The camera to use for rendering
  31996. * @param size This parameter can be set to a single number or to an object with the
  31997. * following (optional) properties: precision, width, height. If a single number is passed,
  31998. * it will be used for both width and height. If an object is passed, the screenshot size
  31999. * will be derived from the parameters. The precision property is a multiplier allowing
  32000. * rendering at a higher or lower resolution
  32001. * @param successCallback The callback receives a single parameter which contains the
  32002. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32003. * src parameter of an <img> to display it
  32004. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32005. * Check your browser for supported MIME types
  32006. * @param samples Texture samples (default: 1)
  32007. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32008. * @param fileName A name for for the downloaded file.
  32009. */
  32010. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32011. /**
  32012. * Generates an image screenshot from the specified camera.
  32013. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32014. * @param engine The engine to use for rendering
  32015. * @param camera The camera to use for rendering
  32016. * @param size This parameter can be set to a single number or to an object with the
  32017. * following (optional) properties: precision, width, height. If a single number is passed,
  32018. * it will be used for both width and height. If an object is passed, the screenshot size
  32019. * will be derived from the parameters. The precision property is a multiplier allowing
  32020. * rendering at a higher or lower resolution
  32021. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32022. * Check your browser for supported MIME types
  32023. * @param samples Texture samples (default: 1)
  32024. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32025. * @param fileName A name for for the downloaded file.
  32026. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32027. * to the src parameter of an <img> to display it
  32028. */
  32029. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32030. /**
  32031. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32032. * Be aware Math.random() could cause collisions, but:
  32033. * "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"
  32034. * @returns a pseudo random id
  32035. */
  32036. static RandomId(): string;
  32037. /**
  32038. * Test if the given uri is a base64 string
  32039. * @param uri The uri to test
  32040. * @return True if the uri is a base64 string or false otherwise
  32041. */
  32042. static IsBase64(uri: string): boolean;
  32043. /**
  32044. * Decode the given base64 uri.
  32045. * @param uri The uri to decode
  32046. * @return The decoded base64 data.
  32047. */
  32048. static DecodeBase64(uri: string): ArrayBuffer;
  32049. /**
  32050. * Gets the absolute url.
  32051. * @param url the input url
  32052. * @return the absolute url
  32053. */
  32054. static GetAbsoluteUrl(url: string): string;
  32055. /**
  32056. * No log
  32057. */
  32058. static readonly NoneLogLevel: number;
  32059. /**
  32060. * Only message logs
  32061. */
  32062. static readonly MessageLogLevel: number;
  32063. /**
  32064. * Only warning logs
  32065. */
  32066. static readonly WarningLogLevel: number;
  32067. /**
  32068. * Only error logs
  32069. */
  32070. static readonly ErrorLogLevel: number;
  32071. /**
  32072. * All logs
  32073. */
  32074. static readonly AllLogLevel: number;
  32075. /**
  32076. * Gets a value indicating the number of loading errors
  32077. * @ignorenaming
  32078. */
  32079. static readonly errorsCount: number;
  32080. /**
  32081. * Callback called when a new log is added
  32082. */
  32083. static OnNewCacheEntry: (entry: string) => void;
  32084. /**
  32085. * Log a message to the console
  32086. * @param message defines the message to log
  32087. */
  32088. static Log(message: string): void;
  32089. /**
  32090. * Write a warning message to the console
  32091. * @param message defines the message to log
  32092. */
  32093. static Warn(message: string): void;
  32094. /**
  32095. * Write an error message to the console
  32096. * @param message defines the message to log
  32097. */
  32098. static Error(message: string): void;
  32099. /**
  32100. * Gets current log cache (list of logs)
  32101. */
  32102. static readonly LogCache: string;
  32103. /**
  32104. * Clears the log cache
  32105. */
  32106. static ClearLogCache(): void;
  32107. /**
  32108. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32109. */
  32110. static LogLevels: number;
  32111. /**
  32112. * Checks if the window object exists
  32113. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32114. */
  32115. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32116. /**
  32117. * No performance log
  32118. */
  32119. static readonly PerformanceNoneLogLevel: number;
  32120. /**
  32121. * Use user marks to log performance
  32122. */
  32123. static readonly PerformanceUserMarkLogLevel: number;
  32124. /**
  32125. * Log performance to the console
  32126. */
  32127. static readonly PerformanceConsoleLogLevel: number;
  32128. private static _performance;
  32129. /**
  32130. * Sets the current performance log level
  32131. */
  32132. static PerformanceLogLevel: number;
  32133. private static _StartPerformanceCounterDisabled;
  32134. private static _EndPerformanceCounterDisabled;
  32135. private static _StartUserMark;
  32136. private static _EndUserMark;
  32137. private static _StartPerformanceConsole;
  32138. private static _EndPerformanceConsole;
  32139. /**
  32140. * Starts a performance counter
  32141. */
  32142. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32143. /**
  32144. * Ends a specific performance coutner
  32145. */
  32146. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32147. /**
  32148. * Gets either window.performance.now() if supported or Date.now() else
  32149. */
  32150. static readonly Now: number;
  32151. /**
  32152. * This method will return the name of the class used to create the instance of the given object.
  32153. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32154. * @param object the object to get the class name from
  32155. * @param isType defines if the object is actually a type
  32156. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32157. */
  32158. static GetClassName(object: any, isType?: boolean): string;
  32159. /**
  32160. * Gets the first element of an array satisfying a given predicate
  32161. * @param array defines the array to browse
  32162. * @param predicate defines the predicate to use
  32163. * @returns null if not found or the element
  32164. */
  32165. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32166. /**
  32167. * This method will return the name of the full name of the class, including its owning module (if any).
  32168. * 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).
  32169. * @param object the object to get the class name from
  32170. * @param isType defines if the object is actually a type
  32171. * @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.
  32172. * @ignorenaming
  32173. */
  32174. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32175. /**
  32176. * Returns a promise that resolves after the given amount of time.
  32177. * @param delay Number of milliseconds to delay
  32178. * @returns Promise that resolves after the given amount of time
  32179. */
  32180. static DelayAsync(delay: number): Promise<void>;
  32181. }
  32182. /**
  32183. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32184. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32185. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32186. * @param name The name of the class, case should be preserved
  32187. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32188. */
  32189. export function className(name: string, module?: string): (target: Object) => void;
  32190. /**
  32191. * An implementation of a loop for asynchronous functions.
  32192. */
  32193. export class AsyncLoop {
  32194. /**
  32195. * Defines the number of iterations for the loop
  32196. */
  32197. iterations: number;
  32198. /**
  32199. * Defines the current index of the loop.
  32200. */
  32201. index: number;
  32202. private _done;
  32203. private _fn;
  32204. private _successCallback;
  32205. /**
  32206. * Constructor.
  32207. * @param iterations the number of iterations.
  32208. * @param func the function to run each iteration
  32209. * @param successCallback the callback that will be called upon succesful execution
  32210. * @param offset starting offset.
  32211. */
  32212. constructor(
  32213. /**
  32214. * Defines the number of iterations for the loop
  32215. */
  32216. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32217. /**
  32218. * Execute the next iteration. Must be called after the last iteration was finished.
  32219. */
  32220. executeNext(): void;
  32221. /**
  32222. * Break the loop and run the success callback.
  32223. */
  32224. breakLoop(): void;
  32225. /**
  32226. * Create and run an async loop.
  32227. * @param iterations the number of iterations.
  32228. * @param fn the function to run each iteration
  32229. * @param successCallback the callback that will be called upon succesful execution
  32230. * @param offset starting offset.
  32231. * @returns the created async loop object
  32232. */
  32233. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32234. /**
  32235. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32236. * @param iterations total number of iterations
  32237. * @param syncedIterations number of synchronous iterations in each async iteration.
  32238. * @param fn the function to call each iteration.
  32239. * @param callback a success call back that will be called when iterating stops.
  32240. * @param breakFunction a break condition (optional)
  32241. * @param timeout timeout settings for the setTimeout function. default - 0.
  32242. * @returns the created async loop object
  32243. */
  32244. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32245. }
  32246. }
  32247. declare module BABYLON {
  32248. /** @hidden */
  32249. export interface ICollisionCoordinator {
  32250. createCollider(): Collider;
  32251. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32252. init(scene: Scene): void;
  32253. }
  32254. /** @hidden */
  32255. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32256. private _scene;
  32257. private _scaledPosition;
  32258. private _scaledVelocity;
  32259. private _finalPosition;
  32260. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32261. createCollider(): Collider;
  32262. init(scene: Scene): void;
  32263. private _collideWithWorld;
  32264. }
  32265. }
  32266. declare module BABYLON {
  32267. /**
  32268. * Class used to manage all inputs for the scene.
  32269. */
  32270. export class InputManager {
  32271. /** The distance in pixel that you have to move to prevent some events */
  32272. static DragMovementThreshold: number;
  32273. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32274. static LongPressDelay: number;
  32275. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32276. static DoubleClickDelay: number;
  32277. /** If you need to check double click without raising a single click at first click, enable this flag */
  32278. static ExclusiveDoubleClickMode: boolean;
  32279. private _wheelEventName;
  32280. private _onPointerMove;
  32281. private _onPointerDown;
  32282. private _onPointerUp;
  32283. private _initClickEvent;
  32284. private _initActionManager;
  32285. private _delayedSimpleClick;
  32286. private _delayedSimpleClickTimeout;
  32287. private _previousDelayedSimpleClickTimeout;
  32288. private _meshPickProceed;
  32289. private _previousButtonPressed;
  32290. private _currentPickResult;
  32291. private _previousPickResult;
  32292. private _totalPointersPressed;
  32293. private _doubleClickOccured;
  32294. private _pointerOverMesh;
  32295. private _pickedDownMesh;
  32296. private _pickedUpMesh;
  32297. private _pointerX;
  32298. private _pointerY;
  32299. private _unTranslatedPointerX;
  32300. private _unTranslatedPointerY;
  32301. private _startingPointerPosition;
  32302. private _previousStartingPointerPosition;
  32303. private _startingPointerTime;
  32304. private _previousStartingPointerTime;
  32305. private _pointerCaptures;
  32306. private _onKeyDown;
  32307. private _onKeyUp;
  32308. private _onCanvasFocusObserver;
  32309. private _onCanvasBlurObserver;
  32310. private _scene;
  32311. /**
  32312. * Creates a new InputManager
  32313. * @param scene defines the hosting scene
  32314. */
  32315. constructor(scene: Scene);
  32316. /**
  32317. * Gets the mesh that is currently under the pointer
  32318. */
  32319. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32320. /**
  32321. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32322. */
  32323. readonly unTranslatedPointer: Vector2;
  32324. /**
  32325. * Gets or sets the current on-screen X position of the pointer
  32326. */
  32327. pointerX: number;
  32328. /**
  32329. * Gets or sets the current on-screen Y position of the pointer
  32330. */
  32331. pointerY: number;
  32332. private _updatePointerPosition;
  32333. private _processPointerMove;
  32334. private _setRayOnPointerInfo;
  32335. private _checkPrePointerObservable;
  32336. /**
  32337. * Use this method to simulate a pointer move on a mesh
  32338. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32339. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32340. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32341. */
  32342. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32343. /**
  32344. * Use this method to simulate a pointer down on a mesh
  32345. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32346. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32347. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32348. */
  32349. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32350. private _processPointerDown;
  32351. /** @hidden */
  32352. _isPointerSwiping(): boolean;
  32353. /**
  32354. * Use this method to simulate a pointer up on a mesh
  32355. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32356. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32357. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32358. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32359. */
  32360. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32361. private _processPointerUp;
  32362. /**
  32363. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32364. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32365. * @returns true if the pointer was captured
  32366. */
  32367. isPointerCaptured(pointerId?: number): boolean;
  32368. /**
  32369. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32370. * @param attachUp defines if you want to attach events to pointerup
  32371. * @param attachDown defines if you want to attach events to pointerdown
  32372. * @param attachMove defines if you want to attach events to pointermove
  32373. */
  32374. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32375. /**
  32376. * Detaches all event handlers
  32377. */
  32378. detachControl(): void;
  32379. /**
  32380. * Force the value of meshUnderPointer
  32381. * @param mesh defines the mesh to use
  32382. */
  32383. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32384. /**
  32385. * Gets the mesh under the pointer
  32386. * @returns a Mesh or null if no mesh is under the pointer
  32387. */
  32388. getPointerOverMesh(): Nullable<AbstractMesh>;
  32389. }
  32390. }
  32391. declare module BABYLON {
  32392. /**
  32393. * Helper class used to generate session unique ID
  32394. */
  32395. export class UniqueIdGenerator {
  32396. private static _UniqueIdCounter;
  32397. /**
  32398. * Gets an unique (relatively to the current scene) Id
  32399. */
  32400. static readonly UniqueId: number;
  32401. }
  32402. }
  32403. declare module BABYLON {
  32404. /**
  32405. * This class defines the direct association between an animation and a target
  32406. */
  32407. export class TargetedAnimation {
  32408. /**
  32409. * Animation to perform
  32410. */
  32411. animation: Animation;
  32412. /**
  32413. * Target to animate
  32414. */
  32415. target: any;
  32416. /**
  32417. * Serialize the object
  32418. * @returns the JSON object representing the current entity
  32419. */
  32420. serialize(): any;
  32421. }
  32422. /**
  32423. * Use this class to create coordinated animations on multiple targets
  32424. */
  32425. export class AnimationGroup implements IDisposable {
  32426. /** The name of the animation group */
  32427. name: string;
  32428. private _scene;
  32429. private _targetedAnimations;
  32430. private _animatables;
  32431. private _from;
  32432. private _to;
  32433. private _isStarted;
  32434. private _isPaused;
  32435. private _speedRatio;
  32436. private _loopAnimation;
  32437. /**
  32438. * Gets or sets the unique id of the node
  32439. */
  32440. uniqueId: number;
  32441. /**
  32442. * This observable will notify when one animation have ended
  32443. */
  32444. onAnimationEndObservable: Observable<TargetedAnimation>;
  32445. /**
  32446. * Observer raised when one animation loops
  32447. */
  32448. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32449. /**
  32450. * This observable will notify when all animations have ended.
  32451. */
  32452. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32453. /**
  32454. * This observable will notify when all animations have paused.
  32455. */
  32456. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32457. /**
  32458. * This observable will notify when all animations are playing.
  32459. */
  32460. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32461. /**
  32462. * Gets the first frame
  32463. */
  32464. readonly from: number;
  32465. /**
  32466. * Gets the last frame
  32467. */
  32468. readonly to: number;
  32469. /**
  32470. * Define if the animations are started
  32471. */
  32472. readonly isStarted: boolean;
  32473. /**
  32474. * Gets a value indicating that the current group is playing
  32475. */
  32476. readonly isPlaying: boolean;
  32477. /**
  32478. * Gets or sets the speed ratio to use for all animations
  32479. */
  32480. /**
  32481. * Gets or sets the speed ratio to use for all animations
  32482. */
  32483. speedRatio: number;
  32484. /**
  32485. * Gets or sets if all animations should loop or not
  32486. */
  32487. loopAnimation: boolean;
  32488. /**
  32489. * Gets the targeted animations for this animation group
  32490. */
  32491. readonly targetedAnimations: Array<TargetedAnimation>;
  32492. /**
  32493. * returning the list of animatables controlled by this animation group.
  32494. */
  32495. readonly animatables: Array<Animatable>;
  32496. /**
  32497. * Instantiates a new Animation Group.
  32498. * This helps managing several animations at once.
  32499. * @see http://doc.babylonjs.com/how_to/group
  32500. * @param name Defines the name of the group
  32501. * @param scene Defines the scene the group belongs to
  32502. */
  32503. constructor(
  32504. /** The name of the animation group */
  32505. name: string, scene?: Nullable<Scene>);
  32506. /**
  32507. * Add an animation (with its target) in the group
  32508. * @param animation defines the animation we want to add
  32509. * @param target defines the target of the animation
  32510. * @returns the TargetedAnimation object
  32511. */
  32512. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32513. /**
  32514. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32515. * It can add constant keys at begin or end
  32516. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32517. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32518. * @returns the animation group
  32519. */
  32520. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32521. /**
  32522. * Start all animations on given targets
  32523. * @param loop defines if animations must loop
  32524. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32525. * @param from defines the from key (optional)
  32526. * @param to defines the to key (optional)
  32527. * @returns the current animation group
  32528. */
  32529. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32530. /**
  32531. * Pause all animations
  32532. * @returns the animation group
  32533. */
  32534. pause(): AnimationGroup;
  32535. /**
  32536. * Play all animations to initial state
  32537. * This function will start() the animations if they were not started or will restart() them if they were paused
  32538. * @param loop defines if animations must loop
  32539. * @returns the animation group
  32540. */
  32541. play(loop?: boolean): AnimationGroup;
  32542. /**
  32543. * Reset all animations to initial state
  32544. * @returns the animation group
  32545. */
  32546. reset(): AnimationGroup;
  32547. /**
  32548. * Restart animations from key 0
  32549. * @returns the animation group
  32550. */
  32551. restart(): AnimationGroup;
  32552. /**
  32553. * Stop all animations
  32554. * @returns the animation group
  32555. */
  32556. stop(): AnimationGroup;
  32557. /**
  32558. * Set animation weight for all animatables
  32559. * @param weight defines the weight to use
  32560. * @return the animationGroup
  32561. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32562. */
  32563. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32564. /**
  32565. * Synchronize and normalize all animatables with a source animatable
  32566. * @param root defines the root animatable to synchronize with
  32567. * @return the animationGroup
  32568. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32569. */
  32570. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32571. /**
  32572. * Goes to a specific frame in this animation group
  32573. * @param frame the frame number to go to
  32574. * @return the animationGroup
  32575. */
  32576. goToFrame(frame: number): AnimationGroup;
  32577. /**
  32578. * Dispose all associated resources
  32579. */
  32580. dispose(): void;
  32581. private _checkAnimationGroupEnded;
  32582. /**
  32583. * Clone the current animation group and returns a copy
  32584. * @param newName defines the name of the new group
  32585. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32586. * @returns the new aniamtion group
  32587. */
  32588. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32589. /**
  32590. * Serializes the animationGroup to an object
  32591. * @returns Serialized object
  32592. */
  32593. serialize(): any;
  32594. /**
  32595. * Returns a new AnimationGroup object parsed from the source provided.
  32596. * @param parsedAnimationGroup defines the source
  32597. * @param scene defines the scene that will receive the animationGroup
  32598. * @returns a new AnimationGroup
  32599. */
  32600. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32601. /**
  32602. * Returns the string "AnimationGroup"
  32603. * @returns "AnimationGroup"
  32604. */
  32605. getClassName(): string;
  32606. /**
  32607. * Creates a detailled string about the object
  32608. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32609. * @returns a string representing the object
  32610. */
  32611. toString(fullDetails?: boolean): string;
  32612. }
  32613. }
  32614. declare module BABYLON {
  32615. /**
  32616. * Define an interface for all classes that will hold resources
  32617. */
  32618. export interface IDisposable {
  32619. /**
  32620. * Releases all held resources
  32621. */
  32622. dispose(): void;
  32623. }
  32624. /** Interface defining initialization parameters for Scene class */
  32625. export interface SceneOptions {
  32626. /**
  32627. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32628. * It will improve performance when the number of geometries becomes important.
  32629. */
  32630. useGeometryUniqueIdsMap?: boolean;
  32631. /**
  32632. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32633. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32634. */
  32635. useMaterialMeshMap?: boolean;
  32636. /**
  32637. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32638. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32639. */
  32640. useClonedMeshhMap?: boolean;
  32641. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32642. virtual?: boolean;
  32643. }
  32644. /**
  32645. * Represents a scene to be rendered by the engine.
  32646. * @see http://doc.babylonjs.com/features/scene
  32647. */
  32648. export class Scene extends AbstractScene implements IAnimatable {
  32649. /** The fog is deactivated */
  32650. static readonly FOGMODE_NONE: number;
  32651. /** The fog density is following an exponential function */
  32652. static readonly FOGMODE_EXP: number;
  32653. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32654. static readonly FOGMODE_EXP2: number;
  32655. /** The fog density is following a linear function. */
  32656. static readonly FOGMODE_LINEAR: number;
  32657. /**
  32658. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32659. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32660. */
  32661. static MinDeltaTime: number;
  32662. /**
  32663. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32664. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32665. */
  32666. static MaxDeltaTime: number;
  32667. /**
  32668. * Factory used to create the default material.
  32669. * @param name The name of the material to create
  32670. * @param scene The scene to create the material for
  32671. * @returns The default material
  32672. */
  32673. static DefaultMaterialFactory(scene: Scene): Material;
  32674. /**
  32675. * Factory used to create the a collision coordinator.
  32676. * @returns The collision coordinator
  32677. */
  32678. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32679. /** @hidden */
  32680. _inputManager: InputManager;
  32681. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32682. cameraToUseForPointers: Nullable<Camera>;
  32683. /** @hidden */
  32684. readonly _isScene: boolean;
  32685. /**
  32686. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32687. */
  32688. autoClear: boolean;
  32689. /**
  32690. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32691. */
  32692. autoClearDepthAndStencil: boolean;
  32693. /**
  32694. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32695. */
  32696. clearColor: Color4;
  32697. /**
  32698. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32699. */
  32700. ambientColor: Color3;
  32701. /**
  32702. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32703. * It should only be one of the following (if not the default embedded one):
  32704. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32705. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32706. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32707. * The material properties need to be setup according to the type of texture in use.
  32708. */
  32709. environmentBRDFTexture: BaseTexture;
  32710. /** @hidden */
  32711. protected _environmentTexture: Nullable<BaseTexture>;
  32712. /**
  32713. * Texture used in all pbr material as the reflection texture.
  32714. * As in the majority of the scene they are the same (exception for multi room and so on),
  32715. * this is easier to reference from here than from all the materials.
  32716. */
  32717. /**
  32718. * Texture used in all pbr material as the reflection texture.
  32719. * As in the majority of the scene they are the same (exception for multi room and so on),
  32720. * this is easier to set here than in all the materials.
  32721. */
  32722. environmentTexture: Nullable<BaseTexture>;
  32723. /** @hidden */
  32724. protected _environmentIntensity: number;
  32725. /**
  32726. * Intensity of the environment in all pbr material.
  32727. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32728. * As in the majority of the scene they are the same (exception for multi room and so on),
  32729. * this is easier to reference from here than from all the materials.
  32730. */
  32731. /**
  32732. * Intensity of the environment in all pbr material.
  32733. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32734. * As in the majority of the scene they are the same (exception for multi room and so on),
  32735. * this is easier to set here than in all the materials.
  32736. */
  32737. environmentIntensity: number;
  32738. /** @hidden */
  32739. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32740. /**
  32741. * Default image processing configuration used either in the rendering
  32742. * Forward main pass or through the imageProcessingPostProcess if present.
  32743. * As in the majority of the scene they are the same (exception for multi camera),
  32744. * this is easier to reference from here than from all the materials and post process.
  32745. *
  32746. * No setter as we it is a shared configuration, you can set the values instead.
  32747. */
  32748. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32749. private _forceWireframe;
  32750. /**
  32751. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32752. */
  32753. forceWireframe: boolean;
  32754. private _forcePointsCloud;
  32755. /**
  32756. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32757. */
  32758. forcePointsCloud: boolean;
  32759. /**
  32760. * Gets or sets the active clipplane 1
  32761. */
  32762. clipPlane: Nullable<Plane>;
  32763. /**
  32764. * Gets or sets the active clipplane 2
  32765. */
  32766. clipPlane2: Nullable<Plane>;
  32767. /**
  32768. * Gets or sets the active clipplane 3
  32769. */
  32770. clipPlane3: Nullable<Plane>;
  32771. /**
  32772. * Gets or sets the active clipplane 4
  32773. */
  32774. clipPlane4: Nullable<Plane>;
  32775. /**
  32776. * Gets or sets a boolean indicating if animations are enabled
  32777. */
  32778. animationsEnabled: boolean;
  32779. private _animationPropertiesOverride;
  32780. /**
  32781. * Gets or sets the animation properties override
  32782. */
  32783. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32784. /**
  32785. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32786. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32787. */
  32788. useConstantAnimationDeltaTime: boolean;
  32789. /**
  32790. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32791. * Please note that it requires to run a ray cast through the scene on every frame
  32792. */
  32793. constantlyUpdateMeshUnderPointer: boolean;
  32794. /**
  32795. * Defines the HTML cursor to use when hovering over interactive elements
  32796. */
  32797. hoverCursor: string;
  32798. /**
  32799. * Defines the HTML default cursor to use (empty by default)
  32800. */
  32801. defaultCursor: string;
  32802. /**
  32803. * This is used to call preventDefault() on pointer down
  32804. * in order to block unwanted artifacts like system double clicks
  32805. */
  32806. preventDefaultOnPointerDown: boolean;
  32807. /**
  32808. * This is used to call preventDefault() on pointer up
  32809. * in order to block unwanted artifacts like system double clicks
  32810. */
  32811. preventDefaultOnPointerUp: boolean;
  32812. /**
  32813. * Gets or sets user defined metadata
  32814. */
  32815. metadata: any;
  32816. /**
  32817. * For internal use only. Please do not use.
  32818. */
  32819. reservedDataStore: any;
  32820. /**
  32821. * Gets the name of the plugin used to load this scene (null by default)
  32822. */
  32823. loadingPluginName: string;
  32824. /**
  32825. * Use this array to add regular expressions used to disable offline support for specific urls
  32826. */
  32827. disableOfflineSupportExceptionRules: RegExp[];
  32828. /**
  32829. * An event triggered when the scene is disposed.
  32830. */
  32831. onDisposeObservable: Observable<Scene>;
  32832. private _onDisposeObserver;
  32833. /** Sets a function to be executed when this scene is disposed. */
  32834. onDispose: () => void;
  32835. /**
  32836. * An event triggered before rendering the scene (right after animations and physics)
  32837. */
  32838. onBeforeRenderObservable: Observable<Scene>;
  32839. private _onBeforeRenderObserver;
  32840. /** Sets a function to be executed before rendering this scene */
  32841. beforeRender: Nullable<() => void>;
  32842. /**
  32843. * An event triggered after rendering the scene
  32844. */
  32845. onAfterRenderObservable: Observable<Scene>;
  32846. /**
  32847. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32848. */
  32849. onAfterRenderCameraObservable: Observable<Camera>;
  32850. private _onAfterRenderObserver;
  32851. /** Sets a function to be executed after rendering this scene */
  32852. afterRender: Nullable<() => void>;
  32853. /**
  32854. * An event triggered before animating the scene
  32855. */
  32856. onBeforeAnimationsObservable: Observable<Scene>;
  32857. /**
  32858. * An event triggered after animations processing
  32859. */
  32860. onAfterAnimationsObservable: Observable<Scene>;
  32861. /**
  32862. * An event triggered before draw calls are ready to be sent
  32863. */
  32864. onBeforeDrawPhaseObservable: Observable<Scene>;
  32865. /**
  32866. * An event triggered after draw calls have been sent
  32867. */
  32868. onAfterDrawPhaseObservable: Observable<Scene>;
  32869. /**
  32870. * An event triggered when the scene is ready
  32871. */
  32872. onReadyObservable: Observable<Scene>;
  32873. /**
  32874. * An event triggered before rendering a camera
  32875. */
  32876. onBeforeCameraRenderObservable: Observable<Camera>;
  32877. private _onBeforeCameraRenderObserver;
  32878. /** Sets a function to be executed before rendering a camera*/
  32879. beforeCameraRender: () => void;
  32880. /**
  32881. * An event triggered after rendering a camera
  32882. */
  32883. onAfterCameraRenderObservable: Observable<Camera>;
  32884. private _onAfterCameraRenderObserver;
  32885. /** Sets a function to be executed after rendering a camera*/
  32886. afterCameraRender: () => void;
  32887. /**
  32888. * An event triggered when active meshes evaluation is about to start
  32889. */
  32890. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32891. /**
  32892. * An event triggered when active meshes evaluation is done
  32893. */
  32894. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32895. /**
  32896. * An event triggered when particles rendering is about to start
  32897. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32898. */
  32899. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32900. /**
  32901. * An event triggered when particles rendering is done
  32902. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32903. */
  32904. onAfterParticlesRenderingObservable: Observable<Scene>;
  32905. /**
  32906. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32907. */
  32908. onDataLoadedObservable: Observable<Scene>;
  32909. /**
  32910. * An event triggered when a camera is created
  32911. */
  32912. onNewCameraAddedObservable: Observable<Camera>;
  32913. /**
  32914. * An event triggered when a camera is removed
  32915. */
  32916. onCameraRemovedObservable: Observable<Camera>;
  32917. /**
  32918. * An event triggered when a light is created
  32919. */
  32920. onNewLightAddedObservable: Observable<Light>;
  32921. /**
  32922. * An event triggered when a light is removed
  32923. */
  32924. onLightRemovedObservable: Observable<Light>;
  32925. /**
  32926. * An event triggered when a geometry is created
  32927. */
  32928. onNewGeometryAddedObservable: Observable<Geometry>;
  32929. /**
  32930. * An event triggered when a geometry is removed
  32931. */
  32932. onGeometryRemovedObservable: Observable<Geometry>;
  32933. /**
  32934. * An event triggered when a transform node is created
  32935. */
  32936. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32937. /**
  32938. * An event triggered when a transform node is removed
  32939. */
  32940. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32941. /**
  32942. * An event triggered when a mesh is created
  32943. */
  32944. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32945. /**
  32946. * An event triggered when a mesh is removed
  32947. */
  32948. onMeshRemovedObservable: Observable<AbstractMesh>;
  32949. /**
  32950. * An event triggered when a skeleton is created
  32951. */
  32952. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32953. /**
  32954. * An event triggered when a skeleton is removed
  32955. */
  32956. onSkeletonRemovedObservable: Observable<Skeleton>;
  32957. /**
  32958. * An event triggered when a material is created
  32959. */
  32960. onNewMaterialAddedObservable: Observable<Material>;
  32961. /**
  32962. * An event triggered when a material is removed
  32963. */
  32964. onMaterialRemovedObservable: Observable<Material>;
  32965. /**
  32966. * An event triggered when a texture is created
  32967. */
  32968. onNewTextureAddedObservable: Observable<BaseTexture>;
  32969. /**
  32970. * An event triggered when a texture is removed
  32971. */
  32972. onTextureRemovedObservable: Observable<BaseTexture>;
  32973. /**
  32974. * An event triggered when render targets are about to be rendered
  32975. * Can happen multiple times per frame.
  32976. */
  32977. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32978. /**
  32979. * An event triggered when render targets were rendered.
  32980. * Can happen multiple times per frame.
  32981. */
  32982. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32983. /**
  32984. * An event triggered before calculating deterministic simulation step
  32985. */
  32986. onBeforeStepObservable: Observable<Scene>;
  32987. /**
  32988. * An event triggered after calculating deterministic simulation step
  32989. */
  32990. onAfterStepObservable: Observable<Scene>;
  32991. /**
  32992. * An event triggered when the activeCamera property is updated
  32993. */
  32994. onActiveCameraChanged: Observable<Scene>;
  32995. /**
  32996. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32997. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32998. * 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)
  32999. */
  33000. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33001. /**
  33002. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33003. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33004. * 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)
  33005. */
  33006. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33007. /**
  33008. * This Observable will when a mesh has been imported into the scene.
  33009. */
  33010. onMeshImportedObservable: Observable<AbstractMesh>;
  33011. /**
  33012. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33013. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33014. */
  33015. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33016. /** @hidden */
  33017. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33018. /**
  33019. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33020. */
  33021. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33022. /**
  33023. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33024. */
  33025. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33026. /**
  33027. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33028. */
  33029. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33030. /** Callback called when a pointer move is detected */
  33031. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33032. /** Callback called when a pointer down is detected */
  33033. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33034. /** Callback called when a pointer up is detected */
  33035. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33036. /** Callback called when a pointer pick is detected */
  33037. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33038. /**
  33039. * 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).
  33040. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33041. */
  33042. onPrePointerObservable: Observable<PointerInfoPre>;
  33043. /**
  33044. * Observable event triggered each time an input event is received from the rendering canvas
  33045. */
  33046. onPointerObservable: Observable<PointerInfo>;
  33047. /**
  33048. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33049. */
  33050. readonly unTranslatedPointer: Vector2;
  33051. /**
  33052. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33053. */
  33054. static DragMovementThreshold: number;
  33055. /**
  33056. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33057. */
  33058. static LongPressDelay: number;
  33059. /**
  33060. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33061. */
  33062. static DoubleClickDelay: number;
  33063. /** If you need to check double click without raising a single click at first click, enable this flag */
  33064. static ExclusiveDoubleClickMode: boolean;
  33065. /** @hidden */
  33066. _mirroredCameraPosition: Nullable<Vector3>;
  33067. /**
  33068. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33069. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33070. */
  33071. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33072. /**
  33073. * Observable event triggered each time an keyboard event is received from the hosting window
  33074. */
  33075. onKeyboardObservable: Observable<KeyboardInfo>;
  33076. private _useRightHandedSystem;
  33077. /**
  33078. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33079. */
  33080. useRightHandedSystem: boolean;
  33081. private _timeAccumulator;
  33082. private _currentStepId;
  33083. private _currentInternalStep;
  33084. /**
  33085. * Sets the step Id used by deterministic lock step
  33086. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33087. * @param newStepId defines the step Id
  33088. */
  33089. setStepId(newStepId: number): void;
  33090. /**
  33091. * Gets the step Id used by deterministic lock step
  33092. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33093. * @returns the step Id
  33094. */
  33095. getStepId(): number;
  33096. /**
  33097. * Gets the internal step used by deterministic lock step
  33098. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33099. * @returns the internal step
  33100. */
  33101. getInternalStep(): number;
  33102. private _fogEnabled;
  33103. /**
  33104. * Gets or sets a boolean indicating if fog is enabled on this scene
  33105. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33106. * (Default is true)
  33107. */
  33108. fogEnabled: boolean;
  33109. private _fogMode;
  33110. /**
  33111. * Gets or sets the fog mode to use
  33112. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33113. * | mode | value |
  33114. * | --- | --- |
  33115. * | FOGMODE_NONE | 0 |
  33116. * | FOGMODE_EXP | 1 |
  33117. * | FOGMODE_EXP2 | 2 |
  33118. * | FOGMODE_LINEAR | 3 |
  33119. */
  33120. fogMode: number;
  33121. /**
  33122. * Gets or sets the fog color to use
  33123. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33124. * (Default is Color3(0.2, 0.2, 0.3))
  33125. */
  33126. fogColor: Color3;
  33127. /**
  33128. * Gets or sets the fog density to use
  33129. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33130. * (Default is 0.1)
  33131. */
  33132. fogDensity: number;
  33133. /**
  33134. * Gets or sets the fog start distance to use
  33135. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33136. * (Default is 0)
  33137. */
  33138. fogStart: number;
  33139. /**
  33140. * Gets or sets the fog end distance to use
  33141. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33142. * (Default is 1000)
  33143. */
  33144. fogEnd: number;
  33145. private _shadowsEnabled;
  33146. /**
  33147. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33148. */
  33149. shadowsEnabled: boolean;
  33150. private _lightsEnabled;
  33151. /**
  33152. * Gets or sets a boolean indicating if lights are enabled on this scene
  33153. */
  33154. lightsEnabled: boolean;
  33155. /** All of the active cameras added to this scene. */
  33156. activeCameras: Camera[];
  33157. /** @hidden */
  33158. _activeCamera: Nullable<Camera>;
  33159. /** Gets or sets the current active camera */
  33160. activeCamera: Nullable<Camera>;
  33161. private _defaultMaterial;
  33162. /** The default material used on meshes when no material is affected */
  33163. /** The default material used on meshes when no material is affected */
  33164. defaultMaterial: Material;
  33165. private _texturesEnabled;
  33166. /**
  33167. * Gets or sets a boolean indicating if textures are enabled on this scene
  33168. */
  33169. texturesEnabled: boolean;
  33170. /**
  33171. * Gets or sets a boolean indicating if particles are enabled on this scene
  33172. */
  33173. particlesEnabled: boolean;
  33174. /**
  33175. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33176. */
  33177. spritesEnabled: boolean;
  33178. private _skeletonsEnabled;
  33179. /**
  33180. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33181. */
  33182. skeletonsEnabled: boolean;
  33183. /**
  33184. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33185. */
  33186. lensFlaresEnabled: boolean;
  33187. /**
  33188. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33189. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33190. */
  33191. collisionsEnabled: boolean;
  33192. private _collisionCoordinator;
  33193. /** @hidden */
  33194. readonly collisionCoordinator: ICollisionCoordinator;
  33195. /**
  33196. * Defines the gravity applied to this scene (used only for collisions)
  33197. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33198. */
  33199. gravity: Vector3;
  33200. /**
  33201. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33202. */
  33203. postProcessesEnabled: boolean;
  33204. /**
  33205. * The list of postprocesses added to the scene
  33206. */
  33207. postProcesses: PostProcess[];
  33208. /**
  33209. * Gets the current postprocess manager
  33210. */
  33211. postProcessManager: PostProcessManager;
  33212. /**
  33213. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33214. */
  33215. renderTargetsEnabled: boolean;
  33216. /**
  33217. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33218. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33219. */
  33220. dumpNextRenderTargets: boolean;
  33221. /**
  33222. * The list of user defined render targets added to the scene
  33223. */
  33224. customRenderTargets: RenderTargetTexture[];
  33225. /**
  33226. * Defines if texture loading must be delayed
  33227. * If true, textures will only be loaded when they need to be rendered
  33228. */
  33229. useDelayedTextureLoading: boolean;
  33230. /**
  33231. * Gets the list of meshes imported to the scene through SceneLoader
  33232. */
  33233. importedMeshesFiles: String[];
  33234. /**
  33235. * Gets or sets a boolean indicating if probes are enabled on this scene
  33236. */
  33237. probesEnabled: boolean;
  33238. /**
  33239. * Gets or sets the current offline provider to use to store scene data
  33240. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33241. */
  33242. offlineProvider: IOfflineProvider;
  33243. /**
  33244. * Gets or sets the action manager associated with the scene
  33245. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33246. */
  33247. actionManager: AbstractActionManager;
  33248. private _meshesForIntersections;
  33249. /**
  33250. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33251. */
  33252. proceduralTexturesEnabled: boolean;
  33253. private _engine;
  33254. private _totalVertices;
  33255. /** @hidden */
  33256. _activeIndices: PerfCounter;
  33257. /** @hidden */
  33258. _activeParticles: PerfCounter;
  33259. /** @hidden */
  33260. _activeBones: PerfCounter;
  33261. private _animationRatio;
  33262. /** @hidden */
  33263. _animationTimeLast: number;
  33264. /** @hidden */
  33265. _animationTime: number;
  33266. /**
  33267. * Gets or sets a general scale for animation speed
  33268. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33269. */
  33270. animationTimeScale: number;
  33271. /** @hidden */
  33272. _cachedMaterial: Nullable<Material>;
  33273. /** @hidden */
  33274. _cachedEffect: Nullable<Effect>;
  33275. /** @hidden */
  33276. _cachedVisibility: Nullable<number>;
  33277. private _renderId;
  33278. private _frameId;
  33279. private _executeWhenReadyTimeoutId;
  33280. private _intermediateRendering;
  33281. private _viewUpdateFlag;
  33282. private _projectionUpdateFlag;
  33283. /** @hidden */
  33284. _toBeDisposed: Nullable<IDisposable>[];
  33285. private _activeRequests;
  33286. /** @hidden */
  33287. _pendingData: any[];
  33288. private _isDisposed;
  33289. /**
  33290. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33291. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33292. */
  33293. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33294. private _activeMeshes;
  33295. private _processedMaterials;
  33296. private _renderTargets;
  33297. /** @hidden */
  33298. _activeParticleSystems: SmartArray<IParticleSystem>;
  33299. private _activeSkeletons;
  33300. private _softwareSkinnedMeshes;
  33301. private _renderingManager;
  33302. /** @hidden */
  33303. _activeAnimatables: Animatable[];
  33304. private _transformMatrix;
  33305. private _sceneUbo;
  33306. /** @hidden */
  33307. _viewMatrix: Matrix;
  33308. private _projectionMatrix;
  33309. /** @hidden */
  33310. _forcedViewPosition: Nullable<Vector3>;
  33311. /** @hidden */
  33312. _frustumPlanes: Plane[];
  33313. /**
  33314. * Gets the list of frustum planes (built from the active camera)
  33315. */
  33316. readonly frustumPlanes: Plane[];
  33317. /**
  33318. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33319. * This is useful if there are more lights that the maximum simulteanous authorized
  33320. */
  33321. requireLightSorting: boolean;
  33322. /** @hidden */
  33323. readonly useMaterialMeshMap: boolean;
  33324. /** @hidden */
  33325. readonly useClonedMeshhMap: boolean;
  33326. private _externalData;
  33327. private _uid;
  33328. /**
  33329. * @hidden
  33330. * Backing store of defined scene components.
  33331. */
  33332. _components: ISceneComponent[];
  33333. /**
  33334. * @hidden
  33335. * Backing store of defined scene components.
  33336. */
  33337. _serializableComponents: ISceneSerializableComponent[];
  33338. /**
  33339. * List of components to register on the next registration step.
  33340. */
  33341. private _transientComponents;
  33342. /**
  33343. * Registers the transient components if needed.
  33344. */
  33345. private _registerTransientComponents;
  33346. /**
  33347. * @hidden
  33348. * Add a component to the scene.
  33349. * Note that the ccomponent could be registered on th next frame if this is called after
  33350. * the register component stage.
  33351. * @param component Defines the component to add to the scene
  33352. */
  33353. _addComponent(component: ISceneComponent): void;
  33354. /**
  33355. * @hidden
  33356. * Gets a component from the scene.
  33357. * @param name defines the name of the component to retrieve
  33358. * @returns the component or null if not present
  33359. */
  33360. _getComponent(name: string): Nullable<ISceneComponent>;
  33361. /**
  33362. * @hidden
  33363. * Defines the actions happening before camera updates.
  33364. */
  33365. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33366. /**
  33367. * @hidden
  33368. * Defines the actions happening before clear the canvas.
  33369. */
  33370. _beforeClearStage: Stage<SimpleStageAction>;
  33371. /**
  33372. * @hidden
  33373. * Defines the actions when collecting render targets for the frame.
  33374. */
  33375. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33376. /**
  33377. * @hidden
  33378. * Defines the actions happening for one camera in the frame.
  33379. */
  33380. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33381. /**
  33382. * @hidden
  33383. * Defines the actions happening during the per mesh ready checks.
  33384. */
  33385. _isReadyForMeshStage: Stage<MeshStageAction>;
  33386. /**
  33387. * @hidden
  33388. * Defines the actions happening before evaluate active mesh checks.
  33389. */
  33390. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33391. /**
  33392. * @hidden
  33393. * Defines the actions happening during the evaluate sub mesh checks.
  33394. */
  33395. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33396. /**
  33397. * @hidden
  33398. * Defines the actions happening during the active mesh stage.
  33399. */
  33400. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33401. /**
  33402. * @hidden
  33403. * Defines the actions happening during the per camera render target step.
  33404. */
  33405. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33406. /**
  33407. * @hidden
  33408. * Defines the actions happening just before the active camera is drawing.
  33409. */
  33410. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33411. /**
  33412. * @hidden
  33413. * Defines the actions happening just before a render target is drawing.
  33414. */
  33415. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33416. /**
  33417. * @hidden
  33418. * Defines the actions happening just before a rendering group is drawing.
  33419. */
  33420. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33421. /**
  33422. * @hidden
  33423. * Defines the actions happening just before a mesh is drawing.
  33424. */
  33425. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33426. /**
  33427. * @hidden
  33428. * Defines the actions happening just after a mesh has been drawn.
  33429. */
  33430. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33431. /**
  33432. * @hidden
  33433. * Defines the actions happening just after a rendering group has been drawn.
  33434. */
  33435. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33436. /**
  33437. * @hidden
  33438. * Defines the actions happening just after the active camera has been drawn.
  33439. */
  33440. _afterCameraDrawStage: Stage<CameraStageAction>;
  33441. /**
  33442. * @hidden
  33443. * Defines the actions happening just after a render target has been drawn.
  33444. */
  33445. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33446. /**
  33447. * @hidden
  33448. * Defines the actions happening just after rendering all cameras and computing intersections.
  33449. */
  33450. _afterRenderStage: Stage<SimpleStageAction>;
  33451. /**
  33452. * @hidden
  33453. * Defines the actions happening when a pointer move event happens.
  33454. */
  33455. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33456. /**
  33457. * @hidden
  33458. * Defines the actions happening when a pointer down event happens.
  33459. */
  33460. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33461. /**
  33462. * @hidden
  33463. * Defines the actions happening when a pointer up event happens.
  33464. */
  33465. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33466. /**
  33467. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33468. */
  33469. private geometriesByUniqueId;
  33470. /**
  33471. * Creates a new Scene
  33472. * @param engine defines the engine to use to render this scene
  33473. * @param options defines the scene options
  33474. */
  33475. constructor(engine: Engine, options?: SceneOptions);
  33476. /**
  33477. * Gets a string idenfifying the name of the class
  33478. * @returns "Scene" string
  33479. */
  33480. getClassName(): string;
  33481. private _defaultMeshCandidates;
  33482. /**
  33483. * @hidden
  33484. */
  33485. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33486. private _defaultSubMeshCandidates;
  33487. /**
  33488. * @hidden
  33489. */
  33490. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33491. /**
  33492. * Sets the default candidate providers for the scene.
  33493. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33494. * and getCollidingSubMeshCandidates to their default function
  33495. */
  33496. setDefaultCandidateProviders(): void;
  33497. /**
  33498. * Gets the mesh that is currently under the pointer
  33499. */
  33500. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33501. /**
  33502. * Gets or sets the current on-screen X position of the pointer
  33503. */
  33504. pointerX: number;
  33505. /**
  33506. * Gets or sets the current on-screen Y position of the pointer
  33507. */
  33508. pointerY: number;
  33509. /**
  33510. * Gets the cached material (ie. the latest rendered one)
  33511. * @returns the cached material
  33512. */
  33513. getCachedMaterial(): Nullable<Material>;
  33514. /**
  33515. * Gets the cached effect (ie. the latest rendered one)
  33516. * @returns the cached effect
  33517. */
  33518. getCachedEffect(): Nullable<Effect>;
  33519. /**
  33520. * Gets the cached visibility state (ie. the latest rendered one)
  33521. * @returns the cached visibility state
  33522. */
  33523. getCachedVisibility(): Nullable<number>;
  33524. /**
  33525. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33526. * @param material defines the current material
  33527. * @param effect defines the current effect
  33528. * @param visibility defines the current visibility state
  33529. * @returns true if one parameter is not cached
  33530. */
  33531. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33532. /**
  33533. * Gets the engine associated with the scene
  33534. * @returns an Engine
  33535. */
  33536. getEngine(): Engine;
  33537. /**
  33538. * Gets the total number of vertices rendered per frame
  33539. * @returns the total number of vertices rendered per frame
  33540. */
  33541. getTotalVertices(): number;
  33542. /**
  33543. * Gets the performance counter for total vertices
  33544. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33545. */
  33546. readonly totalVerticesPerfCounter: PerfCounter;
  33547. /**
  33548. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33549. * @returns the total number of active indices rendered per frame
  33550. */
  33551. getActiveIndices(): number;
  33552. /**
  33553. * Gets the performance counter for active indices
  33554. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33555. */
  33556. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33557. /**
  33558. * Gets the total number of active particles rendered per frame
  33559. * @returns the total number of active particles rendered per frame
  33560. */
  33561. getActiveParticles(): number;
  33562. /**
  33563. * Gets the performance counter for active particles
  33564. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33565. */
  33566. readonly activeParticlesPerfCounter: PerfCounter;
  33567. /**
  33568. * Gets the total number of active bones rendered per frame
  33569. * @returns the total number of active bones rendered per frame
  33570. */
  33571. getActiveBones(): number;
  33572. /**
  33573. * Gets the performance counter for active bones
  33574. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33575. */
  33576. readonly activeBonesPerfCounter: PerfCounter;
  33577. /**
  33578. * Gets the array of active meshes
  33579. * @returns an array of AbstractMesh
  33580. */
  33581. getActiveMeshes(): SmartArray<AbstractMesh>;
  33582. /**
  33583. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33584. * @returns a number
  33585. */
  33586. getAnimationRatio(): number;
  33587. /**
  33588. * Gets an unique Id for the current render phase
  33589. * @returns a number
  33590. */
  33591. getRenderId(): number;
  33592. /**
  33593. * Gets an unique Id for the current frame
  33594. * @returns a number
  33595. */
  33596. getFrameId(): number;
  33597. /** Call this function if you want to manually increment the render Id*/
  33598. incrementRenderId(): void;
  33599. private _createUbo;
  33600. /**
  33601. * Use this method to simulate a pointer move on a mesh
  33602. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33603. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33604. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33605. * @returns the current scene
  33606. */
  33607. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33608. /**
  33609. * Use this method to simulate a pointer down on a mesh
  33610. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33611. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33612. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33613. * @returns the current scene
  33614. */
  33615. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33616. /**
  33617. * Use this method to simulate a pointer up on a mesh
  33618. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33619. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33620. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33621. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33622. * @returns the current scene
  33623. */
  33624. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33625. /**
  33626. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33627. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33628. * @returns true if the pointer was captured
  33629. */
  33630. isPointerCaptured(pointerId?: number): boolean;
  33631. /**
  33632. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33633. * @param attachUp defines if you want to attach events to pointerup
  33634. * @param attachDown defines if you want to attach events to pointerdown
  33635. * @param attachMove defines if you want to attach events to pointermove
  33636. */
  33637. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33638. /** Detaches all event handlers*/
  33639. detachControl(): void;
  33640. /**
  33641. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33642. * Delay loaded resources are not taking in account
  33643. * @return true if all required resources are ready
  33644. */
  33645. isReady(): boolean;
  33646. /** Resets all cached information relative to material (including effect and visibility) */
  33647. resetCachedMaterial(): void;
  33648. /**
  33649. * Registers a function to be called before every frame render
  33650. * @param func defines the function to register
  33651. */
  33652. registerBeforeRender(func: () => void): void;
  33653. /**
  33654. * Unregisters a function called before every frame render
  33655. * @param func defines the function to unregister
  33656. */
  33657. unregisterBeforeRender(func: () => void): void;
  33658. /**
  33659. * Registers a function to be called after every frame render
  33660. * @param func defines the function to register
  33661. */
  33662. registerAfterRender(func: () => void): void;
  33663. /**
  33664. * Unregisters a function called after every frame render
  33665. * @param func defines the function to unregister
  33666. */
  33667. unregisterAfterRender(func: () => void): void;
  33668. private _executeOnceBeforeRender;
  33669. /**
  33670. * The provided function will run before render once and will be disposed afterwards.
  33671. * A timeout delay can be provided so that the function will be executed in N ms.
  33672. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33673. * @param func The function to be executed.
  33674. * @param timeout optional delay in ms
  33675. */
  33676. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33677. /** @hidden */
  33678. _addPendingData(data: any): void;
  33679. /** @hidden */
  33680. _removePendingData(data: any): void;
  33681. /**
  33682. * Returns the number of items waiting to be loaded
  33683. * @returns the number of items waiting to be loaded
  33684. */
  33685. getWaitingItemsCount(): number;
  33686. /**
  33687. * Returns a boolean indicating if the scene is still loading data
  33688. */
  33689. readonly isLoading: boolean;
  33690. /**
  33691. * Registers a function to be executed when the scene is ready
  33692. * @param {Function} func - the function to be executed
  33693. */
  33694. executeWhenReady(func: () => void): void;
  33695. /**
  33696. * Returns a promise that resolves when the scene is ready
  33697. * @returns A promise that resolves when the scene is ready
  33698. */
  33699. whenReadyAsync(): Promise<void>;
  33700. /** @hidden */
  33701. _checkIsReady(): void;
  33702. /**
  33703. * Gets all animatable attached to the scene
  33704. */
  33705. readonly animatables: Animatable[];
  33706. /**
  33707. * Resets the last animation time frame.
  33708. * Useful to override when animations start running when loading a scene for the first time.
  33709. */
  33710. resetLastAnimationTimeFrame(): void;
  33711. /**
  33712. * Gets the current view matrix
  33713. * @returns a Matrix
  33714. */
  33715. getViewMatrix(): Matrix;
  33716. /**
  33717. * Gets the current projection matrix
  33718. * @returns a Matrix
  33719. */
  33720. getProjectionMatrix(): Matrix;
  33721. /**
  33722. * Gets the current transform matrix
  33723. * @returns a Matrix made of View * Projection
  33724. */
  33725. getTransformMatrix(): Matrix;
  33726. /**
  33727. * Sets the current transform matrix
  33728. * @param viewL defines the View matrix to use
  33729. * @param projectionL defines the Projection matrix to use
  33730. * @param viewR defines the right View matrix to use (if provided)
  33731. * @param projectionR defines the right Projection matrix to use (if provided)
  33732. */
  33733. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33734. /**
  33735. * Gets the uniform buffer used to store scene data
  33736. * @returns a UniformBuffer
  33737. */
  33738. getSceneUniformBuffer(): UniformBuffer;
  33739. /**
  33740. * Gets an unique (relatively to the current scene) Id
  33741. * @returns an unique number for the scene
  33742. */
  33743. getUniqueId(): number;
  33744. /**
  33745. * Add a mesh to the list of scene's meshes
  33746. * @param newMesh defines the mesh to add
  33747. * @param recursive if all child meshes should also be added to the scene
  33748. */
  33749. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33750. /**
  33751. * Remove a mesh for the list of scene's meshes
  33752. * @param toRemove defines the mesh to remove
  33753. * @param recursive if all child meshes should also be removed from the scene
  33754. * @returns the index where the mesh was in the mesh list
  33755. */
  33756. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33757. /**
  33758. * Add a transform node to the list of scene's transform nodes
  33759. * @param newTransformNode defines the transform node to add
  33760. */
  33761. addTransformNode(newTransformNode: TransformNode): void;
  33762. /**
  33763. * Remove a transform node for the list of scene's transform nodes
  33764. * @param toRemove defines the transform node to remove
  33765. * @returns the index where the transform node was in the transform node list
  33766. */
  33767. removeTransformNode(toRemove: TransformNode): number;
  33768. /**
  33769. * Remove a skeleton for the list of scene's skeletons
  33770. * @param toRemove defines the skeleton to remove
  33771. * @returns the index where the skeleton was in the skeleton list
  33772. */
  33773. removeSkeleton(toRemove: Skeleton): number;
  33774. /**
  33775. * Remove a morph target for the list of scene's morph targets
  33776. * @param toRemove defines the morph target to remove
  33777. * @returns the index where the morph target was in the morph target list
  33778. */
  33779. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33780. /**
  33781. * Remove a light for the list of scene's lights
  33782. * @param toRemove defines the light to remove
  33783. * @returns the index where the light was in the light list
  33784. */
  33785. removeLight(toRemove: Light): number;
  33786. /**
  33787. * Remove a camera for the list of scene's cameras
  33788. * @param toRemove defines the camera to remove
  33789. * @returns the index where the camera was in the camera list
  33790. */
  33791. removeCamera(toRemove: Camera): number;
  33792. /**
  33793. * Remove a particle system for the list of scene's particle systems
  33794. * @param toRemove defines the particle system to remove
  33795. * @returns the index where the particle system was in the particle system list
  33796. */
  33797. removeParticleSystem(toRemove: IParticleSystem): number;
  33798. /**
  33799. * Remove a animation for the list of scene's animations
  33800. * @param toRemove defines the animation to remove
  33801. * @returns the index where the animation was in the animation list
  33802. */
  33803. removeAnimation(toRemove: Animation): number;
  33804. /**
  33805. * Will stop the animation of the given target
  33806. * @param target - the target
  33807. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33808. * @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)
  33809. */
  33810. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33811. /**
  33812. * Removes the given animation group from this scene.
  33813. * @param toRemove The animation group to remove
  33814. * @returns The index of the removed animation group
  33815. */
  33816. removeAnimationGroup(toRemove: AnimationGroup): number;
  33817. /**
  33818. * Removes the given multi-material from this scene.
  33819. * @param toRemove The multi-material to remove
  33820. * @returns The index of the removed multi-material
  33821. */
  33822. removeMultiMaterial(toRemove: MultiMaterial): number;
  33823. /**
  33824. * Removes the given material from this scene.
  33825. * @param toRemove The material to remove
  33826. * @returns The index of the removed material
  33827. */
  33828. removeMaterial(toRemove: Material): number;
  33829. /**
  33830. * Removes the given action manager from this scene.
  33831. * @param toRemove The action manager to remove
  33832. * @returns The index of the removed action manager
  33833. */
  33834. removeActionManager(toRemove: AbstractActionManager): number;
  33835. /**
  33836. * Removes the given texture from this scene.
  33837. * @param toRemove The texture to remove
  33838. * @returns The index of the removed texture
  33839. */
  33840. removeTexture(toRemove: BaseTexture): number;
  33841. /**
  33842. * Adds the given light to this scene
  33843. * @param newLight The light to add
  33844. */
  33845. addLight(newLight: Light): void;
  33846. /**
  33847. * Sorts the list list based on light priorities
  33848. */
  33849. sortLightsByPriority(): void;
  33850. /**
  33851. * Adds the given camera to this scene
  33852. * @param newCamera The camera to add
  33853. */
  33854. addCamera(newCamera: Camera): void;
  33855. /**
  33856. * Adds the given skeleton to this scene
  33857. * @param newSkeleton The skeleton to add
  33858. */
  33859. addSkeleton(newSkeleton: Skeleton): void;
  33860. /**
  33861. * Adds the given particle system to this scene
  33862. * @param newParticleSystem The particle system to add
  33863. */
  33864. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33865. /**
  33866. * Adds the given animation to this scene
  33867. * @param newAnimation The animation to add
  33868. */
  33869. addAnimation(newAnimation: Animation): void;
  33870. /**
  33871. * Adds the given animation group to this scene.
  33872. * @param newAnimationGroup The animation group to add
  33873. */
  33874. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33875. /**
  33876. * Adds the given multi-material to this scene
  33877. * @param newMultiMaterial The multi-material to add
  33878. */
  33879. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33880. /**
  33881. * Adds the given material to this scene
  33882. * @param newMaterial The material to add
  33883. */
  33884. addMaterial(newMaterial: Material): void;
  33885. /**
  33886. * Adds the given morph target to this scene
  33887. * @param newMorphTargetManager The morph target to add
  33888. */
  33889. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33890. /**
  33891. * Adds the given geometry to this scene
  33892. * @param newGeometry The geometry to add
  33893. */
  33894. addGeometry(newGeometry: Geometry): void;
  33895. /**
  33896. * Adds the given action manager to this scene
  33897. * @param newActionManager The action manager to add
  33898. */
  33899. addActionManager(newActionManager: AbstractActionManager): void;
  33900. /**
  33901. * Adds the given texture to this scene.
  33902. * @param newTexture The texture to add
  33903. */
  33904. addTexture(newTexture: BaseTexture): void;
  33905. /**
  33906. * Switch active camera
  33907. * @param newCamera defines the new active camera
  33908. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33909. */
  33910. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33911. /**
  33912. * sets the active camera of the scene using its ID
  33913. * @param id defines the camera's ID
  33914. * @return the new active camera or null if none found.
  33915. */
  33916. setActiveCameraByID(id: string): Nullable<Camera>;
  33917. /**
  33918. * sets the active camera of the scene using its name
  33919. * @param name defines the camera's name
  33920. * @returns the new active camera or null if none found.
  33921. */
  33922. setActiveCameraByName(name: string): Nullable<Camera>;
  33923. /**
  33924. * get an animation group using its name
  33925. * @param name defines the material's name
  33926. * @return the animation group or null if none found.
  33927. */
  33928. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33929. /**
  33930. * Get a material using its unique id
  33931. * @param uniqueId defines the material's unique id
  33932. * @return the material or null if none found.
  33933. */
  33934. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33935. /**
  33936. * get a material using its id
  33937. * @param id defines the material's ID
  33938. * @return the material or null if none found.
  33939. */
  33940. getMaterialByID(id: string): Nullable<Material>;
  33941. /**
  33942. * Gets a the last added material using a given id
  33943. * @param id defines the material's ID
  33944. * @return the last material with the given id or null if none found.
  33945. */
  33946. getLastMaterialByID(id: string): Nullable<Material>;
  33947. /**
  33948. * Gets a material using its name
  33949. * @param name defines the material's name
  33950. * @return the material or null if none found.
  33951. */
  33952. getMaterialByName(name: string): Nullable<Material>;
  33953. /**
  33954. * Get a texture using its unique id
  33955. * @param uniqueId defines the texture's unique id
  33956. * @return the texture or null if none found.
  33957. */
  33958. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  33959. /**
  33960. * Gets a camera using its id
  33961. * @param id defines the id to look for
  33962. * @returns the camera or null if not found
  33963. */
  33964. getCameraByID(id: string): Nullable<Camera>;
  33965. /**
  33966. * Gets a camera using its unique id
  33967. * @param uniqueId defines the unique id to look for
  33968. * @returns the camera or null if not found
  33969. */
  33970. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33971. /**
  33972. * Gets a camera using its name
  33973. * @param name defines the camera's name
  33974. * @return the camera or null if none found.
  33975. */
  33976. getCameraByName(name: string): Nullable<Camera>;
  33977. /**
  33978. * Gets a bone using its id
  33979. * @param id defines the bone's id
  33980. * @return the bone or null if not found
  33981. */
  33982. getBoneByID(id: string): Nullable<Bone>;
  33983. /**
  33984. * Gets a bone using its id
  33985. * @param name defines the bone's name
  33986. * @return the bone or null if not found
  33987. */
  33988. getBoneByName(name: string): Nullable<Bone>;
  33989. /**
  33990. * Gets a light node using its name
  33991. * @param name defines the the light's name
  33992. * @return the light or null if none found.
  33993. */
  33994. getLightByName(name: string): Nullable<Light>;
  33995. /**
  33996. * Gets a light node using its id
  33997. * @param id defines the light's id
  33998. * @return the light or null if none found.
  33999. */
  34000. getLightByID(id: string): Nullable<Light>;
  34001. /**
  34002. * Gets a light node using its scene-generated unique ID
  34003. * @param uniqueId defines the light's unique id
  34004. * @return the light or null if none found.
  34005. */
  34006. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34007. /**
  34008. * Gets a particle system by id
  34009. * @param id defines the particle system id
  34010. * @return the corresponding system or null if none found
  34011. */
  34012. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34013. /**
  34014. * Gets a geometry using its ID
  34015. * @param id defines the geometry's id
  34016. * @return the geometry or null if none found.
  34017. */
  34018. getGeometryByID(id: string): Nullable<Geometry>;
  34019. private _getGeometryByUniqueID;
  34020. /**
  34021. * Add a new geometry to this scene
  34022. * @param geometry defines the geometry to be added to the scene.
  34023. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34024. * @return a boolean defining if the geometry was added or not
  34025. */
  34026. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34027. /**
  34028. * Removes an existing geometry
  34029. * @param geometry defines the geometry to be removed from the scene
  34030. * @return a boolean defining if the geometry was removed or not
  34031. */
  34032. removeGeometry(geometry: Geometry): boolean;
  34033. /**
  34034. * Gets the list of geometries attached to the scene
  34035. * @returns an array of Geometry
  34036. */
  34037. getGeometries(): Geometry[];
  34038. /**
  34039. * Gets the first added mesh found of a given ID
  34040. * @param id defines the id to search for
  34041. * @return the mesh found or null if not found at all
  34042. */
  34043. getMeshByID(id: string): Nullable<AbstractMesh>;
  34044. /**
  34045. * Gets a list of meshes using their id
  34046. * @param id defines the id to search for
  34047. * @returns a list of meshes
  34048. */
  34049. getMeshesByID(id: string): Array<AbstractMesh>;
  34050. /**
  34051. * Gets the first added transform node found of a given ID
  34052. * @param id defines the id to search for
  34053. * @return the found transform node or null if not found at all.
  34054. */
  34055. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34056. /**
  34057. * Gets a transform node with its auto-generated unique id
  34058. * @param uniqueId efines the unique id to search for
  34059. * @return the found transform node or null if not found at all.
  34060. */
  34061. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34062. /**
  34063. * Gets a list of transform nodes using their id
  34064. * @param id defines the id to search for
  34065. * @returns a list of transform nodes
  34066. */
  34067. getTransformNodesByID(id: string): Array<TransformNode>;
  34068. /**
  34069. * Gets a mesh with its auto-generated unique id
  34070. * @param uniqueId defines the unique id to search for
  34071. * @return the found mesh or null if not found at all.
  34072. */
  34073. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34074. /**
  34075. * Gets a the last added mesh using a given id
  34076. * @param id defines the id to search for
  34077. * @return the found mesh or null if not found at all.
  34078. */
  34079. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34080. /**
  34081. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34082. * @param id defines the id to search for
  34083. * @return the found node or null if not found at all
  34084. */
  34085. getLastEntryByID(id: string): Nullable<Node>;
  34086. /**
  34087. * Gets a node (Mesh, Camera, Light) using a given id
  34088. * @param id defines the id to search for
  34089. * @return the found node or null if not found at all
  34090. */
  34091. getNodeByID(id: string): Nullable<Node>;
  34092. /**
  34093. * Gets a node (Mesh, Camera, Light) using a given name
  34094. * @param name defines the name to search for
  34095. * @return the found node or null if not found at all.
  34096. */
  34097. getNodeByName(name: string): Nullable<Node>;
  34098. /**
  34099. * Gets a mesh using a given name
  34100. * @param name defines the name to search for
  34101. * @return the found mesh or null if not found at all.
  34102. */
  34103. getMeshByName(name: string): Nullable<AbstractMesh>;
  34104. /**
  34105. * Gets a transform node using a given name
  34106. * @param name defines the name to search for
  34107. * @return the found transform node or null if not found at all.
  34108. */
  34109. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34110. /**
  34111. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34112. * @param id defines the id to search for
  34113. * @return the found skeleton or null if not found at all.
  34114. */
  34115. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34116. /**
  34117. * Gets a skeleton using a given auto generated unique id
  34118. * @param uniqueId defines the unique id to search for
  34119. * @return the found skeleton or null if not found at all.
  34120. */
  34121. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34122. /**
  34123. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34124. * @param id defines the id to search for
  34125. * @return the found skeleton or null if not found at all.
  34126. */
  34127. getSkeletonById(id: string): Nullable<Skeleton>;
  34128. /**
  34129. * Gets a skeleton using a given name
  34130. * @param name defines the name to search for
  34131. * @return the found skeleton or null if not found at all.
  34132. */
  34133. getSkeletonByName(name: string): Nullable<Skeleton>;
  34134. /**
  34135. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34136. * @param id defines the id to search for
  34137. * @return the found morph target manager or null if not found at all.
  34138. */
  34139. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34140. /**
  34141. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34142. * @param id defines the id to search for
  34143. * @return the found morph target or null if not found at all.
  34144. */
  34145. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34146. /**
  34147. * Gets a boolean indicating if the given mesh is active
  34148. * @param mesh defines the mesh to look for
  34149. * @returns true if the mesh is in the active list
  34150. */
  34151. isActiveMesh(mesh: AbstractMesh): boolean;
  34152. /**
  34153. * Return a unique id as a string which can serve as an identifier for the scene
  34154. */
  34155. readonly uid: string;
  34156. /**
  34157. * Add an externaly attached data from its key.
  34158. * This method call will fail and return false, if such key already exists.
  34159. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34160. * @param key the unique key that identifies the data
  34161. * @param data the data object to associate to the key for this Engine instance
  34162. * @return true if no such key were already present and the data was added successfully, false otherwise
  34163. */
  34164. addExternalData<T>(key: string, data: T): boolean;
  34165. /**
  34166. * Get an externaly attached data from its key
  34167. * @param key the unique key that identifies the data
  34168. * @return the associated data, if present (can be null), or undefined if not present
  34169. */
  34170. getExternalData<T>(key: string): Nullable<T>;
  34171. /**
  34172. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34173. * @param key the unique key that identifies the data
  34174. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34175. * @return the associated data, can be null if the factory returned null.
  34176. */
  34177. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34178. /**
  34179. * Remove an externaly attached data from the Engine instance
  34180. * @param key the unique key that identifies the data
  34181. * @return true if the data was successfully removed, false if it doesn't exist
  34182. */
  34183. removeExternalData(key: string): boolean;
  34184. private _evaluateSubMesh;
  34185. /**
  34186. * Clear the processed materials smart array preventing retention point in material dispose.
  34187. */
  34188. freeProcessedMaterials(): void;
  34189. private _preventFreeActiveMeshesAndRenderingGroups;
  34190. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34191. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34192. * when disposing several meshes in a row or a hierarchy of meshes.
  34193. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34194. */
  34195. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34196. /**
  34197. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34198. */
  34199. freeActiveMeshes(): void;
  34200. /**
  34201. * Clear the info related to rendering groups preventing retention points during dispose.
  34202. */
  34203. freeRenderingGroups(): void;
  34204. /** @hidden */
  34205. _isInIntermediateRendering(): boolean;
  34206. /**
  34207. * Lambda returning the list of potentially active meshes.
  34208. */
  34209. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34210. /**
  34211. * Lambda returning the list of potentially active sub meshes.
  34212. */
  34213. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34214. /**
  34215. * Lambda returning the list of potentially intersecting sub meshes.
  34216. */
  34217. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34218. /**
  34219. * Lambda returning the list of potentially colliding sub meshes.
  34220. */
  34221. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34222. private _activeMeshesFrozen;
  34223. /**
  34224. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34225. * @returns the current scene
  34226. */
  34227. freezeActiveMeshes(): Scene;
  34228. /**
  34229. * Use this function to restart evaluating active meshes on every frame
  34230. * @returns the current scene
  34231. */
  34232. unfreezeActiveMeshes(): Scene;
  34233. private _evaluateActiveMeshes;
  34234. private _activeMesh;
  34235. /**
  34236. * Update the transform matrix to update from the current active camera
  34237. * @param force defines a boolean used to force the update even if cache is up to date
  34238. */
  34239. updateTransformMatrix(force?: boolean): void;
  34240. private _bindFrameBuffer;
  34241. /** @hidden */
  34242. _allowPostProcessClearColor: boolean;
  34243. /** @hidden */
  34244. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34245. private _processSubCameras;
  34246. private _checkIntersections;
  34247. /** @hidden */
  34248. _advancePhysicsEngineStep(step: number): void;
  34249. /**
  34250. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34251. */
  34252. getDeterministicFrameTime: () => number;
  34253. /** @hidden */
  34254. _animate(): void;
  34255. /** Execute all animations (for a frame) */
  34256. animate(): void;
  34257. /**
  34258. * Render the scene
  34259. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34260. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34261. */
  34262. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34263. /**
  34264. * Freeze all materials
  34265. * A frozen material will not be updatable but should be faster to render
  34266. */
  34267. freezeMaterials(): void;
  34268. /**
  34269. * Unfreeze all materials
  34270. * A frozen material will not be updatable but should be faster to render
  34271. */
  34272. unfreezeMaterials(): void;
  34273. /**
  34274. * Releases all held ressources
  34275. */
  34276. dispose(): void;
  34277. /**
  34278. * Gets if the scene is already disposed
  34279. */
  34280. readonly isDisposed: boolean;
  34281. /**
  34282. * Call this function to reduce memory footprint of the scene.
  34283. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34284. */
  34285. clearCachedVertexData(): void;
  34286. /**
  34287. * This function will remove the local cached buffer data from texture.
  34288. * It will save memory but will prevent the texture from being rebuilt
  34289. */
  34290. cleanCachedTextureBuffer(): void;
  34291. /**
  34292. * Get the world extend vectors with an optional filter
  34293. *
  34294. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34295. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34296. */
  34297. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34298. min: Vector3;
  34299. max: Vector3;
  34300. };
  34301. /**
  34302. * Creates a ray that can be used to pick in the scene
  34303. * @param x defines the x coordinate of the origin (on-screen)
  34304. * @param y defines the y coordinate of the origin (on-screen)
  34305. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34306. * @param camera defines the camera to use for the picking
  34307. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34308. * @returns a Ray
  34309. */
  34310. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34311. /**
  34312. * Creates a ray that can be used to pick in the scene
  34313. * @param x defines the x coordinate of the origin (on-screen)
  34314. * @param y defines the y coordinate of the origin (on-screen)
  34315. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34316. * @param result defines the ray where to store the picking ray
  34317. * @param camera defines the camera to use for the picking
  34318. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34319. * @returns the current scene
  34320. */
  34321. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34322. /**
  34323. * Creates a ray that can be used to pick in the scene
  34324. * @param x defines the x coordinate of the origin (on-screen)
  34325. * @param y defines the y coordinate of the origin (on-screen)
  34326. * @param camera defines the camera to use for the picking
  34327. * @returns a Ray
  34328. */
  34329. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34330. /**
  34331. * Creates a ray that can be used to pick in the scene
  34332. * @param x defines the x coordinate of the origin (on-screen)
  34333. * @param y defines the y coordinate of the origin (on-screen)
  34334. * @param result defines the ray where to store the picking ray
  34335. * @param camera defines the camera to use for the picking
  34336. * @returns the current scene
  34337. */
  34338. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34339. /** Launch a ray to try to pick a mesh in the scene
  34340. * @param x position on screen
  34341. * @param y position on screen
  34342. * @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
  34343. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34344. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34345. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34346. * @returns a PickingInfo
  34347. */
  34348. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34349. /** Use the given ray to pick a mesh in the scene
  34350. * @param ray The ray to use to pick meshes
  34351. * @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
  34352. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34353. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34354. * @returns a PickingInfo
  34355. */
  34356. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34357. /**
  34358. * Launch a ray to try to pick a mesh in the scene
  34359. * @param x X position on screen
  34360. * @param y Y position on screen
  34361. * @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
  34362. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34363. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34364. * @returns an array of PickingInfo
  34365. */
  34366. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34367. /**
  34368. * Launch a ray to try to pick a mesh in the scene
  34369. * @param ray Ray to use
  34370. * @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
  34371. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34372. * @returns an array of PickingInfo
  34373. */
  34374. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34375. /**
  34376. * Force the value of meshUnderPointer
  34377. * @param mesh defines the mesh to use
  34378. */
  34379. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34380. /**
  34381. * Gets the mesh under the pointer
  34382. * @returns a Mesh or null if no mesh is under the pointer
  34383. */
  34384. getPointerOverMesh(): Nullable<AbstractMesh>;
  34385. /** @hidden */
  34386. _rebuildGeometries(): void;
  34387. /** @hidden */
  34388. _rebuildTextures(): void;
  34389. private _getByTags;
  34390. /**
  34391. * Get a list of meshes by tags
  34392. * @param tagsQuery defines the tags query to use
  34393. * @param forEach defines a predicate used to filter results
  34394. * @returns an array of Mesh
  34395. */
  34396. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34397. /**
  34398. * Get a list of cameras by tags
  34399. * @param tagsQuery defines the tags query to use
  34400. * @param forEach defines a predicate used to filter results
  34401. * @returns an array of Camera
  34402. */
  34403. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34404. /**
  34405. * Get a list of lights by tags
  34406. * @param tagsQuery defines the tags query to use
  34407. * @param forEach defines a predicate used to filter results
  34408. * @returns an array of Light
  34409. */
  34410. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34411. /**
  34412. * Get a list of materials by tags
  34413. * @param tagsQuery defines the tags query to use
  34414. * @param forEach defines a predicate used to filter results
  34415. * @returns an array of Material
  34416. */
  34417. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34418. /**
  34419. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34420. * This allowed control for front to back rendering or reversly depending of the special needs.
  34421. *
  34422. * @param renderingGroupId The rendering group id corresponding to its index
  34423. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34424. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34425. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34426. */
  34427. 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;
  34428. /**
  34429. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34430. *
  34431. * @param renderingGroupId The rendering group id corresponding to its index
  34432. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34433. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34434. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34435. */
  34436. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34437. /**
  34438. * Gets the current auto clear configuration for one rendering group of the rendering
  34439. * manager.
  34440. * @param index the rendering group index to get the information for
  34441. * @returns The auto clear setup for the requested rendering group
  34442. */
  34443. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34444. private _blockMaterialDirtyMechanism;
  34445. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34446. blockMaterialDirtyMechanism: boolean;
  34447. /**
  34448. * Will flag all materials as dirty to trigger new shader compilation
  34449. * @param flag defines the flag used to specify which material part must be marked as dirty
  34450. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34451. */
  34452. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34453. /** @hidden */
  34454. _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;
  34455. /** @hidden */
  34456. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34457. }
  34458. }
  34459. declare module BABYLON {
  34460. /**
  34461. * Set of assets to keep when moving a scene into an asset container.
  34462. */
  34463. export class KeepAssets extends AbstractScene {
  34464. }
  34465. /**
  34466. * Container with a set of assets that can be added or removed from a scene.
  34467. */
  34468. export class AssetContainer extends AbstractScene {
  34469. /**
  34470. * The scene the AssetContainer belongs to.
  34471. */
  34472. scene: Scene;
  34473. /**
  34474. * Instantiates an AssetContainer.
  34475. * @param scene The scene the AssetContainer belongs to.
  34476. */
  34477. constructor(scene: Scene);
  34478. /**
  34479. * Adds all the assets from the container to the scene.
  34480. */
  34481. addAllToScene(): void;
  34482. /**
  34483. * Removes all the assets in the container from the scene
  34484. */
  34485. removeAllFromScene(): void;
  34486. /**
  34487. * Disposes all the assets in the container
  34488. */
  34489. dispose(): void;
  34490. private _moveAssets;
  34491. /**
  34492. * Removes all the assets contained in the scene and adds them to the container.
  34493. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34494. */
  34495. moveAllFromScene(keepAssets?: KeepAssets): void;
  34496. /**
  34497. * 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.
  34498. * @returns the root mesh
  34499. */
  34500. createRootMesh(): Mesh;
  34501. }
  34502. }
  34503. declare module BABYLON {
  34504. /**
  34505. * Defines how the parser contract is defined.
  34506. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34507. */
  34508. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34509. /**
  34510. * Defines how the individual parser contract is defined.
  34511. * These parser can parse an individual asset
  34512. */
  34513. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34514. /**
  34515. * Base class of the scene acting as a container for the different elements composing a scene.
  34516. * This class is dynamically extended by the different components of the scene increasing
  34517. * flexibility and reducing coupling
  34518. */
  34519. export abstract class AbstractScene {
  34520. /**
  34521. * Stores the list of available parsers in the application.
  34522. */
  34523. private static _BabylonFileParsers;
  34524. /**
  34525. * Stores the list of available individual parsers in the application.
  34526. */
  34527. private static _IndividualBabylonFileParsers;
  34528. /**
  34529. * Adds a parser in the list of available ones
  34530. * @param name Defines the name of the parser
  34531. * @param parser Defines the parser to add
  34532. */
  34533. static AddParser(name: string, parser: BabylonFileParser): void;
  34534. /**
  34535. * Gets a general parser from the list of avaialble ones
  34536. * @param name Defines the name of the parser
  34537. * @returns the requested parser or null
  34538. */
  34539. static GetParser(name: string): Nullable<BabylonFileParser>;
  34540. /**
  34541. * Adds n individual parser in the list of available ones
  34542. * @param name Defines the name of the parser
  34543. * @param parser Defines the parser to add
  34544. */
  34545. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34546. /**
  34547. * Gets an individual parser from the list of avaialble ones
  34548. * @param name Defines the name of the parser
  34549. * @returns the requested parser or null
  34550. */
  34551. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34552. /**
  34553. * Parser json data and populate both a scene and its associated container object
  34554. * @param jsonData Defines the data to parse
  34555. * @param scene Defines the scene to parse the data for
  34556. * @param container Defines the container attached to the parsing sequence
  34557. * @param rootUrl Defines the root url of the data
  34558. */
  34559. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34560. /**
  34561. * Gets the list of root nodes (ie. nodes with no parent)
  34562. */
  34563. rootNodes: Node[];
  34564. /** All of the cameras added to this scene
  34565. * @see http://doc.babylonjs.com/babylon101/cameras
  34566. */
  34567. cameras: Camera[];
  34568. /**
  34569. * All of the lights added to this scene
  34570. * @see http://doc.babylonjs.com/babylon101/lights
  34571. */
  34572. lights: Light[];
  34573. /**
  34574. * All of the (abstract) meshes added to this scene
  34575. */
  34576. meshes: AbstractMesh[];
  34577. /**
  34578. * The list of skeletons added to the scene
  34579. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34580. */
  34581. skeletons: Skeleton[];
  34582. /**
  34583. * All of the particle systems added to this scene
  34584. * @see http://doc.babylonjs.com/babylon101/particles
  34585. */
  34586. particleSystems: IParticleSystem[];
  34587. /**
  34588. * Gets a list of Animations associated with the scene
  34589. */
  34590. animations: Animation[];
  34591. /**
  34592. * All of the animation groups added to this scene
  34593. * @see http://doc.babylonjs.com/how_to/group
  34594. */
  34595. animationGroups: AnimationGroup[];
  34596. /**
  34597. * All of the multi-materials added to this scene
  34598. * @see http://doc.babylonjs.com/how_to/multi_materials
  34599. */
  34600. multiMaterials: MultiMaterial[];
  34601. /**
  34602. * All of the materials added to this scene
  34603. * In the context of a Scene, it is not supposed to be modified manually.
  34604. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34605. * Note also that the order of the Material wihin the array is not significant and might change.
  34606. * @see http://doc.babylonjs.com/babylon101/materials
  34607. */
  34608. materials: Material[];
  34609. /**
  34610. * The list of morph target managers added to the scene
  34611. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34612. */
  34613. morphTargetManagers: MorphTargetManager[];
  34614. /**
  34615. * The list of geometries used in the scene.
  34616. */
  34617. geometries: Geometry[];
  34618. /**
  34619. * All of the tranform nodes added to this scene
  34620. * In the context of a Scene, it is not supposed to be modified manually.
  34621. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34622. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34623. * @see http://doc.babylonjs.com/how_to/transformnode
  34624. */
  34625. transformNodes: TransformNode[];
  34626. /**
  34627. * ActionManagers available on the scene.
  34628. */
  34629. actionManagers: AbstractActionManager[];
  34630. /**
  34631. * Textures to keep.
  34632. */
  34633. textures: BaseTexture[];
  34634. /**
  34635. * Environment texture for the scene
  34636. */
  34637. environmentTexture: Nullable<BaseTexture>;
  34638. }
  34639. }
  34640. declare module BABYLON {
  34641. /**
  34642. * Interface used to define options for Sound class
  34643. */
  34644. export interface ISoundOptions {
  34645. /**
  34646. * Does the sound autoplay once loaded.
  34647. */
  34648. autoplay?: boolean;
  34649. /**
  34650. * Does the sound loop after it finishes playing once.
  34651. */
  34652. loop?: boolean;
  34653. /**
  34654. * Sound's volume
  34655. */
  34656. volume?: number;
  34657. /**
  34658. * Is it a spatial sound?
  34659. */
  34660. spatialSound?: boolean;
  34661. /**
  34662. * Maximum distance to hear that sound
  34663. */
  34664. maxDistance?: number;
  34665. /**
  34666. * Uses user defined attenuation function
  34667. */
  34668. useCustomAttenuation?: boolean;
  34669. /**
  34670. * Define the roll off factor of spatial sounds.
  34671. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34672. */
  34673. rolloffFactor?: number;
  34674. /**
  34675. * Define the reference distance the sound should be heard perfectly.
  34676. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34677. */
  34678. refDistance?: number;
  34679. /**
  34680. * Define the distance attenuation model the sound will follow.
  34681. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34682. */
  34683. distanceModel?: string;
  34684. /**
  34685. * Defines the playback speed (1 by default)
  34686. */
  34687. playbackRate?: number;
  34688. /**
  34689. * Defines if the sound is from a streaming source
  34690. */
  34691. streaming?: boolean;
  34692. /**
  34693. * Defines an optional length (in seconds) inside the sound file
  34694. */
  34695. length?: number;
  34696. /**
  34697. * Defines an optional offset (in seconds) inside the sound file
  34698. */
  34699. offset?: number;
  34700. /**
  34701. * If true, URLs will not be required to state the audio file codec to use.
  34702. */
  34703. skipCodecCheck?: boolean;
  34704. }
  34705. /**
  34706. * Defines a sound that can be played in the application.
  34707. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34708. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34709. */
  34710. export class Sound {
  34711. /**
  34712. * The name of the sound in the scene.
  34713. */
  34714. name: string;
  34715. /**
  34716. * Does the sound autoplay once loaded.
  34717. */
  34718. autoplay: boolean;
  34719. /**
  34720. * Does the sound loop after it finishes playing once.
  34721. */
  34722. loop: boolean;
  34723. /**
  34724. * Does the sound use a custom attenuation curve to simulate the falloff
  34725. * happening when the source gets further away from the camera.
  34726. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34727. */
  34728. useCustomAttenuation: boolean;
  34729. /**
  34730. * The sound track id this sound belongs to.
  34731. */
  34732. soundTrackId: number;
  34733. /**
  34734. * Is this sound currently played.
  34735. */
  34736. isPlaying: boolean;
  34737. /**
  34738. * Is this sound currently paused.
  34739. */
  34740. isPaused: boolean;
  34741. /**
  34742. * Does this sound enables spatial sound.
  34743. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34744. */
  34745. spatialSound: boolean;
  34746. /**
  34747. * Define the reference distance the sound should be heard perfectly.
  34748. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34749. */
  34750. refDistance: number;
  34751. /**
  34752. * Define the roll off factor of spatial sounds.
  34753. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34754. */
  34755. rolloffFactor: number;
  34756. /**
  34757. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34758. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34759. */
  34760. maxDistance: number;
  34761. /**
  34762. * Define the distance attenuation model the sound will follow.
  34763. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34764. */
  34765. distanceModel: string;
  34766. /**
  34767. * @hidden
  34768. * Back Compat
  34769. **/
  34770. onended: () => any;
  34771. /**
  34772. * Observable event when the current playing sound finishes.
  34773. */
  34774. onEndedObservable: Observable<Sound>;
  34775. private _panningModel;
  34776. private _playbackRate;
  34777. private _streaming;
  34778. private _startTime;
  34779. private _startOffset;
  34780. private _position;
  34781. /** @hidden */
  34782. _positionInEmitterSpace: boolean;
  34783. private _localDirection;
  34784. private _volume;
  34785. private _isReadyToPlay;
  34786. private _isDirectional;
  34787. private _readyToPlayCallback;
  34788. private _audioBuffer;
  34789. private _soundSource;
  34790. private _streamingSource;
  34791. private _soundPanner;
  34792. private _soundGain;
  34793. private _inputAudioNode;
  34794. private _outputAudioNode;
  34795. private _coneInnerAngle;
  34796. private _coneOuterAngle;
  34797. private _coneOuterGain;
  34798. private _scene;
  34799. private _connectedTransformNode;
  34800. private _customAttenuationFunction;
  34801. private _registerFunc;
  34802. private _isOutputConnected;
  34803. private _htmlAudioElement;
  34804. private _urlType;
  34805. private _length?;
  34806. private _offset?;
  34807. /** @hidden */
  34808. static _SceneComponentInitialization: (scene: Scene) => void;
  34809. /**
  34810. * Create a sound and attach it to a scene
  34811. * @param name Name of your sound
  34812. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34813. * @param scene defines the scene the sound belongs to
  34814. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34815. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34816. */
  34817. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34818. /**
  34819. * Release the sound and its associated resources
  34820. */
  34821. dispose(): void;
  34822. /**
  34823. * Gets if the sounds is ready to be played or not.
  34824. * @returns true if ready, otherwise false
  34825. */
  34826. isReady(): boolean;
  34827. private _soundLoaded;
  34828. /**
  34829. * Sets the data of the sound from an audiobuffer
  34830. * @param audioBuffer The audioBuffer containing the data
  34831. */
  34832. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34833. /**
  34834. * Updates the current sounds options such as maxdistance, loop...
  34835. * @param options A JSON object containing values named as the object properties
  34836. */
  34837. updateOptions(options: ISoundOptions): void;
  34838. private _createSpatialParameters;
  34839. private _updateSpatialParameters;
  34840. /**
  34841. * Switch the panning model to HRTF:
  34842. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34843. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34844. */
  34845. switchPanningModelToHRTF(): void;
  34846. /**
  34847. * Switch the panning model to Equal Power:
  34848. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34849. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34850. */
  34851. switchPanningModelToEqualPower(): void;
  34852. private _switchPanningModel;
  34853. /**
  34854. * Connect this sound to a sound track audio node like gain...
  34855. * @param soundTrackAudioNode the sound track audio node to connect to
  34856. */
  34857. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34858. /**
  34859. * Transform this sound into a directional source
  34860. * @param coneInnerAngle Size of the inner cone in degree
  34861. * @param coneOuterAngle Size of the outer cone in degree
  34862. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34863. */
  34864. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34865. /**
  34866. * Gets or sets the inner angle for the directional cone.
  34867. */
  34868. /**
  34869. * Gets or sets the inner angle for the directional cone.
  34870. */
  34871. directionalConeInnerAngle: number;
  34872. /**
  34873. * Gets or sets the outer angle for the directional cone.
  34874. */
  34875. /**
  34876. * Gets or sets the outer angle for the directional cone.
  34877. */
  34878. directionalConeOuterAngle: number;
  34879. /**
  34880. * Sets the position of the emitter if spatial sound is enabled
  34881. * @param newPosition Defines the new posisiton
  34882. */
  34883. setPosition(newPosition: Vector3): void;
  34884. /**
  34885. * Sets the local direction of the emitter if spatial sound is enabled
  34886. * @param newLocalDirection Defines the new local direction
  34887. */
  34888. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34889. private _updateDirection;
  34890. /** @hidden */
  34891. updateDistanceFromListener(): void;
  34892. /**
  34893. * Sets a new custom attenuation function for the sound.
  34894. * @param callback Defines the function used for the attenuation
  34895. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34896. */
  34897. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34898. /**
  34899. * Play the sound
  34900. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34901. * @param offset (optional) Start the sound at a specific time in seconds
  34902. * @param length (optional) Sound duration (in seconds)
  34903. */
  34904. play(time?: number, offset?: number, length?: number): void;
  34905. private _onended;
  34906. /**
  34907. * Stop the sound
  34908. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34909. */
  34910. stop(time?: number): void;
  34911. /**
  34912. * Put the sound in pause
  34913. */
  34914. pause(): void;
  34915. /**
  34916. * Sets a dedicated volume for this sounds
  34917. * @param newVolume Define the new volume of the sound
  34918. * @param time Define time for gradual change to new volume
  34919. */
  34920. setVolume(newVolume: number, time?: number): void;
  34921. /**
  34922. * Set the sound play back rate
  34923. * @param newPlaybackRate Define the playback rate the sound should be played at
  34924. */
  34925. setPlaybackRate(newPlaybackRate: number): void;
  34926. /**
  34927. * Gets the volume of the sound.
  34928. * @returns the volume of the sound
  34929. */
  34930. getVolume(): number;
  34931. /**
  34932. * Attach the sound to a dedicated mesh
  34933. * @param transformNode The transform node to connect the sound with
  34934. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34935. */
  34936. attachToMesh(transformNode: TransformNode): void;
  34937. /**
  34938. * Detach the sound from the previously attached mesh
  34939. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34940. */
  34941. detachFromMesh(): void;
  34942. private _onRegisterAfterWorldMatrixUpdate;
  34943. /**
  34944. * Clone the current sound in the scene.
  34945. * @returns the new sound clone
  34946. */
  34947. clone(): Nullable<Sound>;
  34948. /**
  34949. * Gets the current underlying audio buffer containing the data
  34950. * @returns the audio buffer
  34951. */
  34952. getAudioBuffer(): Nullable<AudioBuffer>;
  34953. /**
  34954. * Serializes the Sound in a JSON representation
  34955. * @returns the JSON representation of the sound
  34956. */
  34957. serialize(): any;
  34958. /**
  34959. * Parse a JSON representation of a sound to innstantiate in a given scene
  34960. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34961. * @param scene Define the scene the new parsed sound should be created in
  34962. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34963. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34964. * @returns the newly parsed sound
  34965. */
  34966. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34967. }
  34968. }
  34969. declare module BABYLON {
  34970. /**
  34971. * This defines an action helpful to play a defined sound on a triggered action.
  34972. */
  34973. export class PlaySoundAction extends Action {
  34974. private _sound;
  34975. /**
  34976. * Instantiate the action
  34977. * @param triggerOptions defines the trigger options
  34978. * @param sound defines the sound to play
  34979. * @param condition defines the trigger related conditions
  34980. */
  34981. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34982. /** @hidden */
  34983. _prepare(): void;
  34984. /**
  34985. * Execute the action and play the sound.
  34986. */
  34987. execute(): void;
  34988. /**
  34989. * Serializes the actions and its related information.
  34990. * @param parent defines the object to serialize in
  34991. * @returns the serialized object
  34992. */
  34993. serialize(parent: any): any;
  34994. }
  34995. /**
  34996. * This defines an action helpful to stop a defined sound on a triggered action.
  34997. */
  34998. export class StopSoundAction extends Action {
  34999. private _sound;
  35000. /**
  35001. * Instantiate the action
  35002. * @param triggerOptions defines the trigger options
  35003. * @param sound defines the sound to stop
  35004. * @param condition defines the trigger related conditions
  35005. */
  35006. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35007. /** @hidden */
  35008. _prepare(): void;
  35009. /**
  35010. * Execute the action and stop the sound.
  35011. */
  35012. execute(): void;
  35013. /**
  35014. * Serializes the actions and its related information.
  35015. * @param parent defines the object to serialize in
  35016. * @returns the serialized object
  35017. */
  35018. serialize(parent: any): any;
  35019. }
  35020. }
  35021. declare module BABYLON {
  35022. /**
  35023. * This defines an action responsible to change the value of a property
  35024. * by interpolating between its current value and the newly set one once triggered.
  35025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35026. */
  35027. export class InterpolateValueAction extends Action {
  35028. /**
  35029. * Defines the path of the property where the value should be interpolated
  35030. */
  35031. propertyPath: string;
  35032. /**
  35033. * Defines the target value at the end of the interpolation.
  35034. */
  35035. value: any;
  35036. /**
  35037. * Defines the time it will take for the property to interpolate to the value.
  35038. */
  35039. duration: number;
  35040. /**
  35041. * Defines if the other scene animations should be stopped when the action has been triggered
  35042. */
  35043. stopOtherAnimations?: boolean;
  35044. /**
  35045. * Defines a callback raised once the interpolation animation has been done.
  35046. */
  35047. onInterpolationDone?: () => void;
  35048. /**
  35049. * Observable triggered once the interpolation animation has been done.
  35050. */
  35051. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35052. private _target;
  35053. private _effectiveTarget;
  35054. private _property;
  35055. /**
  35056. * Instantiate the action
  35057. * @param triggerOptions defines the trigger options
  35058. * @param target defines the object containing the value to interpolate
  35059. * @param propertyPath defines the path to the property in the target object
  35060. * @param value defines the target value at the end of the interpolation
  35061. * @param duration deines the time it will take for the property to interpolate to the value.
  35062. * @param condition defines the trigger related conditions
  35063. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35064. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35065. */
  35066. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35067. /** @hidden */
  35068. _prepare(): void;
  35069. /**
  35070. * Execute the action starts the value interpolation.
  35071. */
  35072. execute(): void;
  35073. /**
  35074. * Serializes the actions and its related information.
  35075. * @param parent defines the object to serialize in
  35076. * @returns the serialized object
  35077. */
  35078. serialize(parent: any): any;
  35079. }
  35080. }
  35081. declare module BABYLON {
  35082. /**
  35083. * Options allowed during the creation of a sound track.
  35084. */
  35085. export interface ISoundTrackOptions {
  35086. /**
  35087. * The volume the sound track should take during creation
  35088. */
  35089. volume?: number;
  35090. /**
  35091. * Define if the sound track is the main sound track of the scene
  35092. */
  35093. mainTrack?: boolean;
  35094. }
  35095. /**
  35096. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35097. * It will be also used in a future release to apply effects on a specific track.
  35098. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35099. */
  35100. export class SoundTrack {
  35101. /**
  35102. * The unique identifier of the sound track in the scene.
  35103. */
  35104. id: number;
  35105. /**
  35106. * The list of sounds included in the sound track.
  35107. */
  35108. soundCollection: Array<Sound>;
  35109. private _outputAudioNode;
  35110. private _scene;
  35111. private _isMainTrack;
  35112. private _connectedAnalyser;
  35113. private _options;
  35114. private _isInitialized;
  35115. /**
  35116. * Creates a new sound track.
  35117. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35118. * @param scene Define the scene the sound track belongs to
  35119. * @param options
  35120. */
  35121. constructor(scene: Scene, options?: ISoundTrackOptions);
  35122. private _initializeSoundTrackAudioGraph;
  35123. /**
  35124. * Release the sound track and its associated resources
  35125. */
  35126. dispose(): void;
  35127. /**
  35128. * Adds a sound to this sound track
  35129. * @param sound define the cound to add
  35130. * @ignoreNaming
  35131. */
  35132. AddSound(sound: Sound): void;
  35133. /**
  35134. * Removes a sound to this sound track
  35135. * @param sound define the cound to remove
  35136. * @ignoreNaming
  35137. */
  35138. RemoveSound(sound: Sound): void;
  35139. /**
  35140. * Set a global volume for the full sound track.
  35141. * @param newVolume Define the new volume of the sound track
  35142. */
  35143. setVolume(newVolume: number): void;
  35144. /**
  35145. * Switch the panning model to HRTF:
  35146. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35147. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35148. */
  35149. switchPanningModelToHRTF(): void;
  35150. /**
  35151. * Switch the panning model to Equal Power:
  35152. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35153. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35154. */
  35155. switchPanningModelToEqualPower(): void;
  35156. /**
  35157. * Connect the sound track to an audio analyser allowing some amazing
  35158. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35159. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35160. * @param analyser The analyser to connect to the engine
  35161. */
  35162. connectToAnalyser(analyser: Analyser): void;
  35163. }
  35164. }
  35165. declare module BABYLON {
  35166. interface AbstractScene {
  35167. /**
  35168. * The list of sounds used in the scene.
  35169. */
  35170. sounds: Nullable<Array<Sound>>;
  35171. }
  35172. interface Scene {
  35173. /**
  35174. * @hidden
  35175. * Backing field
  35176. */
  35177. _mainSoundTrack: SoundTrack;
  35178. /**
  35179. * The main sound track played by the scene.
  35180. * It cotains your primary collection of sounds.
  35181. */
  35182. mainSoundTrack: SoundTrack;
  35183. /**
  35184. * The list of sound tracks added to the scene
  35185. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35186. */
  35187. soundTracks: Nullable<Array<SoundTrack>>;
  35188. /**
  35189. * Gets a sound using a given name
  35190. * @param name defines the name to search for
  35191. * @return the found sound or null if not found at all.
  35192. */
  35193. getSoundByName(name: string): Nullable<Sound>;
  35194. /**
  35195. * Gets or sets if audio support is enabled
  35196. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35197. */
  35198. audioEnabled: boolean;
  35199. /**
  35200. * Gets or sets if audio will be output to headphones
  35201. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35202. */
  35203. headphone: boolean;
  35204. /**
  35205. * Gets or sets custom audio listener position provider
  35206. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35207. */
  35208. audioListenerPositionProvider: Nullable<() => Vector3>;
  35209. }
  35210. /**
  35211. * Defines the sound scene component responsible to manage any sounds
  35212. * in a given scene.
  35213. */
  35214. export class AudioSceneComponent implements ISceneSerializableComponent {
  35215. /**
  35216. * The component name helpfull to identify the component in the list of scene components.
  35217. */
  35218. readonly name: string;
  35219. /**
  35220. * The scene the component belongs to.
  35221. */
  35222. scene: Scene;
  35223. private _audioEnabled;
  35224. /**
  35225. * Gets whether audio is enabled or not.
  35226. * Please use related enable/disable method to switch state.
  35227. */
  35228. readonly audioEnabled: boolean;
  35229. private _headphone;
  35230. /**
  35231. * Gets whether audio is outputing to headphone or not.
  35232. * Please use the according Switch methods to change output.
  35233. */
  35234. readonly headphone: boolean;
  35235. private _audioListenerPositionProvider;
  35236. /**
  35237. * Gets the current audio listener position provider
  35238. */
  35239. /**
  35240. * Sets a custom listener position for all sounds in the scene
  35241. * By default, this is the position of the first active camera
  35242. */
  35243. audioListenerPositionProvider: Nullable<() => Vector3>;
  35244. /**
  35245. * Creates a new instance of the component for the given scene
  35246. * @param scene Defines the scene to register the component in
  35247. */
  35248. constructor(scene: Scene);
  35249. /**
  35250. * Registers the component in a given scene
  35251. */
  35252. register(): void;
  35253. /**
  35254. * Rebuilds the elements related to this component in case of
  35255. * context lost for instance.
  35256. */
  35257. rebuild(): void;
  35258. /**
  35259. * Serializes the component data to the specified json object
  35260. * @param serializationObject The object to serialize to
  35261. */
  35262. serialize(serializationObject: any): void;
  35263. /**
  35264. * Adds all the elements from the container to the scene
  35265. * @param container the container holding the elements
  35266. */
  35267. addFromContainer(container: AbstractScene): void;
  35268. /**
  35269. * Removes all the elements in the container from the scene
  35270. * @param container contains the elements to remove
  35271. * @param dispose if the removed element should be disposed (default: false)
  35272. */
  35273. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35274. /**
  35275. * Disposes the component and the associated ressources.
  35276. */
  35277. dispose(): void;
  35278. /**
  35279. * Disables audio in the associated scene.
  35280. */
  35281. disableAudio(): void;
  35282. /**
  35283. * Enables audio in the associated scene.
  35284. */
  35285. enableAudio(): void;
  35286. /**
  35287. * Switch audio to headphone output.
  35288. */
  35289. switchAudioModeForHeadphones(): void;
  35290. /**
  35291. * Switch audio to normal speakers.
  35292. */
  35293. switchAudioModeForNormalSpeakers(): void;
  35294. private _afterRender;
  35295. }
  35296. }
  35297. declare module BABYLON {
  35298. /**
  35299. * Wraps one or more Sound objects and selects one with random weight for playback.
  35300. */
  35301. export class WeightedSound {
  35302. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35303. loop: boolean;
  35304. private _coneInnerAngle;
  35305. private _coneOuterAngle;
  35306. private _volume;
  35307. /** A Sound is currently playing. */
  35308. isPlaying: boolean;
  35309. /** A Sound is currently paused. */
  35310. isPaused: boolean;
  35311. private _sounds;
  35312. private _weights;
  35313. private _currentIndex?;
  35314. /**
  35315. * Creates a new WeightedSound from the list of sounds given.
  35316. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35317. * @param sounds Array of Sounds that will be selected from.
  35318. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35319. */
  35320. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35321. /**
  35322. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35323. */
  35324. /**
  35325. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35326. */
  35327. directionalConeInnerAngle: number;
  35328. /**
  35329. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35330. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35331. */
  35332. /**
  35333. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35334. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35335. */
  35336. directionalConeOuterAngle: number;
  35337. /**
  35338. * Playback volume.
  35339. */
  35340. /**
  35341. * Playback volume.
  35342. */
  35343. volume: number;
  35344. private _onended;
  35345. /**
  35346. * Suspend playback
  35347. */
  35348. pause(): void;
  35349. /**
  35350. * Stop playback
  35351. */
  35352. stop(): void;
  35353. /**
  35354. * Start playback.
  35355. * @param startOffset Position the clip head at a specific time in seconds.
  35356. */
  35357. play(startOffset?: number): void;
  35358. }
  35359. }
  35360. declare module BABYLON {
  35361. /**
  35362. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35363. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35364. */
  35365. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35366. /**
  35367. * Gets the name of the behavior.
  35368. */
  35369. readonly name: string;
  35370. /**
  35371. * The easing function used by animations
  35372. */
  35373. static EasingFunction: BackEase;
  35374. /**
  35375. * The easing mode used by animations
  35376. */
  35377. static EasingMode: number;
  35378. /**
  35379. * The duration of the animation, in milliseconds
  35380. */
  35381. transitionDuration: number;
  35382. /**
  35383. * Length of the distance animated by the transition when lower radius is reached
  35384. */
  35385. lowerRadiusTransitionRange: number;
  35386. /**
  35387. * Length of the distance animated by the transition when upper radius is reached
  35388. */
  35389. upperRadiusTransitionRange: number;
  35390. private _autoTransitionRange;
  35391. /**
  35392. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35393. */
  35394. /**
  35395. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35396. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35397. */
  35398. autoTransitionRange: boolean;
  35399. private _attachedCamera;
  35400. private _onAfterCheckInputsObserver;
  35401. private _onMeshTargetChangedObserver;
  35402. /**
  35403. * Initializes the behavior.
  35404. */
  35405. init(): void;
  35406. /**
  35407. * Attaches the behavior to its arc rotate camera.
  35408. * @param camera Defines the camera to attach the behavior to
  35409. */
  35410. attach(camera: ArcRotateCamera): void;
  35411. /**
  35412. * Detaches the behavior from its current arc rotate camera.
  35413. */
  35414. detach(): void;
  35415. private _radiusIsAnimating;
  35416. private _radiusBounceTransition;
  35417. private _animatables;
  35418. private _cachedWheelPrecision;
  35419. /**
  35420. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35421. * @param radiusLimit The limit to check against.
  35422. * @return Bool to indicate if at limit.
  35423. */
  35424. private _isRadiusAtLimit;
  35425. /**
  35426. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35427. * @param radiusDelta The delta by which to animate to. Can be negative.
  35428. */
  35429. private _applyBoundRadiusAnimation;
  35430. /**
  35431. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35432. */
  35433. protected _clearAnimationLocks(): void;
  35434. /**
  35435. * Stops and removes all animations that have been applied to the camera
  35436. */
  35437. stopAllAnimations(): void;
  35438. }
  35439. }
  35440. declare module BABYLON {
  35441. /**
  35442. * 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.
  35443. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35444. */
  35445. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35446. /**
  35447. * Gets the name of the behavior.
  35448. */
  35449. readonly name: string;
  35450. private _mode;
  35451. private _radiusScale;
  35452. private _positionScale;
  35453. private _defaultElevation;
  35454. private _elevationReturnTime;
  35455. private _elevationReturnWaitTime;
  35456. private _zoomStopsAnimation;
  35457. private _framingTime;
  35458. /**
  35459. * The easing function used by animations
  35460. */
  35461. static EasingFunction: ExponentialEase;
  35462. /**
  35463. * The easing mode used by animations
  35464. */
  35465. static EasingMode: number;
  35466. /**
  35467. * Sets the current mode used by the behavior
  35468. */
  35469. /**
  35470. * Gets current mode used by the behavior.
  35471. */
  35472. mode: number;
  35473. /**
  35474. * Sets the scale applied to the radius (1 by default)
  35475. */
  35476. /**
  35477. * Gets the scale applied to the radius
  35478. */
  35479. radiusScale: number;
  35480. /**
  35481. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35482. */
  35483. /**
  35484. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35485. */
  35486. positionScale: number;
  35487. /**
  35488. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35489. * behaviour is triggered, in radians.
  35490. */
  35491. /**
  35492. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35493. * behaviour is triggered, in radians.
  35494. */
  35495. defaultElevation: number;
  35496. /**
  35497. * Sets the time (in milliseconds) taken to return to the default beta position.
  35498. * Negative value indicates camera should not return to default.
  35499. */
  35500. /**
  35501. * Gets the time (in milliseconds) taken to return to the default beta position.
  35502. * Negative value indicates camera should not return to default.
  35503. */
  35504. elevationReturnTime: number;
  35505. /**
  35506. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35507. */
  35508. /**
  35509. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35510. */
  35511. elevationReturnWaitTime: number;
  35512. /**
  35513. * Sets the flag that indicates if user zooming should stop animation.
  35514. */
  35515. /**
  35516. * Gets the flag that indicates if user zooming should stop animation.
  35517. */
  35518. zoomStopsAnimation: boolean;
  35519. /**
  35520. * Sets the transition time when framing the mesh, in milliseconds
  35521. */
  35522. /**
  35523. * Gets the transition time when framing the mesh, in milliseconds
  35524. */
  35525. framingTime: number;
  35526. /**
  35527. * Define if the behavior should automatically change the configured
  35528. * camera limits and sensibilities.
  35529. */
  35530. autoCorrectCameraLimitsAndSensibility: boolean;
  35531. private _onPrePointerObservableObserver;
  35532. private _onAfterCheckInputsObserver;
  35533. private _onMeshTargetChangedObserver;
  35534. private _attachedCamera;
  35535. private _isPointerDown;
  35536. private _lastInteractionTime;
  35537. /**
  35538. * Initializes the behavior.
  35539. */
  35540. init(): void;
  35541. /**
  35542. * Attaches the behavior to its arc rotate camera.
  35543. * @param camera Defines the camera to attach the behavior to
  35544. */
  35545. attach(camera: ArcRotateCamera): void;
  35546. /**
  35547. * Detaches the behavior from its current arc rotate camera.
  35548. */
  35549. detach(): void;
  35550. private _animatables;
  35551. private _betaIsAnimating;
  35552. private _betaTransition;
  35553. private _radiusTransition;
  35554. private _vectorTransition;
  35555. /**
  35556. * Targets the given mesh and updates zoom level accordingly.
  35557. * @param mesh The mesh to target.
  35558. * @param radius Optional. If a cached radius position already exists, overrides default.
  35559. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35560. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35561. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35562. */
  35563. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35564. /**
  35565. * Targets the given mesh with its children and updates zoom level accordingly.
  35566. * @param mesh The mesh to target.
  35567. * @param radius Optional. If a cached radius position already exists, overrides default.
  35568. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35569. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35570. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35571. */
  35572. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35573. /**
  35574. * Targets the given meshes with their children and updates zoom level accordingly.
  35575. * @param meshes The mesh to target.
  35576. * @param radius Optional. If a cached radius position already exists, overrides default.
  35577. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35578. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35579. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35580. */
  35581. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35582. /**
  35583. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35584. * @param minimumWorld Determines the smaller position of the bounding box extend
  35585. * @param maximumWorld Determines the bigger position of the bounding box extend
  35586. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35587. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35588. */
  35589. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35590. /**
  35591. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35592. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35593. * frustum width.
  35594. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35595. * to fully enclose the mesh in the viewing frustum.
  35596. */
  35597. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35598. /**
  35599. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35600. * is automatically returned to its default position (expected to be above ground plane).
  35601. */
  35602. private _maintainCameraAboveGround;
  35603. /**
  35604. * Returns the frustum slope based on the canvas ratio and camera FOV
  35605. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35606. */
  35607. private _getFrustumSlope;
  35608. /**
  35609. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35610. */
  35611. private _clearAnimationLocks;
  35612. /**
  35613. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35614. */
  35615. private _applyUserInteraction;
  35616. /**
  35617. * Stops and removes all animations that have been applied to the camera
  35618. */
  35619. stopAllAnimations(): void;
  35620. /**
  35621. * Gets a value indicating if the user is moving the camera
  35622. */
  35623. readonly isUserIsMoving: boolean;
  35624. /**
  35625. * The camera can move all the way towards the mesh.
  35626. */
  35627. static IgnoreBoundsSizeMode: number;
  35628. /**
  35629. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35630. */
  35631. static FitFrustumSidesMode: number;
  35632. }
  35633. }
  35634. declare module BABYLON {
  35635. /**
  35636. * Base class for Camera Pointer Inputs.
  35637. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35638. * for example usage.
  35639. */
  35640. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35641. /**
  35642. * Defines the camera the input is attached to.
  35643. */
  35644. abstract camera: Camera;
  35645. /**
  35646. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35647. */
  35648. protected _altKey: boolean;
  35649. protected _ctrlKey: boolean;
  35650. protected _metaKey: boolean;
  35651. protected _shiftKey: boolean;
  35652. /**
  35653. * Which mouse buttons were pressed at time of last mouse event.
  35654. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35655. */
  35656. protected _buttonsPressed: number;
  35657. /**
  35658. * Defines the buttons associated with the input to handle camera move.
  35659. */
  35660. buttons: number[];
  35661. /**
  35662. * Attach the input controls to a specific dom element to get the input from.
  35663. * @param element Defines the element the controls should be listened from
  35664. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35665. */
  35666. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35667. /**
  35668. * Detach the current controls from the specified dom element.
  35669. * @param element Defines the element to stop listening the inputs from
  35670. */
  35671. detachControl(element: Nullable<HTMLElement>): void;
  35672. /**
  35673. * Gets the class name of the current input.
  35674. * @returns the class name
  35675. */
  35676. getClassName(): string;
  35677. /**
  35678. * Get the friendly name associated with the input class.
  35679. * @returns the input friendly name
  35680. */
  35681. getSimpleName(): string;
  35682. /**
  35683. * Called on pointer POINTERDOUBLETAP event.
  35684. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35685. */
  35686. protected onDoubleTap(type: string): void;
  35687. /**
  35688. * Called on pointer POINTERMOVE event if only a single touch is active.
  35689. * Override this method to provide functionality.
  35690. */
  35691. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35692. /**
  35693. * Called on pointer POINTERMOVE event if multiple touches are active.
  35694. * Override this method to provide functionality.
  35695. */
  35696. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35697. /**
  35698. * Called on JS contextmenu event.
  35699. * Override this method to provide functionality.
  35700. */
  35701. protected onContextMenu(evt: PointerEvent): void;
  35702. /**
  35703. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35704. * press.
  35705. * Override this method to provide functionality.
  35706. */
  35707. protected onButtonDown(evt: PointerEvent): void;
  35708. /**
  35709. * Called each time a new POINTERUP event occurs. Ie, for each button
  35710. * release.
  35711. * Override this method to provide functionality.
  35712. */
  35713. protected onButtonUp(evt: PointerEvent): void;
  35714. /**
  35715. * Called when window becomes inactive.
  35716. * Override this method to provide functionality.
  35717. */
  35718. protected onLostFocus(): void;
  35719. private _pointerInput;
  35720. private _observer;
  35721. private _onLostFocus;
  35722. private pointA;
  35723. private pointB;
  35724. }
  35725. }
  35726. declare module BABYLON {
  35727. /**
  35728. * Manage the pointers inputs to control an arc rotate camera.
  35729. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35730. */
  35731. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35732. /**
  35733. * Defines the camera the input is attached to.
  35734. */
  35735. camera: ArcRotateCamera;
  35736. /**
  35737. * Gets the class name of the current input.
  35738. * @returns the class name
  35739. */
  35740. getClassName(): string;
  35741. /**
  35742. * Defines the buttons associated with the input to handle camera move.
  35743. */
  35744. buttons: number[];
  35745. /**
  35746. * Defines the pointer angular sensibility along the X axis or how fast is
  35747. * the camera rotating.
  35748. */
  35749. angularSensibilityX: number;
  35750. /**
  35751. * Defines the pointer angular sensibility along the Y axis or how fast is
  35752. * the camera rotating.
  35753. */
  35754. angularSensibilityY: number;
  35755. /**
  35756. * Defines the pointer pinch precision or how fast is the camera zooming.
  35757. */
  35758. pinchPrecision: number;
  35759. /**
  35760. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35761. * from 0.
  35762. * It defines the percentage of current camera.radius to use as delta when
  35763. * pinch zoom is used.
  35764. */
  35765. pinchDeltaPercentage: number;
  35766. /**
  35767. * Defines the pointer panning sensibility or how fast is the camera moving.
  35768. */
  35769. panningSensibility: number;
  35770. /**
  35771. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35772. */
  35773. multiTouchPanning: boolean;
  35774. /**
  35775. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35776. * zoom (pinch) through multitouch.
  35777. */
  35778. multiTouchPanAndZoom: boolean;
  35779. /**
  35780. * Revers pinch action direction.
  35781. */
  35782. pinchInwards: boolean;
  35783. private _isPanClick;
  35784. private _twoFingerActivityCount;
  35785. private _isPinching;
  35786. /**
  35787. * Called on pointer POINTERMOVE event if only a single touch is active.
  35788. */
  35789. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35790. /**
  35791. * Called on pointer POINTERDOUBLETAP event.
  35792. */
  35793. protected onDoubleTap(type: string): void;
  35794. /**
  35795. * Called on pointer POINTERMOVE event if multiple touches are active.
  35796. */
  35797. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35798. /**
  35799. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35800. * press.
  35801. */
  35802. protected onButtonDown(evt: PointerEvent): void;
  35803. /**
  35804. * Called each time a new POINTERUP event occurs. Ie, for each button
  35805. * release.
  35806. */
  35807. protected onButtonUp(evt: PointerEvent): void;
  35808. /**
  35809. * Called when window becomes inactive.
  35810. */
  35811. protected onLostFocus(): void;
  35812. }
  35813. }
  35814. declare module BABYLON {
  35815. /**
  35816. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35817. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35818. */
  35819. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35820. /**
  35821. * Defines the camera the input is attached to.
  35822. */
  35823. camera: ArcRotateCamera;
  35824. /**
  35825. * Defines the list of key codes associated with the up action (increase alpha)
  35826. */
  35827. keysUp: number[];
  35828. /**
  35829. * Defines the list of key codes associated with the down action (decrease alpha)
  35830. */
  35831. keysDown: number[];
  35832. /**
  35833. * Defines the list of key codes associated with the left action (increase beta)
  35834. */
  35835. keysLeft: number[];
  35836. /**
  35837. * Defines the list of key codes associated with the right action (decrease beta)
  35838. */
  35839. keysRight: number[];
  35840. /**
  35841. * Defines the list of key codes associated with the reset action.
  35842. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35843. */
  35844. keysReset: number[];
  35845. /**
  35846. * Defines the panning sensibility of the inputs.
  35847. * (How fast is the camera paning)
  35848. */
  35849. panningSensibility: number;
  35850. /**
  35851. * Defines the zooming sensibility of the inputs.
  35852. * (How fast is the camera zooming)
  35853. */
  35854. zoomingSensibility: number;
  35855. /**
  35856. * Defines wether maintaining the alt key down switch the movement mode from
  35857. * orientation to zoom.
  35858. */
  35859. useAltToZoom: boolean;
  35860. /**
  35861. * Rotation speed of the camera
  35862. */
  35863. angularSpeed: number;
  35864. private _keys;
  35865. private _ctrlPressed;
  35866. private _altPressed;
  35867. private _onCanvasBlurObserver;
  35868. private _onKeyboardObserver;
  35869. private _engine;
  35870. private _scene;
  35871. /**
  35872. * Attach the input controls to a specific dom element to get the input from.
  35873. * @param element Defines the element the controls should be listened from
  35874. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35875. */
  35876. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35877. /**
  35878. * Detach the current controls from the specified dom element.
  35879. * @param element Defines the element to stop listening the inputs from
  35880. */
  35881. detachControl(element: Nullable<HTMLElement>): void;
  35882. /**
  35883. * Update the current camera state depending on the inputs that have been used this frame.
  35884. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35885. */
  35886. checkInputs(): void;
  35887. /**
  35888. * Gets the class name of the current intput.
  35889. * @returns the class name
  35890. */
  35891. getClassName(): string;
  35892. /**
  35893. * Get the friendly name associated with the input class.
  35894. * @returns the input friendly name
  35895. */
  35896. getSimpleName(): string;
  35897. }
  35898. }
  35899. declare module BABYLON {
  35900. /**
  35901. * Manage the mouse wheel inputs to control an arc rotate camera.
  35902. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35903. */
  35904. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35905. /**
  35906. * Defines the camera the input is attached to.
  35907. */
  35908. camera: ArcRotateCamera;
  35909. /**
  35910. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35911. */
  35912. wheelPrecision: number;
  35913. /**
  35914. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35915. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35916. */
  35917. wheelDeltaPercentage: number;
  35918. private _wheel;
  35919. private _observer;
  35920. private computeDeltaFromMouseWheelLegacyEvent;
  35921. /**
  35922. * Attach the input controls to a specific dom element to get the input from.
  35923. * @param element Defines the element the controls should be listened from
  35924. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35925. */
  35926. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35927. /**
  35928. * Detach the current controls from the specified dom element.
  35929. * @param element Defines the element to stop listening the inputs from
  35930. */
  35931. detachControl(element: Nullable<HTMLElement>): void;
  35932. /**
  35933. * Gets the class name of the current intput.
  35934. * @returns the class name
  35935. */
  35936. getClassName(): string;
  35937. /**
  35938. * Get the friendly name associated with the input class.
  35939. * @returns the input friendly name
  35940. */
  35941. getSimpleName(): string;
  35942. }
  35943. }
  35944. declare module BABYLON {
  35945. /**
  35946. * Default Inputs manager for the ArcRotateCamera.
  35947. * It groups all the default supported inputs for ease of use.
  35948. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35949. */
  35950. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35951. /**
  35952. * Instantiates a new ArcRotateCameraInputsManager.
  35953. * @param camera Defines the camera the inputs belong to
  35954. */
  35955. constructor(camera: ArcRotateCamera);
  35956. /**
  35957. * Add mouse wheel input support to the input manager.
  35958. * @returns the current input manager
  35959. */
  35960. addMouseWheel(): ArcRotateCameraInputsManager;
  35961. /**
  35962. * Add pointers input support to the input manager.
  35963. * @returns the current input manager
  35964. */
  35965. addPointers(): ArcRotateCameraInputsManager;
  35966. /**
  35967. * Add keyboard input support to the input manager.
  35968. * @returns the current input manager
  35969. */
  35970. addKeyboard(): ArcRotateCameraInputsManager;
  35971. }
  35972. }
  35973. declare module BABYLON {
  35974. /**
  35975. * This represents an orbital type of camera.
  35976. *
  35977. * 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.
  35978. * 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.
  35979. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35980. */
  35981. export class ArcRotateCamera extends TargetCamera {
  35982. /**
  35983. * Defines the rotation angle of the camera along the longitudinal axis.
  35984. */
  35985. alpha: number;
  35986. /**
  35987. * Defines the rotation angle of the camera along the latitudinal axis.
  35988. */
  35989. beta: number;
  35990. /**
  35991. * Defines the radius of the camera from it s target point.
  35992. */
  35993. radius: number;
  35994. protected _target: Vector3;
  35995. protected _targetHost: Nullable<AbstractMesh>;
  35996. /**
  35997. * Defines the target point of the camera.
  35998. * The camera looks towards it form the radius distance.
  35999. */
  36000. target: Vector3;
  36001. /**
  36002. * Define the current local position of the camera in the scene
  36003. */
  36004. position: Vector3;
  36005. protected _upVector: Vector3;
  36006. protected _upToYMatrix: Matrix;
  36007. protected _YToUpMatrix: Matrix;
  36008. /**
  36009. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36010. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36011. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36012. */
  36013. upVector: Vector3;
  36014. /**
  36015. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36016. */
  36017. setMatUp(): void;
  36018. /**
  36019. * Current inertia value on the longitudinal axis.
  36020. * The bigger this number the longer it will take for the camera to stop.
  36021. */
  36022. inertialAlphaOffset: number;
  36023. /**
  36024. * Current inertia value on the latitudinal axis.
  36025. * The bigger this number the longer it will take for the camera to stop.
  36026. */
  36027. inertialBetaOffset: number;
  36028. /**
  36029. * Current inertia value on the radius axis.
  36030. * The bigger this number the longer it will take for the camera to stop.
  36031. */
  36032. inertialRadiusOffset: number;
  36033. /**
  36034. * Minimum allowed angle on the longitudinal axis.
  36035. * This can help limiting how the Camera is able to move in the scene.
  36036. */
  36037. lowerAlphaLimit: Nullable<number>;
  36038. /**
  36039. * Maximum allowed angle on the longitudinal axis.
  36040. * This can help limiting how the Camera is able to move in the scene.
  36041. */
  36042. upperAlphaLimit: Nullable<number>;
  36043. /**
  36044. * Minimum allowed angle on the latitudinal axis.
  36045. * This can help limiting how the Camera is able to move in the scene.
  36046. */
  36047. lowerBetaLimit: number;
  36048. /**
  36049. * Maximum allowed angle on the latitudinal axis.
  36050. * This can help limiting how the Camera is able to move in the scene.
  36051. */
  36052. upperBetaLimit: number;
  36053. /**
  36054. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36055. * This can help limiting how the Camera is able to move in the scene.
  36056. */
  36057. lowerRadiusLimit: Nullable<number>;
  36058. /**
  36059. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36060. * This can help limiting how the Camera is able to move in the scene.
  36061. */
  36062. upperRadiusLimit: Nullable<number>;
  36063. /**
  36064. * Defines the current inertia value used during panning of the camera along the X axis.
  36065. */
  36066. inertialPanningX: number;
  36067. /**
  36068. * Defines the current inertia value used during panning of the camera along the Y axis.
  36069. */
  36070. inertialPanningY: number;
  36071. /**
  36072. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36073. * Basically if your fingers moves away from more than this distance you will be considered
  36074. * in pinch mode.
  36075. */
  36076. pinchToPanMaxDistance: number;
  36077. /**
  36078. * Defines the maximum distance the camera can pan.
  36079. * This could help keeping the cammera always in your scene.
  36080. */
  36081. panningDistanceLimit: Nullable<number>;
  36082. /**
  36083. * Defines the target of the camera before paning.
  36084. */
  36085. panningOriginTarget: Vector3;
  36086. /**
  36087. * Defines the value of the inertia used during panning.
  36088. * 0 would mean stop inertia and one would mean no decelleration at all.
  36089. */
  36090. panningInertia: number;
  36091. /**
  36092. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36093. */
  36094. angularSensibilityX: number;
  36095. /**
  36096. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36097. */
  36098. angularSensibilityY: number;
  36099. /**
  36100. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36101. */
  36102. pinchPrecision: number;
  36103. /**
  36104. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36105. * It will be used instead of pinchDeltaPrecision if different from 0.
  36106. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36107. */
  36108. pinchDeltaPercentage: number;
  36109. /**
  36110. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36111. */
  36112. panningSensibility: number;
  36113. /**
  36114. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36115. */
  36116. keysUp: number[];
  36117. /**
  36118. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36119. */
  36120. keysDown: number[];
  36121. /**
  36122. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36123. */
  36124. keysLeft: number[];
  36125. /**
  36126. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36127. */
  36128. keysRight: number[];
  36129. /**
  36130. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36131. */
  36132. wheelPrecision: number;
  36133. /**
  36134. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36135. * It will be used instead of pinchDeltaPrecision if different from 0.
  36136. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36137. */
  36138. wheelDeltaPercentage: number;
  36139. /**
  36140. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36141. */
  36142. zoomOnFactor: number;
  36143. /**
  36144. * Defines a screen offset for the camera position.
  36145. */
  36146. targetScreenOffset: Vector2;
  36147. /**
  36148. * Allows the camera to be completely reversed.
  36149. * If false the camera can not arrive upside down.
  36150. */
  36151. allowUpsideDown: boolean;
  36152. /**
  36153. * Define if double tap/click is used to restore the previously saved state of the camera.
  36154. */
  36155. useInputToRestoreState: boolean;
  36156. /** @hidden */
  36157. _viewMatrix: Matrix;
  36158. /** @hidden */
  36159. _useCtrlForPanning: boolean;
  36160. /** @hidden */
  36161. _panningMouseButton: number;
  36162. /**
  36163. * Defines the input associated to the camera.
  36164. */
  36165. inputs: ArcRotateCameraInputsManager;
  36166. /** @hidden */
  36167. _reset: () => void;
  36168. /**
  36169. * Defines the allowed panning axis.
  36170. */
  36171. panningAxis: Vector3;
  36172. protected _localDirection: Vector3;
  36173. protected _transformedDirection: Vector3;
  36174. private _bouncingBehavior;
  36175. /**
  36176. * Gets the bouncing behavior of the camera if it has been enabled.
  36177. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36178. */
  36179. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36180. /**
  36181. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36182. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36183. */
  36184. useBouncingBehavior: boolean;
  36185. private _framingBehavior;
  36186. /**
  36187. * Gets the framing behavior of the camera if it has been enabled.
  36188. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36189. */
  36190. readonly framingBehavior: Nullable<FramingBehavior>;
  36191. /**
  36192. * Defines if the framing behavior of the camera is enabled on the camera.
  36193. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36194. */
  36195. useFramingBehavior: boolean;
  36196. private _autoRotationBehavior;
  36197. /**
  36198. * Gets the auto rotation behavior of the camera if it has been enabled.
  36199. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36200. */
  36201. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36202. /**
  36203. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36204. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36205. */
  36206. useAutoRotationBehavior: boolean;
  36207. /**
  36208. * Observable triggered when the mesh target has been changed on the camera.
  36209. */
  36210. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36211. /**
  36212. * Event raised when the camera is colliding with a mesh.
  36213. */
  36214. onCollide: (collidedMesh: AbstractMesh) => void;
  36215. /**
  36216. * Defines whether the camera should check collision with the objects oh the scene.
  36217. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36218. */
  36219. checkCollisions: boolean;
  36220. /**
  36221. * Defines the collision radius of the camera.
  36222. * This simulates a sphere around the camera.
  36223. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36224. */
  36225. collisionRadius: Vector3;
  36226. protected _collider: Collider;
  36227. protected _previousPosition: Vector3;
  36228. protected _collisionVelocity: Vector3;
  36229. protected _newPosition: Vector3;
  36230. protected _previousAlpha: number;
  36231. protected _previousBeta: number;
  36232. protected _previousRadius: number;
  36233. protected _collisionTriggered: boolean;
  36234. protected _targetBoundingCenter: Nullable<Vector3>;
  36235. private _computationVector;
  36236. /**
  36237. * Instantiates a new ArcRotateCamera in a given scene
  36238. * @param name Defines the name of the camera
  36239. * @param alpha Defines the camera rotation along the logitudinal axis
  36240. * @param beta Defines the camera rotation along the latitudinal axis
  36241. * @param radius Defines the camera distance from its target
  36242. * @param target Defines the camera target
  36243. * @param scene Defines the scene the camera belongs to
  36244. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36245. */
  36246. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36247. /** @hidden */
  36248. _initCache(): void;
  36249. /** @hidden */
  36250. _updateCache(ignoreParentClass?: boolean): void;
  36251. protected _getTargetPosition(): Vector3;
  36252. private _storedAlpha;
  36253. private _storedBeta;
  36254. private _storedRadius;
  36255. private _storedTarget;
  36256. /**
  36257. * Stores the current state of the camera (alpha, beta, radius and target)
  36258. * @returns the camera itself
  36259. */
  36260. storeState(): Camera;
  36261. /**
  36262. * @hidden
  36263. * Restored camera state. You must call storeState() first
  36264. */
  36265. _restoreStateValues(): boolean;
  36266. /** @hidden */
  36267. _isSynchronizedViewMatrix(): boolean;
  36268. /**
  36269. * Attached controls to the current camera.
  36270. * @param element Defines the element the controls should be listened from
  36271. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36272. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36273. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36274. */
  36275. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36276. /**
  36277. * Detach the current controls from the camera.
  36278. * The camera will stop reacting to inputs.
  36279. * @param element Defines the element to stop listening the inputs from
  36280. */
  36281. detachControl(element: HTMLElement): void;
  36282. /** @hidden */
  36283. _checkInputs(): void;
  36284. protected _checkLimits(): void;
  36285. /**
  36286. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36287. */
  36288. rebuildAnglesAndRadius(): void;
  36289. /**
  36290. * Use a position to define the current camera related information like aplha, beta and radius
  36291. * @param position Defines the position to set the camera at
  36292. */
  36293. setPosition(position: Vector3): void;
  36294. /**
  36295. * Defines the target the camera should look at.
  36296. * This will automatically adapt alpha beta and radius to fit within the new target.
  36297. * @param target Defines the new target as a Vector or a mesh
  36298. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36299. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36300. */
  36301. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36302. /** @hidden */
  36303. _getViewMatrix(): Matrix;
  36304. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36305. /**
  36306. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36307. * @param meshes Defines the mesh to zoom on
  36308. * @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)
  36309. */
  36310. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36311. /**
  36312. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36313. * The target will be changed but the radius
  36314. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36315. * @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)
  36316. */
  36317. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36318. min: Vector3;
  36319. max: Vector3;
  36320. distance: number;
  36321. }, doNotUpdateMaxZ?: boolean): void;
  36322. /**
  36323. * @override
  36324. * Override Camera.createRigCamera
  36325. */
  36326. createRigCamera(name: string, cameraIndex: number): Camera;
  36327. /**
  36328. * @hidden
  36329. * @override
  36330. * Override Camera._updateRigCameras
  36331. */
  36332. _updateRigCameras(): void;
  36333. /**
  36334. * Destroy the camera and release the current resources hold by it.
  36335. */
  36336. dispose(): void;
  36337. /**
  36338. * Gets the current object class name.
  36339. * @return the class name
  36340. */
  36341. getClassName(): string;
  36342. }
  36343. }
  36344. declare module BABYLON {
  36345. /**
  36346. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36347. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36348. */
  36349. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36350. /**
  36351. * Gets the name of the behavior.
  36352. */
  36353. readonly name: string;
  36354. private _zoomStopsAnimation;
  36355. private _idleRotationSpeed;
  36356. private _idleRotationWaitTime;
  36357. private _idleRotationSpinupTime;
  36358. /**
  36359. * Sets the flag that indicates if user zooming should stop animation.
  36360. */
  36361. /**
  36362. * Gets the flag that indicates if user zooming should stop animation.
  36363. */
  36364. zoomStopsAnimation: boolean;
  36365. /**
  36366. * Sets the default speed at which the camera rotates around the model.
  36367. */
  36368. /**
  36369. * Gets the default speed at which the camera rotates around the model.
  36370. */
  36371. idleRotationSpeed: number;
  36372. /**
  36373. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36374. */
  36375. /**
  36376. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36377. */
  36378. idleRotationWaitTime: number;
  36379. /**
  36380. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36381. */
  36382. /**
  36383. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36384. */
  36385. idleRotationSpinupTime: number;
  36386. /**
  36387. * Gets a value indicating if the camera is currently rotating because of this behavior
  36388. */
  36389. readonly rotationInProgress: boolean;
  36390. private _onPrePointerObservableObserver;
  36391. private _onAfterCheckInputsObserver;
  36392. private _attachedCamera;
  36393. private _isPointerDown;
  36394. private _lastFrameTime;
  36395. private _lastInteractionTime;
  36396. private _cameraRotationSpeed;
  36397. /**
  36398. * Initializes the behavior.
  36399. */
  36400. init(): void;
  36401. /**
  36402. * Attaches the behavior to its arc rotate camera.
  36403. * @param camera Defines the camera to attach the behavior to
  36404. */
  36405. attach(camera: ArcRotateCamera): void;
  36406. /**
  36407. * Detaches the behavior from its current arc rotate camera.
  36408. */
  36409. detach(): void;
  36410. /**
  36411. * Returns true if user is scrolling.
  36412. * @return true if user is scrolling.
  36413. */
  36414. private _userIsZooming;
  36415. private _lastFrameRadius;
  36416. private _shouldAnimationStopForInteraction;
  36417. /**
  36418. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36419. */
  36420. private _applyUserInteraction;
  36421. private _userIsMoving;
  36422. }
  36423. }
  36424. declare module BABYLON {
  36425. /**
  36426. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36427. */
  36428. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36429. private ui;
  36430. /**
  36431. * The name of the behavior
  36432. */
  36433. name: string;
  36434. /**
  36435. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36436. */
  36437. distanceAwayFromFace: number;
  36438. /**
  36439. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36440. */
  36441. distanceAwayFromBottomOfFace: number;
  36442. private _faceVectors;
  36443. private _target;
  36444. private _scene;
  36445. private _onRenderObserver;
  36446. private _tmpMatrix;
  36447. private _tmpVector;
  36448. /**
  36449. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36450. * @param ui The transform node that should be attched to the mesh
  36451. */
  36452. constructor(ui: TransformNode);
  36453. /**
  36454. * Initializes the behavior
  36455. */
  36456. init(): void;
  36457. private _closestFace;
  36458. private _zeroVector;
  36459. private _lookAtTmpMatrix;
  36460. private _lookAtToRef;
  36461. /**
  36462. * Attaches the AttachToBoxBehavior to the passed in mesh
  36463. * @param target The mesh that the specified node will be attached to
  36464. */
  36465. attach(target: Mesh): void;
  36466. /**
  36467. * Detaches the behavior from the mesh
  36468. */
  36469. detach(): void;
  36470. }
  36471. }
  36472. declare module BABYLON {
  36473. /**
  36474. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36475. */
  36476. export class FadeInOutBehavior implements Behavior<Mesh> {
  36477. /**
  36478. * Time in milliseconds to delay before fading in (Default: 0)
  36479. */
  36480. delay: number;
  36481. /**
  36482. * Time in milliseconds for the mesh to fade in (Default: 300)
  36483. */
  36484. fadeInTime: number;
  36485. private _millisecondsPerFrame;
  36486. private _hovered;
  36487. private _hoverValue;
  36488. private _ownerNode;
  36489. /**
  36490. * Instatiates the FadeInOutBehavior
  36491. */
  36492. constructor();
  36493. /**
  36494. * The name of the behavior
  36495. */
  36496. readonly name: string;
  36497. /**
  36498. * Initializes the behavior
  36499. */
  36500. init(): void;
  36501. /**
  36502. * Attaches the fade behavior on the passed in mesh
  36503. * @param ownerNode The mesh that will be faded in/out once attached
  36504. */
  36505. attach(ownerNode: Mesh): void;
  36506. /**
  36507. * Detaches the behavior from the mesh
  36508. */
  36509. detach(): void;
  36510. /**
  36511. * Triggers the mesh to begin fading in or out
  36512. * @param value if the object should fade in or out (true to fade in)
  36513. */
  36514. fadeIn(value: boolean): void;
  36515. private _update;
  36516. private _setAllVisibility;
  36517. }
  36518. }
  36519. declare module BABYLON {
  36520. /**
  36521. * Class containing a set of static utilities functions for managing Pivots
  36522. * @hidden
  36523. */
  36524. export class PivotTools {
  36525. private static _PivotCached;
  36526. private static _OldPivotPoint;
  36527. private static _PivotTranslation;
  36528. private static _PivotTmpVector;
  36529. /** @hidden */
  36530. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36531. /** @hidden */
  36532. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36533. }
  36534. }
  36535. declare module BABYLON {
  36536. /**
  36537. * Class containing static functions to help procedurally build meshes
  36538. */
  36539. export class PlaneBuilder {
  36540. /**
  36541. * Creates a plane mesh
  36542. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36543. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36544. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36545. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36546. * * 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
  36547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36548. * @param name defines the name of the mesh
  36549. * @param options defines the options used to create the mesh
  36550. * @param scene defines the hosting scene
  36551. * @returns the plane mesh
  36552. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36553. */
  36554. static CreatePlane(name: string, options: {
  36555. size?: number;
  36556. width?: number;
  36557. height?: number;
  36558. sideOrientation?: number;
  36559. frontUVs?: Vector4;
  36560. backUVs?: Vector4;
  36561. updatable?: boolean;
  36562. sourcePlane?: Plane;
  36563. }, scene?: Nullable<Scene>): Mesh;
  36564. }
  36565. }
  36566. declare module BABYLON {
  36567. /**
  36568. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36569. */
  36570. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36571. private static _AnyMouseID;
  36572. /**
  36573. * Abstract mesh the behavior is set on
  36574. */
  36575. attachedNode: AbstractMesh;
  36576. private _dragPlane;
  36577. private _scene;
  36578. private _pointerObserver;
  36579. private _beforeRenderObserver;
  36580. private static _planeScene;
  36581. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36582. /**
  36583. * 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)
  36584. */
  36585. maxDragAngle: number;
  36586. /**
  36587. * @hidden
  36588. */
  36589. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36590. /**
  36591. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36592. */
  36593. currentDraggingPointerID: number;
  36594. /**
  36595. * The last position where the pointer hit the drag plane in world space
  36596. */
  36597. lastDragPosition: Vector3;
  36598. /**
  36599. * If the behavior is currently in a dragging state
  36600. */
  36601. dragging: boolean;
  36602. /**
  36603. * 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)
  36604. */
  36605. dragDeltaRatio: number;
  36606. /**
  36607. * If the drag plane orientation should be updated during the dragging (Default: true)
  36608. */
  36609. updateDragPlane: boolean;
  36610. private _debugMode;
  36611. private _moving;
  36612. /**
  36613. * Fires each time the attached mesh is dragged with the pointer
  36614. * * delta between last drag position and current drag position in world space
  36615. * * dragDistance along the drag axis
  36616. * * dragPlaneNormal normal of the current drag plane used during the drag
  36617. * * dragPlanePoint in world space where the drag intersects the drag plane
  36618. */
  36619. onDragObservable: Observable<{
  36620. delta: Vector3;
  36621. dragPlanePoint: Vector3;
  36622. dragPlaneNormal: Vector3;
  36623. dragDistance: number;
  36624. pointerId: number;
  36625. }>;
  36626. /**
  36627. * Fires each time a drag begins (eg. mouse down on mesh)
  36628. */
  36629. onDragStartObservable: Observable<{
  36630. dragPlanePoint: Vector3;
  36631. pointerId: number;
  36632. }>;
  36633. /**
  36634. * Fires each time a drag ends (eg. mouse release after drag)
  36635. */
  36636. onDragEndObservable: Observable<{
  36637. dragPlanePoint: Vector3;
  36638. pointerId: number;
  36639. }>;
  36640. /**
  36641. * If the attached mesh should be moved when dragged
  36642. */
  36643. moveAttached: boolean;
  36644. /**
  36645. * If the drag behavior will react to drag events (Default: true)
  36646. */
  36647. enabled: boolean;
  36648. /**
  36649. * If pointer events should start and release the drag (Default: true)
  36650. */
  36651. startAndReleaseDragOnPointerEvents: boolean;
  36652. /**
  36653. * If camera controls should be detached during the drag
  36654. */
  36655. detachCameraControls: boolean;
  36656. /**
  36657. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36658. */
  36659. useObjectOrienationForDragging: boolean;
  36660. private _options;
  36661. /**
  36662. * Creates a pointer drag behavior that can be attached to a mesh
  36663. * @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)
  36664. */
  36665. constructor(options?: {
  36666. dragAxis?: Vector3;
  36667. dragPlaneNormal?: Vector3;
  36668. });
  36669. /**
  36670. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36671. */
  36672. validateDrag: (targetPosition: Vector3) => boolean;
  36673. /**
  36674. * The name of the behavior
  36675. */
  36676. readonly name: string;
  36677. /**
  36678. * Initializes the behavior
  36679. */
  36680. init(): void;
  36681. private _tmpVector;
  36682. private _alternatePickedPoint;
  36683. private _worldDragAxis;
  36684. private _targetPosition;
  36685. private _attachedElement;
  36686. /**
  36687. * Attaches the drag behavior the passed in mesh
  36688. * @param ownerNode The mesh that will be dragged around once attached
  36689. */
  36690. attach(ownerNode: AbstractMesh): void;
  36691. /**
  36692. * Force relase the drag action by code.
  36693. */
  36694. releaseDrag(): void;
  36695. private _startDragRay;
  36696. private _lastPointerRay;
  36697. /**
  36698. * Simulates the start of a pointer drag event on the behavior
  36699. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36700. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36701. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36702. */
  36703. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36704. private _startDrag;
  36705. private _dragDelta;
  36706. private _moveDrag;
  36707. private _pickWithRayOnDragPlane;
  36708. private _pointA;
  36709. private _pointB;
  36710. private _pointC;
  36711. private _lineA;
  36712. private _lineB;
  36713. private _localAxis;
  36714. private _lookAt;
  36715. private _updateDragPlanePosition;
  36716. /**
  36717. * Detaches the behavior from the mesh
  36718. */
  36719. detach(): void;
  36720. }
  36721. }
  36722. declare module BABYLON {
  36723. /**
  36724. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36725. */
  36726. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36727. private _dragBehaviorA;
  36728. private _dragBehaviorB;
  36729. private _startDistance;
  36730. private _initialScale;
  36731. private _targetScale;
  36732. private _ownerNode;
  36733. private _sceneRenderObserver;
  36734. /**
  36735. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36736. */
  36737. constructor();
  36738. /**
  36739. * The name of the behavior
  36740. */
  36741. readonly name: string;
  36742. /**
  36743. * Initializes the behavior
  36744. */
  36745. init(): void;
  36746. private _getCurrentDistance;
  36747. /**
  36748. * Attaches the scale behavior the passed in mesh
  36749. * @param ownerNode The mesh that will be scaled around once attached
  36750. */
  36751. attach(ownerNode: Mesh): void;
  36752. /**
  36753. * Detaches the behavior from the mesh
  36754. */
  36755. detach(): void;
  36756. }
  36757. }
  36758. declare module BABYLON {
  36759. /**
  36760. * 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
  36761. */
  36762. export class SixDofDragBehavior implements Behavior<Mesh> {
  36763. private static _virtualScene;
  36764. private _ownerNode;
  36765. private _sceneRenderObserver;
  36766. private _scene;
  36767. private _targetPosition;
  36768. private _virtualOriginMesh;
  36769. private _virtualDragMesh;
  36770. private _pointerObserver;
  36771. private _moving;
  36772. private _startingOrientation;
  36773. /**
  36774. * 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)
  36775. */
  36776. private zDragFactor;
  36777. /**
  36778. * If the object should rotate to face the drag origin
  36779. */
  36780. rotateDraggedObject: boolean;
  36781. /**
  36782. * If the behavior is currently in a dragging state
  36783. */
  36784. dragging: boolean;
  36785. /**
  36786. * 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)
  36787. */
  36788. dragDeltaRatio: number;
  36789. /**
  36790. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36791. */
  36792. currentDraggingPointerID: number;
  36793. /**
  36794. * If camera controls should be detached during the drag
  36795. */
  36796. detachCameraControls: boolean;
  36797. /**
  36798. * Fires each time a drag starts
  36799. */
  36800. onDragStartObservable: Observable<{}>;
  36801. /**
  36802. * Fires each time a drag ends (eg. mouse release after drag)
  36803. */
  36804. onDragEndObservable: Observable<{}>;
  36805. /**
  36806. * 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
  36807. */
  36808. constructor();
  36809. /**
  36810. * The name of the behavior
  36811. */
  36812. readonly name: string;
  36813. /**
  36814. * Initializes the behavior
  36815. */
  36816. init(): void;
  36817. /**
  36818. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36819. */
  36820. private readonly _pointerCamera;
  36821. /**
  36822. * Attaches the scale behavior the passed in mesh
  36823. * @param ownerNode The mesh that will be scaled around once attached
  36824. */
  36825. attach(ownerNode: Mesh): void;
  36826. /**
  36827. * Detaches the behavior from the mesh
  36828. */
  36829. detach(): void;
  36830. }
  36831. }
  36832. declare module BABYLON {
  36833. /**
  36834. * Class used to apply inverse kinematics to bones
  36835. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36836. */
  36837. export class BoneIKController {
  36838. private static _tmpVecs;
  36839. private static _tmpQuat;
  36840. private static _tmpMats;
  36841. /**
  36842. * Gets or sets the target mesh
  36843. */
  36844. targetMesh: AbstractMesh;
  36845. /** Gets or sets the mesh used as pole */
  36846. poleTargetMesh: AbstractMesh;
  36847. /**
  36848. * Gets or sets the bone used as pole
  36849. */
  36850. poleTargetBone: Nullable<Bone>;
  36851. /**
  36852. * Gets or sets the target position
  36853. */
  36854. targetPosition: Vector3;
  36855. /**
  36856. * Gets or sets the pole target position
  36857. */
  36858. poleTargetPosition: Vector3;
  36859. /**
  36860. * Gets or sets the pole target local offset
  36861. */
  36862. poleTargetLocalOffset: Vector3;
  36863. /**
  36864. * Gets or sets the pole angle
  36865. */
  36866. poleAngle: number;
  36867. /**
  36868. * Gets or sets the mesh associated with the controller
  36869. */
  36870. mesh: AbstractMesh;
  36871. /**
  36872. * 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)
  36873. */
  36874. slerpAmount: number;
  36875. private _bone1Quat;
  36876. private _bone1Mat;
  36877. private _bone2Ang;
  36878. private _bone1;
  36879. private _bone2;
  36880. private _bone1Length;
  36881. private _bone2Length;
  36882. private _maxAngle;
  36883. private _maxReach;
  36884. private _rightHandedSystem;
  36885. private _bendAxis;
  36886. private _slerping;
  36887. private _adjustRoll;
  36888. /**
  36889. * Gets or sets maximum allowed angle
  36890. */
  36891. maxAngle: number;
  36892. /**
  36893. * Creates a new BoneIKController
  36894. * @param mesh defines the mesh to control
  36895. * @param bone defines the bone to control
  36896. * @param options defines options to set up the controller
  36897. */
  36898. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36899. targetMesh?: AbstractMesh;
  36900. poleTargetMesh?: AbstractMesh;
  36901. poleTargetBone?: Bone;
  36902. poleTargetLocalOffset?: Vector3;
  36903. poleAngle?: number;
  36904. bendAxis?: Vector3;
  36905. maxAngle?: number;
  36906. slerpAmount?: number;
  36907. });
  36908. private _setMaxAngle;
  36909. /**
  36910. * Force the controller to update the bones
  36911. */
  36912. update(): void;
  36913. }
  36914. }
  36915. declare module BABYLON {
  36916. /**
  36917. * Class used to make a bone look toward a point in space
  36918. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36919. */
  36920. export class BoneLookController {
  36921. private static _tmpVecs;
  36922. private static _tmpQuat;
  36923. private static _tmpMats;
  36924. /**
  36925. * The target Vector3 that the bone will look at
  36926. */
  36927. target: Vector3;
  36928. /**
  36929. * The mesh that the bone is attached to
  36930. */
  36931. mesh: AbstractMesh;
  36932. /**
  36933. * The bone that will be looking to the target
  36934. */
  36935. bone: Bone;
  36936. /**
  36937. * The up axis of the coordinate system that is used when the bone is rotated
  36938. */
  36939. upAxis: Vector3;
  36940. /**
  36941. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36942. */
  36943. upAxisSpace: Space;
  36944. /**
  36945. * Used to make an adjustment to the yaw of the bone
  36946. */
  36947. adjustYaw: number;
  36948. /**
  36949. * Used to make an adjustment to the pitch of the bone
  36950. */
  36951. adjustPitch: number;
  36952. /**
  36953. * Used to make an adjustment to the roll of the bone
  36954. */
  36955. adjustRoll: number;
  36956. /**
  36957. * 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)
  36958. */
  36959. slerpAmount: number;
  36960. private _minYaw;
  36961. private _maxYaw;
  36962. private _minPitch;
  36963. private _maxPitch;
  36964. private _minYawSin;
  36965. private _minYawCos;
  36966. private _maxYawSin;
  36967. private _maxYawCos;
  36968. private _midYawConstraint;
  36969. private _minPitchTan;
  36970. private _maxPitchTan;
  36971. private _boneQuat;
  36972. private _slerping;
  36973. private _transformYawPitch;
  36974. private _transformYawPitchInv;
  36975. private _firstFrameSkipped;
  36976. private _yawRange;
  36977. private _fowardAxis;
  36978. /**
  36979. * Gets or sets the minimum yaw angle that the bone can look to
  36980. */
  36981. minYaw: number;
  36982. /**
  36983. * Gets or sets the maximum yaw angle that the bone can look to
  36984. */
  36985. maxYaw: number;
  36986. /**
  36987. * Gets or sets the minimum pitch angle that the bone can look to
  36988. */
  36989. minPitch: number;
  36990. /**
  36991. * Gets or sets the maximum pitch angle that the bone can look to
  36992. */
  36993. maxPitch: number;
  36994. /**
  36995. * Create a BoneLookController
  36996. * @param mesh the mesh that the bone belongs to
  36997. * @param bone the bone that will be looking to the target
  36998. * @param target the target Vector3 to look at
  36999. * @param options optional settings:
  37000. * * maxYaw: the maximum angle the bone will yaw to
  37001. * * minYaw: the minimum angle the bone will yaw to
  37002. * * maxPitch: the maximum angle the bone will pitch to
  37003. * * minPitch: the minimum angle the bone will yaw to
  37004. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37005. * * upAxis: the up axis of the coordinate system
  37006. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37007. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37008. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37009. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37010. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37011. * * adjustRoll: used to make an adjustment to the roll of the bone
  37012. **/
  37013. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37014. maxYaw?: number;
  37015. minYaw?: number;
  37016. maxPitch?: number;
  37017. minPitch?: number;
  37018. slerpAmount?: number;
  37019. upAxis?: Vector3;
  37020. upAxisSpace?: Space;
  37021. yawAxis?: Vector3;
  37022. pitchAxis?: Vector3;
  37023. adjustYaw?: number;
  37024. adjustPitch?: number;
  37025. adjustRoll?: number;
  37026. });
  37027. /**
  37028. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37029. */
  37030. update(): void;
  37031. private _getAngleDiff;
  37032. private _getAngleBetween;
  37033. private _isAngleBetween;
  37034. }
  37035. }
  37036. declare module BABYLON {
  37037. /**
  37038. * Manage the gamepad inputs to control an arc rotate camera.
  37039. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37040. */
  37041. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37042. /**
  37043. * Defines the camera the input is attached to.
  37044. */
  37045. camera: ArcRotateCamera;
  37046. /**
  37047. * Defines the gamepad the input is gathering event from.
  37048. */
  37049. gamepad: Nullable<Gamepad>;
  37050. /**
  37051. * Defines the gamepad rotation sensiblity.
  37052. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37053. */
  37054. gamepadRotationSensibility: number;
  37055. /**
  37056. * Defines the gamepad move sensiblity.
  37057. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37058. */
  37059. gamepadMoveSensibility: number;
  37060. private _onGamepadConnectedObserver;
  37061. private _onGamepadDisconnectedObserver;
  37062. /**
  37063. * Attach the input controls to a specific dom element to get the input from.
  37064. * @param element Defines the element the controls should be listened from
  37065. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37066. */
  37067. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37068. /**
  37069. * Detach the current controls from the specified dom element.
  37070. * @param element Defines the element to stop listening the inputs from
  37071. */
  37072. detachControl(element: Nullable<HTMLElement>): void;
  37073. /**
  37074. * Update the current camera state depending on the inputs that have been used this frame.
  37075. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37076. */
  37077. checkInputs(): void;
  37078. /**
  37079. * Gets the class name of the current intput.
  37080. * @returns the class name
  37081. */
  37082. getClassName(): string;
  37083. /**
  37084. * Get the friendly name associated with the input class.
  37085. * @returns the input friendly name
  37086. */
  37087. getSimpleName(): string;
  37088. }
  37089. }
  37090. declare module BABYLON {
  37091. interface ArcRotateCameraInputsManager {
  37092. /**
  37093. * Add orientation input support to the input manager.
  37094. * @returns the current input manager
  37095. */
  37096. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37097. }
  37098. /**
  37099. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37100. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37101. */
  37102. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37103. /**
  37104. * Defines the camera the input is attached to.
  37105. */
  37106. camera: ArcRotateCamera;
  37107. /**
  37108. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37109. */
  37110. alphaCorrection: number;
  37111. /**
  37112. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37113. */
  37114. gammaCorrection: number;
  37115. private _alpha;
  37116. private _gamma;
  37117. private _dirty;
  37118. private _deviceOrientationHandler;
  37119. /**
  37120. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37121. */
  37122. constructor();
  37123. /**
  37124. * Attach the input controls to a specific dom element to get the input from.
  37125. * @param element Defines the element the controls should be listened from
  37126. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37127. */
  37128. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37129. /** @hidden */
  37130. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37131. /**
  37132. * Update the current camera state depending on the inputs that have been used this frame.
  37133. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37134. */
  37135. checkInputs(): void;
  37136. /**
  37137. * Detach the current controls from the specified dom element.
  37138. * @param element Defines the element to stop listening the inputs from
  37139. */
  37140. detachControl(element: Nullable<HTMLElement>): void;
  37141. /**
  37142. * Gets the class name of the current intput.
  37143. * @returns the class name
  37144. */
  37145. getClassName(): string;
  37146. /**
  37147. * Get the friendly name associated with the input class.
  37148. * @returns the input friendly name
  37149. */
  37150. getSimpleName(): string;
  37151. }
  37152. }
  37153. declare module BABYLON {
  37154. /**
  37155. * Listen to mouse events to control the camera.
  37156. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37157. */
  37158. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37159. /**
  37160. * Defines the camera the input is attached to.
  37161. */
  37162. camera: FlyCamera;
  37163. /**
  37164. * Defines if touch is enabled. (Default is true.)
  37165. */
  37166. touchEnabled: boolean;
  37167. /**
  37168. * Defines the buttons associated with the input to handle camera rotation.
  37169. */
  37170. buttons: number[];
  37171. /**
  37172. * Assign buttons for Yaw control.
  37173. */
  37174. buttonsYaw: number[];
  37175. /**
  37176. * Assign buttons for Pitch control.
  37177. */
  37178. buttonsPitch: number[];
  37179. /**
  37180. * Assign buttons for Roll control.
  37181. */
  37182. buttonsRoll: number[];
  37183. /**
  37184. * Detect if any button is being pressed while mouse is moved.
  37185. * -1 = Mouse locked.
  37186. * 0 = Left button.
  37187. * 1 = Middle Button.
  37188. * 2 = Right Button.
  37189. */
  37190. activeButton: number;
  37191. /**
  37192. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37193. * Higher values reduce its sensitivity.
  37194. */
  37195. angularSensibility: number;
  37196. private _mousemoveCallback;
  37197. private _observer;
  37198. private _rollObserver;
  37199. private previousPosition;
  37200. private noPreventDefault;
  37201. private element;
  37202. /**
  37203. * Listen to mouse events to control the camera.
  37204. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37205. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37206. */
  37207. constructor(touchEnabled?: boolean);
  37208. /**
  37209. * Attach the mouse control to the HTML DOM element.
  37210. * @param element Defines the element that listens to the input events.
  37211. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37212. */
  37213. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37214. /**
  37215. * Detach the current controls from the specified dom element.
  37216. * @param element Defines the element to stop listening the inputs from
  37217. */
  37218. detachControl(element: Nullable<HTMLElement>): void;
  37219. /**
  37220. * Gets the class name of the current input.
  37221. * @returns the class name.
  37222. */
  37223. getClassName(): string;
  37224. /**
  37225. * Get the friendly name associated with the input class.
  37226. * @returns the input's friendly name.
  37227. */
  37228. getSimpleName(): string;
  37229. private _pointerInput;
  37230. private _onMouseMove;
  37231. /**
  37232. * Rotate camera by mouse offset.
  37233. */
  37234. private rotateCamera;
  37235. }
  37236. }
  37237. declare module BABYLON {
  37238. /**
  37239. * Default Inputs manager for the FlyCamera.
  37240. * It groups all the default supported inputs for ease of use.
  37241. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37242. */
  37243. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37244. /**
  37245. * Instantiates a new FlyCameraInputsManager.
  37246. * @param camera Defines the camera the inputs belong to.
  37247. */
  37248. constructor(camera: FlyCamera);
  37249. /**
  37250. * Add keyboard input support to the input manager.
  37251. * @returns the new FlyCameraKeyboardMoveInput().
  37252. */
  37253. addKeyboard(): FlyCameraInputsManager;
  37254. /**
  37255. * Add mouse input support to the input manager.
  37256. * @param touchEnabled Enable touch screen support.
  37257. * @returns the new FlyCameraMouseInput().
  37258. */
  37259. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37260. }
  37261. }
  37262. declare module BABYLON {
  37263. /**
  37264. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37265. * such as in a 3D Space Shooter or a Flight Simulator.
  37266. */
  37267. export class FlyCamera extends TargetCamera {
  37268. /**
  37269. * Define the collision ellipsoid of the camera.
  37270. * This is helpful for simulating a camera body, like a player's body.
  37271. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37272. */
  37273. ellipsoid: Vector3;
  37274. /**
  37275. * Define an offset for the position of the ellipsoid around the camera.
  37276. * This can be helpful if the camera is attached away from the player's body center,
  37277. * such as at its head.
  37278. */
  37279. ellipsoidOffset: Vector3;
  37280. /**
  37281. * Enable or disable collisions of the camera with the rest of the scene objects.
  37282. */
  37283. checkCollisions: boolean;
  37284. /**
  37285. * Enable or disable gravity on the camera.
  37286. */
  37287. applyGravity: boolean;
  37288. /**
  37289. * Define the current direction the camera is moving to.
  37290. */
  37291. cameraDirection: Vector3;
  37292. /**
  37293. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37294. * This overrides and empties cameraRotation.
  37295. */
  37296. rotationQuaternion: Quaternion;
  37297. /**
  37298. * Track Roll to maintain the wanted Rolling when looking around.
  37299. */
  37300. _trackRoll: number;
  37301. /**
  37302. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37303. */
  37304. rollCorrect: number;
  37305. /**
  37306. * Mimic a banked turn, Rolling the camera when Yawing.
  37307. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37308. */
  37309. bankedTurn: boolean;
  37310. /**
  37311. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37312. */
  37313. bankedTurnLimit: number;
  37314. /**
  37315. * Value of 0 disables the banked Roll.
  37316. * Value of 1 is equal to the Yaw angle in radians.
  37317. */
  37318. bankedTurnMultiplier: number;
  37319. /**
  37320. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37321. */
  37322. inputs: FlyCameraInputsManager;
  37323. /**
  37324. * Gets the input sensibility for mouse input.
  37325. * Higher values reduce sensitivity.
  37326. */
  37327. /**
  37328. * Sets the input sensibility for a mouse input.
  37329. * Higher values reduce sensitivity.
  37330. */
  37331. angularSensibility: number;
  37332. /**
  37333. * Get the keys for camera movement forward.
  37334. */
  37335. /**
  37336. * Set the keys for camera movement forward.
  37337. */
  37338. keysForward: number[];
  37339. /**
  37340. * Get the keys for camera movement backward.
  37341. */
  37342. keysBackward: number[];
  37343. /**
  37344. * Get the keys for camera movement up.
  37345. */
  37346. /**
  37347. * Set the keys for camera movement up.
  37348. */
  37349. keysUp: number[];
  37350. /**
  37351. * Get the keys for camera movement down.
  37352. */
  37353. /**
  37354. * Set the keys for camera movement down.
  37355. */
  37356. keysDown: number[];
  37357. /**
  37358. * Get the keys for camera movement left.
  37359. */
  37360. /**
  37361. * Set the keys for camera movement left.
  37362. */
  37363. keysLeft: number[];
  37364. /**
  37365. * Set the keys for camera movement right.
  37366. */
  37367. /**
  37368. * Set the keys for camera movement right.
  37369. */
  37370. keysRight: number[];
  37371. /**
  37372. * Event raised when the camera collides with a mesh in the scene.
  37373. */
  37374. onCollide: (collidedMesh: AbstractMesh) => void;
  37375. private _collider;
  37376. private _needMoveForGravity;
  37377. private _oldPosition;
  37378. private _diffPosition;
  37379. private _newPosition;
  37380. /** @hidden */
  37381. _localDirection: Vector3;
  37382. /** @hidden */
  37383. _transformedDirection: Vector3;
  37384. /**
  37385. * Instantiates a FlyCamera.
  37386. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37387. * such as in a 3D Space Shooter or a Flight Simulator.
  37388. * @param name Define the name of the camera in the scene.
  37389. * @param position Define the starting position of the camera in the scene.
  37390. * @param scene Define the scene the camera belongs to.
  37391. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37392. */
  37393. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37394. /**
  37395. * Attach a control to the HTML DOM element.
  37396. * @param element Defines the element that listens to the input events.
  37397. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37398. */
  37399. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37400. /**
  37401. * Detach a control from the HTML DOM element.
  37402. * The camera will stop reacting to that input.
  37403. * @param element Defines the element that listens to the input events.
  37404. */
  37405. detachControl(element: HTMLElement): void;
  37406. private _collisionMask;
  37407. /**
  37408. * Get the mask that the camera ignores in collision events.
  37409. */
  37410. /**
  37411. * Set the mask that the camera ignores in collision events.
  37412. */
  37413. collisionMask: number;
  37414. /** @hidden */
  37415. _collideWithWorld(displacement: Vector3): void;
  37416. /** @hidden */
  37417. private _onCollisionPositionChange;
  37418. /** @hidden */
  37419. _checkInputs(): void;
  37420. /** @hidden */
  37421. _decideIfNeedsToMove(): boolean;
  37422. /** @hidden */
  37423. _updatePosition(): void;
  37424. /**
  37425. * Restore the Roll to its target value at the rate specified.
  37426. * @param rate - Higher means slower restoring.
  37427. * @hidden
  37428. */
  37429. restoreRoll(rate: number): void;
  37430. /**
  37431. * Destroy the camera and release the current resources held by it.
  37432. */
  37433. dispose(): void;
  37434. /**
  37435. * Get the current object class name.
  37436. * @returns the class name.
  37437. */
  37438. getClassName(): string;
  37439. }
  37440. }
  37441. declare module BABYLON {
  37442. /**
  37443. * Listen to keyboard events to control the camera.
  37444. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37445. */
  37446. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37447. /**
  37448. * Defines the camera the input is attached to.
  37449. */
  37450. camera: FlyCamera;
  37451. /**
  37452. * The list of keyboard keys used to control the forward move of the camera.
  37453. */
  37454. keysForward: number[];
  37455. /**
  37456. * The list of keyboard keys used to control the backward move of the camera.
  37457. */
  37458. keysBackward: number[];
  37459. /**
  37460. * The list of keyboard keys used to control the forward move of the camera.
  37461. */
  37462. keysUp: number[];
  37463. /**
  37464. * The list of keyboard keys used to control the backward move of the camera.
  37465. */
  37466. keysDown: number[];
  37467. /**
  37468. * The list of keyboard keys used to control the right strafe move of the camera.
  37469. */
  37470. keysRight: number[];
  37471. /**
  37472. * The list of keyboard keys used to control the left strafe move of the camera.
  37473. */
  37474. keysLeft: number[];
  37475. private _keys;
  37476. private _onCanvasBlurObserver;
  37477. private _onKeyboardObserver;
  37478. private _engine;
  37479. private _scene;
  37480. /**
  37481. * Attach the input controls to a specific dom element to get the input from.
  37482. * @param element Defines the element the controls should be listened from
  37483. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37484. */
  37485. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37486. /**
  37487. * Detach the current controls from the specified dom element.
  37488. * @param element Defines the element to stop listening the inputs from
  37489. */
  37490. detachControl(element: Nullable<HTMLElement>): void;
  37491. /**
  37492. * Gets the class name of the current intput.
  37493. * @returns the class name
  37494. */
  37495. getClassName(): string;
  37496. /** @hidden */
  37497. _onLostFocus(e: FocusEvent): void;
  37498. /**
  37499. * Get the friendly name associated with the input class.
  37500. * @returns the input friendly name
  37501. */
  37502. getSimpleName(): string;
  37503. /**
  37504. * Update the current camera state depending on the inputs that have been used this frame.
  37505. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37506. */
  37507. checkInputs(): void;
  37508. }
  37509. }
  37510. declare module BABYLON {
  37511. /**
  37512. * Manage the mouse wheel inputs to control a follow camera.
  37513. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37514. */
  37515. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37516. /**
  37517. * Defines the camera the input is attached to.
  37518. */
  37519. camera: FollowCamera;
  37520. /**
  37521. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37522. */
  37523. axisControlRadius: boolean;
  37524. /**
  37525. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37526. */
  37527. axisControlHeight: boolean;
  37528. /**
  37529. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37530. */
  37531. axisControlRotation: boolean;
  37532. /**
  37533. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37534. * relation to mouseWheel events.
  37535. */
  37536. wheelPrecision: number;
  37537. /**
  37538. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37539. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37540. */
  37541. wheelDeltaPercentage: number;
  37542. private _wheel;
  37543. private _observer;
  37544. /**
  37545. * Attach the input controls to a specific dom element to get the input from.
  37546. * @param element Defines the element the controls should be listened from
  37547. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37548. */
  37549. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37550. /**
  37551. * Detach the current controls from the specified dom element.
  37552. * @param element Defines the element to stop listening the inputs from
  37553. */
  37554. detachControl(element: Nullable<HTMLElement>): void;
  37555. /**
  37556. * Gets the class name of the current intput.
  37557. * @returns the class name
  37558. */
  37559. getClassName(): string;
  37560. /**
  37561. * Get the friendly name associated with the input class.
  37562. * @returns the input friendly name
  37563. */
  37564. getSimpleName(): string;
  37565. }
  37566. }
  37567. declare module BABYLON {
  37568. /**
  37569. * Manage the pointers inputs to control an follow camera.
  37570. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37571. */
  37572. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37573. /**
  37574. * Defines the camera the input is attached to.
  37575. */
  37576. camera: FollowCamera;
  37577. /**
  37578. * Gets the class name of the current input.
  37579. * @returns the class name
  37580. */
  37581. getClassName(): string;
  37582. /**
  37583. * Defines the pointer angular sensibility along the X axis or how fast is
  37584. * the camera rotating.
  37585. * A negative number will reverse the axis direction.
  37586. */
  37587. angularSensibilityX: number;
  37588. /**
  37589. * Defines the pointer angular sensibility along the Y axis or how fast is
  37590. * the camera rotating.
  37591. * A negative number will reverse the axis direction.
  37592. */
  37593. angularSensibilityY: number;
  37594. /**
  37595. * Defines the pointer pinch precision or how fast is the camera zooming.
  37596. * A negative number will reverse the axis direction.
  37597. */
  37598. pinchPrecision: number;
  37599. /**
  37600. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37601. * from 0.
  37602. * It defines the percentage of current camera.radius to use as delta when
  37603. * pinch zoom is used.
  37604. */
  37605. pinchDeltaPercentage: number;
  37606. /**
  37607. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37608. */
  37609. axisXControlRadius: boolean;
  37610. /**
  37611. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37612. */
  37613. axisXControlHeight: boolean;
  37614. /**
  37615. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37616. */
  37617. axisXControlRotation: boolean;
  37618. /**
  37619. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37620. */
  37621. axisYControlRadius: boolean;
  37622. /**
  37623. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37624. */
  37625. axisYControlHeight: boolean;
  37626. /**
  37627. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37628. */
  37629. axisYControlRotation: boolean;
  37630. /**
  37631. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37632. */
  37633. axisPinchControlRadius: boolean;
  37634. /**
  37635. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37636. */
  37637. axisPinchControlHeight: boolean;
  37638. /**
  37639. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37640. */
  37641. axisPinchControlRotation: boolean;
  37642. /**
  37643. * Log error messages if basic misconfiguration has occurred.
  37644. */
  37645. warningEnable: boolean;
  37646. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37647. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37648. private _warningCounter;
  37649. private _warning;
  37650. }
  37651. }
  37652. declare module BABYLON {
  37653. /**
  37654. * Default Inputs manager for the FollowCamera.
  37655. * It groups all the default supported inputs for ease of use.
  37656. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37657. */
  37658. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37659. /**
  37660. * Instantiates a new FollowCameraInputsManager.
  37661. * @param camera Defines the camera the inputs belong to
  37662. */
  37663. constructor(camera: FollowCamera);
  37664. /**
  37665. * Add keyboard input support to the input manager.
  37666. * @returns the current input manager
  37667. */
  37668. addKeyboard(): FollowCameraInputsManager;
  37669. /**
  37670. * Add mouse wheel input support to the input manager.
  37671. * @returns the current input manager
  37672. */
  37673. addMouseWheel(): FollowCameraInputsManager;
  37674. /**
  37675. * Add pointers input support to the input manager.
  37676. * @returns the current input manager
  37677. */
  37678. addPointers(): FollowCameraInputsManager;
  37679. /**
  37680. * Add orientation input support to the input manager.
  37681. * @returns the current input manager
  37682. */
  37683. addVRDeviceOrientation(): FollowCameraInputsManager;
  37684. }
  37685. }
  37686. declare module BABYLON {
  37687. /**
  37688. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37689. * an arc rotate version arcFollowCamera are available.
  37690. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37691. */
  37692. export class FollowCamera extends TargetCamera {
  37693. /**
  37694. * Distance the follow camera should follow an object at
  37695. */
  37696. radius: number;
  37697. /**
  37698. * Minimum allowed distance of the camera to the axis of rotation
  37699. * (The camera can not get closer).
  37700. * This can help limiting how the Camera is able to move in the scene.
  37701. */
  37702. lowerRadiusLimit: Nullable<number>;
  37703. /**
  37704. * Maximum allowed distance of the camera to the axis of rotation
  37705. * (The camera can not get further).
  37706. * This can help limiting how the Camera is able to move in the scene.
  37707. */
  37708. upperRadiusLimit: Nullable<number>;
  37709. /**
  37710. * Define a rotation offset between the camera and the object it follows
  37711. */
  37712. rotationOffset: number;
  37713. /**
  37714. * Minimum allowed angle to camera position relative to target object.
  37715. * This can help limiting how the Camera is able to move in the scene.
  37716. */
  37717. lowerRotationOffsetLimit: Nullable<number>;
  37718. /**
  37719. * Maximum allowed angle to camera position relative to target object.
  37720. * This can help limiting how the Camera is able to move in the scene.
  37721. */
  37722. upperRotationOffsetLimit: Nullable<number>;
  37723. /**
  37724. * Define a height offset between the camera and the object it follows.
  37725. * It can help following an object from the top (like a car chaing a plane)
  37726. */
  37727. heightOffset: number;
  37728. /**
  37729. * Minimum allowed height of camera position relative to target object.
  37730. * This can help limiting how the Camera is able to move in the scene.
  37731. */
  37732. lowerHeightOffsetLimit: Nullable<number>;
  37733. /**
  37734. * Maximum allowed height of camera position relative to target object.
  37735. * This can help limiting how the Camera is able to move in the scene.
  37736. */
  37737. upperHeightOffsetLimit: Nullable<number>;
  37738. /**
  37739. * Define how fast the camera can accelerate to follow it s target.
  37740. */
  37741. cameraAcceleration: number;
  37742. /**
  37743. * Define the speed limit of the camera following an object.
  37744. */
  37745. maxCameraSpeed: number;
  37746. /**
  37747. * Define the target of the camera.
  37748. */
  37749. lockedTarget: Nullable<AbstractMesh>;
  37750. /**
  37751. * Defines the input associated with the camera.
  37752. */
  37753. inputs: FollowCameraInputsManager;
  37754. /**
  37755. * Instantiates the follow camera.
  37756. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37757. * @param name Define the name of the camera in the scene
  37758. * @param position Define the position of the camera
  37759. * @param scene Define the scene the camera belong to
  37760. * @param lockedTarget Define the target of the camera
  37761. */
  37762. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37763. private _follow;
  37764. /**
  37765. * Attached controls to the current camera.
  37766. * @param element Defines the element the controls should be listened from
  37767. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37768. */
  37769. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37770. /**
  37771. * Detach the current controls from the camera.
  37772. * The camera will stop reacting to inputs.
  37773. * @param element Defines the element to stop listening the inputs from
  37774. */
  37775. detachControl(element: HTMLElement): void;
  37776. /** @hidden */
  37777. _checkInputs(): void;
  37778. private _checkLimits;
  37779. /**
  37780. * Gets the camera class name.
  37781. * @returns the class name
  37782. */
  37783. getClassName(): string;
  37784. }
  37785. /**
  37786. * Arc Rotate version of the follow camera.
  37787. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37788. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37789. */
  37790. export class ArcFollowCamera extends TargetCamera {
  37791. /** The longitudinal angle of the camera */
  37792. alpha: number;
  37793. /** The latitudinal angle of the camera */
  37794. beta: number;
  37795. /** The radius of the camera from its target */
  37796. radius: number;
  37797. /** Define the camera target (the messh it should follow) */
  37798. target: Nullable<AbstractMesh>;
  37799. private _cartesianCoordinates;
  37800. /**
  37801. * Instantiates a new ArcFollowCamera
  37802. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37803. * @param name Define the name of the camera
  37804. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37805. * @param beta Define the rotation angle of the camera around the elevation axis
  37806. * @param radius Define the radius of the camera from its target point
  37807. * @param target Define the target of the camera
  37808. * @param scene Define the scene the camera belongs to
  37809. */
  37810. constructor(name: string,
  37811. /** The longitudinal angle of the camera */
  37812. alpha: number,
  37813. /** The latitudinal angle of the camera */
  37814. beta: number,
  37815. /** The radius of the camera from its target */
  37816. radius: number,
  37817. /** Define the camera target (the messh it should follow) */
  37818. target: Nullable<AbstractMesh>, scene: Scene);
  37819. private _follow;
  37820. /** @hidden */
  37821. _checkInputs(): void;
  37822. /**
  37823. * Returns the class name of the object.
  37824. * It is mostly used internally for serialization purposes.
  37825. */
  37826. getClassName(): string;
  37827. }
  37828. }
  37829. declare module BABYLON {
  37830. /**
  37831. * Manage the keyboard inputs to control the movement of a follow camera.
  37832. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37833. */
  37834. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37835. /**
  37836. * Defines the camera the input is attached to.
  37837. */
  37838. camera: FollowCamera;
  37839. /**
  37840. * Defines the list of key codes associated with the up action (increase heightOffset)
  37841. */
  37842. keysHeightOffsetIncr: number[];
  37843. /**
  37844. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37845. */
  37846. keysHeightOffsetDecr: number[];
  37847. /**
  37848. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37849. */
  37850. keysHeightOffsetModifierAlt: boolean;
  37851. /**
  37852. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37853. */
  37854. keysHeightOffsetModifierCtrl: boolean;
  37855. /**
  37856. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37857. */
  37858. keysHeightOffsetModifierShift: boolean;
  37859. /**
  37860. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37861. */
  37862. keysRotationOffsetIncr: number[];
  37863. /**
  37864. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37865. */
  37866. keysRotationOffsetDecr: number[];
  37867. /**
  37868. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37869. */
  37870. keysRotationOffsetModifierAlt: boolean;
  37871. /**
  37872. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37873. */
  37874. keysRotationOffsetModifierCtrl: boolean;
  37875. /**
  37876. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37877. */
  37878. keysRotationOffsetModifierShift: boolean;
  37879. /**
  37880. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37881. */
  37882. keysRadiusIncr: number[];
  37883. /**
  37884. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37885. */
  37886. keysRadiusDecr: number[];
  37887. /**
  37888. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37889. */
  37890. keysRadiusModifierAlt: boolean;
  37891. /**
  37892. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37893. */
  37894. keysRadiusModifierCtrl: boolean;
  37895. /**
  37896. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37897. */
  37898. keysRadiusModifierShift: boolean;
  37899. /**
  37900. * Defines the rate of change of heightOffset.
  37901. */
  37902. heightSensibility: number;
  37903. /**
  37904. * Defines the rate of change of rotationOffset.
  37905. */
  37906. rotationSensibility: number;
  37907. /**
  37908. * Defines the rate of change of radius.
  37909. */
  37910. radiusSensibility: number;
  37911. private _keys;
  37912. private _ctrlPressed;
  37913. private _altPressed;
  37914. private _shiftPressed;
  37915. private _onCanvasBlurObserver;
  37916. private _onKeyboardObserver;
  37917. private _engine;
  37918. private _scene;
  37919. /**
  37920. * Attach the input controls to a specific dom element to get the input from.
  37921. * @param element Defines the element the controls should be listened from
  37922. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37923. */
  37924. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37925. /**
  37926. * Detach the current controls from the specified dom element.
  37927. * @param element Defines the element to stop listening the inputs from
  37928. */
  37929. detachControl(element: Nullable<HTMLElement>): void;
  37930. /**
  37931. * Update the current camera state depending on the inputs that have been used this frame.
  37932. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37933. */
  37934. checkInputs(): void;
  37935. /**
  37936. * Gets the class name of the current input.
  37937. * @returns the class name
  37938. */
  37939. getClassName(): string;
  37940. /**
  37941. * Get the friendly name associated with the input class.
  37942. * @returns the input friendly name
  37943. */
  37944. getSimpleName(): string;
  37945. /**
  37946. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37947. * allow modification of the heightOffset value.
  37948. */
  37949. private _modifierHeightOffset;
  37950. /**
  37951. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37952. * allow modification of the rotationOffset value.
  37953. */
  37954. private _modifierRotationOffset;
  37955. /**
  37956. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37957. * allow modification of the radius value.
  37958. */
  37959. private _modifierRadius;
  37960. }
  37961. }
  37962. declare module BABYLON {
  37963. interface FreeCameraInputsManager {
  37964. /**
  37965. * @hidden
  37966. */
  37967. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37968. /**
  37969. * Add orientation input support to the input manager.
  37970. * @returns the current input manager
  37971. */
  37972. addDeviceOrientation(): FreeCameraInputsManager;
  37973. }
  37974. /**
  37975. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37976. * Screen rotation is taken into account.
  37977. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37978. */
  37979. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37980. private _camera;
  37981. private _screenOrientationAngle;
  37982. private _constantTranform;
  37983. private _screenQuaternion;
  37984. private _alpha;
  37985. private _beta;
  37986. private _gamma;
  37987. /**
  37988. * Can be used to detect if a device orientation sensor is availible on a device
  37989. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  37990. * @returns a promise that will resolve on orientation change
  37991. */
  37992. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  37993. /**
  37994. * @hidden
  37995. */
  37996. _onDeviceOrientationChangedObservable: Observable<void>;
  37997. /**
  37998. * Instantiates a new input
  37999. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38000. */
  38001. constructor();
  38002. /**
  38003. * Define the camera controlled by the input.
  38004. */
  38005. camera: FreeCamera;
  38006. /**
  38007. * Attach the input controls to a specific dom element to get the input from.
  38008. * @param element Defines the element the controls should be listened from
  38009. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38010. */
  38011. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38012. private _orientationChanged;
  38013. private _deviceOrientation;
  38014. /**
  38015. * Detach the current controls from the specified dom element.
  38016. * @param element Defines the element to stop listening the inputs from
  38017. */
  38018. detachControl(element: Nullable<HTMLElement>): void;
  38019. /**
  38020. * Update the current camera state depending on the inputs that have been used this frame.
  38021. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38022. */
  38023. checkInputs(): void;
  38024. /**
  38025. * Gets the class name of the current intput.
  38026. * @returns the class name
  38027. */
  38028. getClassName(): string;
  38029. /**
  38030. * Get the friendly name associated with the input class.
  38031. * @returns the input friendly name
  38032. */
  38033. getSimpleName(): string;
  38034. }
  38035. }
  38036. declare module BABYLON {
  38037. /**
  38038. * Manage the gamepad inputs to control a free camera.
  38039. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38040. */
  38041. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38042. /**
  38043. * Define the camera the input is attached to.
  38044. */
  38045. camera: FreeCamera;
  38046. /**
  38047. * Define the Gamepad controlling the input
  38048. */
  38049. gamepad: Nullable<Gamepad>;
  38050. /**
  38051. * Defines the gamepad rotation sensiblity.
  38052. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38053. */
  38054. gamepadAngularSensibility: number;
  38055. /**
  38056. * Defines the gamepad move sensiblity.
  38057. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38058. */
  38059. gamepadMoveSensibility: number;
  38060. private _onGamepadConnectedObserver;
  38061. private _onGamepadDisconnectedObserver;
  38062. private _cameraTransform;
  38063. private _deltaTransform;
  38064. private _vector3;
  38065. private _vector2;
  38066. /**
  38067. * Attach the input controls to a specific dom element to get the input from.
  38068. * @param element Defines the element the controls should be listened from
  38069. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38070. */
  38071. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38072. /**
  38073. * Detach the current controls from the specified dom element.
  38074. * @param element Defines the element to stop listening the inputs from
  38075. */
  38076. detachControl(element: Nullable<HTMLElement>): void;
  38077. /**
  38078. * Update the current camera state depending on the inputs that have been used this frame.
  38079. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38080. */
  38081. checkInputs(): void;
  38082. /**
  38083. * Gets the class name of the current intput.
  38084. * @returns the class name
  38085. */
  38086. getClassName(): string;
  38087. /**
  38088. * Get the friendly name associated with the input class.
  38089. * @returns the input friendly name
  38090. */
  38091. getSimpleName(): string;
  38092. }
  38093. }
  38094. declare module BABYLON {
  38095. /**
  38096. * Defines the potential axis of a Joystick
  38097. */
  38098. export enum JoystickAxis {
  38099. /** X axis */
  38100. X = 0,
  38101. /** Y axis */
  38102. Y = 1,
  38103. /** Z axis */
  38104. Z = 2
  38105. }
  38106. /**
  38107. * Class used to define virtual joystick (used in touch mode)
  38108. */
  38109. export class VirtualJoystick {
  38110. /**
  38111. * Gets or sets a boolean indicating that left and right values must be inverted
  38112. */
  38113. reverseLeftRight: boolean;
  38114. /**
  38115. * Gets or sets a boolean indicating that up and down values must be inverted
  38116. */
  38117. reverseUpDown: boolean;
  38118. /**
  38119. * Gets the offset value for the position (ie. the change of the position value)
  38120. */
  38121. deltaPosition: Vector3;
  38122. /**
  38123. * Gets a boolean indicating if the virtual joystick was pressed
  38124. */
  38125. pressed: boolean;
  38126. /**
  38127. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38128. */
  38129. static Canvas: Nullable<HTMLCanvasElement>;
  38130. private static _globalJoystickIndex;
  38131. private static vjCanvasContext;
  38132. private static vjCanvasWidth;
  38133. private static vjCanvasHeight;
  38134. private static halfWidth;
  38135. private _action;
  38136. private _axisTargetedByLeftAndRight;
  38137. private _axisTargetedByUpAndDown;
  38138. private _joystickSensibility;
  38139. private _inversedSensibility;
  38140. private _joystickPointerID;
  38141. private _joystickColor;
  38142. private _joystickPointerPos;
  38143. private _joystickPreviousPointerPos;
  38144. private _joystickPointerStartPos;
  38145. private _deltaJoystickVector;
  38146. private _leftJoystick;
  38147. private _touches;
  38148. private _onPointerDownHandlerRef;
  38149. private _onPointerMoveHandlerRef;
  38150. private _onPointerUpHandlerRef;
  38151. private _onResize;
  38152. /**
  38153. * Creates a new virtual joystick
  38154. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38155. */
  38156. constructor(leftJoystick?: boolean);
  38157. /**
  38158. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38159. * @param newJoystickSensibility defines the new sensibility
  38160. */
  38161. setJoystickSensibility(newJoystickSensibility: number): void;
  38162. private _onPointerDown;
  38163. private _onPointerMove;
  38164. private _onPointerUp;
  38165. /**
  38166. * Change the color of the virtual joystick
  38167. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38168. */
  38169. setJoystickColor(newColor: string): void;
  38170. /**
  38171. * Defines a callback to call when the joystick is touched
  38172. * @param action defines the callback
  38173. */
  38174. setActionOnTouch(action: () => any): void;
  38175. /**
  38176. * Defines which axis you'd like to control for left & right
  38177. * @param axis defines the axis to use
  38178. */
  38179. setAxisForLeftRight(axis: JoystickAxis): void;
  38180. /**
  38181. * Defines which axis you'd like to control for up & down
  38182. * @param axis defines the axis to use
  38183. */
  38184. setAxisForUpDown(axis: JoystickAxis): void;
  38185. private _drawVirtualJoystick;
  38186. /**
  38187. * Release internal HTML canvas
  38188. */
  38189. releaseCanvas(): void;
  38190. }
  38191. }
  38192. declare module BABYLON {
  38193. interface FreeCameraInputsManager {
  38194. /**
  38195. * Add virtual joystick input support to the input manager.
  38196. * @returns the current input manager
  38197. */
  38198. addVirtualJoystick(): FreeCameraInputsManager;
  38199. }
  38200. /**
  38201. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38202. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38203. */
  38204. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38205. /**
  38206. * Defines the camera the input is attached to.
  38207. */
  38208. camera: FreeCamera;
  38209. private _leftjoystick;
  38210. private _rightjoystick;
  38211. /**
  38212. * Gets the left stick of the virtual joystick.
  38213. * @returns The virtual Joystick
  38214. */
  38215. getLeftJoystick(): VirtualJoystick;
  38216. /**
  38217. * Gets the right stick of the virtual joystick.
  38218. * @returns The virtual Joystick
  38219. */
  38220. getRightJoystick(): VirtualJoystick;
  38221. /**
  38222. * Update the current camera state depending on the inputs that have been used this frame.
  38223. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38224. */
  38225. checkInputs(): void;
  38226. /**
  38227. * Attach the input controls to a specific dom element to get the input from.
  38228. * @param element Defines the element the controls should be listened from
  38229. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38230. */
  38231. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38232. /**
  38233. * Detach the current controls from the specified dom element.
  38234. * @param element Defines the element to stop listening the inputs from
  38235. */
  38236. detachControl(element: Nullable<HTMLElement>): void;
  38237. /**
  38238. * Gets the class name of the current intput.
  38239. * @returns the class name
  38240. */
  38241. getClassName(): string;
  38242. /**
  38243. * Get the friendly name associated with the input class.
  38244. * @returns the input friendly name
  38245. */
  38246. getSimpleName(): string;
  38247. }
  38248. }
  38249. declare module BABYLON {
  38250. /**
  38251. * This represents a FPS type of camera controlled by touch.
  38252. * This is like a universal camera minus the Gamepad controls.
  38253. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38254. */
  38255. export class TouchCamera extends FreeCamera {
  38256. /**
  38257. * Defines the touch sensibility for rotation.
  38258. * The higher the faster.
  38259. */
  38260. touchAngularSensibility: number;
  38261. /**
  38262. * Defines the touch sensibility for move.
  38263. * The higher the faster.
  38264. */
  38265. touchMoveSensibility: number;
  38266. /**
  38267. * Instantiates a new touch camera.
  38268. * This represents a FPS type of camera controlled by touch.
  38269. * This is like a universal camera minus the Gamepad controls.
  38270. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38271. * @param name Define the name of the camera in the scene
  38272. * @param position Define the start position of the camera in the scene
  38273. * @param scene Define the scene the camera belongs to
  38274. */
  38275. constructor(name: string, position: Vector3, scene: Scene);
  38276. /**
  38277. * Gets the current object class name.
  38278. * @return the class name
  38279. */
  38280. getClassName(): string;
  38281. /** @hidden */
  38282. _setupInputs(): void;
  38283. }
  38284. }
  38285. declare module BABYLON {
  38286. /**
  38287. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38288. * being tilted forward or back and left or right.
  38289. */
  38290. export class DeviceOrientationCamera extends FreeCamera {
  38291. private _initialQuaternion;
  38292. private _quaternionCache;
  38293. private _tmpDragQuaternion;
  38294. private _disablePointerInputWhenUsingDeviceOrientation;
  38295. /**
  38296. * Creates a new device orientation camera
  38297. * @param name The name of the camera
  38298. * @param position The start position camera
  38299. * @param scene The scene the camera belongs to
  38300. */
  38301. constructor(name: string, position: Vector3, scene: Scene);
  38302. /**
  38303. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38304. */
  38305. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38306. private _dragFactor;
  38307. /**
  38308. * Enabled turning on the y axis when the orientation sensor is active
  38309. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38310. */
  38311. enableHorizontalDragging(dragFactor?: number): void;
  38312. /**
  38313. * Gets the current instance class name ("DeviceOrientationCamera").
  38314. * This helps avoiding instanceof at run time.
  38315. * @returns the class name
  38316. */
  38317. getClassName(): string;
  38318. /**
  38319. * @hidden
  38320. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38321. */
  38322. _checkInputs(): void;
  38323. /**
  38324. * Reset the camera to its default orientation on the specified axis only.
  38325. * @param axis The axis to reset
  38326. */
  38327. resetToCurrentRotation(axis?: Axis): void;
  38328. }
  38329. }
  38330. declare module BABYLON {
  38331. /**
  38332. * Defines supported buttons for XBox360 compatible gamepads
  38333. */
  38334. export enum Xbox360Button {
  38335. /** A */
  38336. A = 0,
  38337. /** B */
  38338. B = 1,
  38339. /** X */
  38340. X = 2,
  38341. /** Y */
  38342. Y = 3,
  38343. /** Start */
  38344. Start = 4,
  38345. /** Back */
  38346. Back = 5,
  38347. /** Left button */
  38348. LB = 6,
  38349. /** Right button */
  38350. RB = 7,
  38351. /** Left stick */
  38352. LeftStick = 8,
  38353. /** Right stick */
  38354. RightStick = 9
  38355. }
  38356. /** Defines values for XBox360 DPad */
  38357. export enum Xbox360Dpad {
  38358. /** Up */
  38359. Up = 0,
  38360. /** Down */
  38361. Down = 1,
  38362. /** Left */
  38363. Left = 2,
  38364. /** Right */
  38365. Right = 3
  38366. }
  38367. /**
  38368. * Defines a XBox360 gamepad
  38369. */
  38370. export class Xbox360Pad extends Gamepad {
  38371. private _leftTrigger;
  38372. private _rightTrigger;
  38373. private _onlefttriggerchanged;
  38374. private _onrighttriggerchanged;
  38375. private _onbuttondown;
  38376. private _onbuttonup;
  38377. private _ondpaddown;
  38378. private _ondpadup;
  38379. /** Observable raised when a button is pressed */
  38380. onButtonDownObservable: Observable<Xbox360Button>;
  38381. /** Observable raised when a button is released */
  38382. onButtonUpObservable: Observable<Xbox360Button>;
  38383. /** Observable raised when a pad is pressed */
  38384. onPadDownObservable: Observable<Xbox360Dpad>;
  38385. /** Observable raised when a pad is released */
  38386. onPadUpObservable: Observable<Xbox360Dpad>;
  38387. private _buttonA;
  38388. private _buttonB;
  38389. private _buttonX;
  38390. private _buttonY;
  38391. private _buttonBack;
  38392. private _buttonStart;
  38393. private _buttonLB;
  38394. private _buttonRB;
  38395. private _buttonLeftStick;
  38396. private _buttonRightStick;
  38397. private _dPadUp;
  38398. private _dPadDown;
  38399. private _dPadLeft;
  38400. private _dPadRight;
  38401. private _isXboxOnePad;
  38402. /**
  38403. * Creates a new XBox360 gamepad object
  38404. * @param id defines the id of this gamepad
  38405. * @param index defines its index
  38406. * @param gamepad defines the internal HTML gamepad object
  38407. * @param xboxOne defines if it is a XBox One gamepad
  38408. */
  38409. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38410. /**
  38411. * Defines the callback to call when left trigger is pressed
  38412. * @param callback defines the callback to use
  38413. */
  38414. onlefttriggerchanged(callback: (value: number) => void): void;
  38415. /**
  38416. * Defines the callback to call when right trigger is pressed
  38417. * @param callback defines the callback to use
  38418. */
  38419. onrighttriggerchanged(callback: (value: number) => void): void;
  38420. /**
  38421. * Gets the left trigger value
  38422. */
  38423. /**
  38424. * Sets the left trigger value
  38425. */
  38426. leftTrigger: number;
  38427. /**
  38428. * Gets the right trigger value
  38429. */
  38430. /**
  38431. * Sets the right trigger value
  38432. */
  38433. rightTrigger: number;
  38434. /**
  38435. * Defines the callback to call when a button is pressed
  38436. * @param callback defines the callback to use
  38437. */
  38438. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38439. /**
  38440. * Defines the callback to call when a button is released
  38441. * @param callback defines the callback to use
  38442. */
  38443. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38444. /**
  38445. * Defines the callback to call when a pad is pressed
  38446. * @param callback defines the callback to use
  38447. */
  38448. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38449. /**
  38450. * Defines the callback to call when a pad is released
  38451. * @param callback defines the callback to use
  38452. */
  38453. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38454. private _setButtonValue;
  38455. private _setDPadValue;
  38456. /**
  38457. * Gets the value of the `A` button
  38458. */
  38459. /**
  38460. * Sets the value of the `A` button
  38461. */
  38462. buttonA: number;
  38463. /**
  38464. * Gets the value of the `B` button
  38465. */
  38466. /**
  38467. * Sets the value of the `B` button
  38468. */
  38469. buttonB: number;
  38470. /**
  38471. * Gets the value of the `X` button
  38472. */
  38473. /**
  38474. * Sets the value of the `X` button
  38475. */
  38476. buttonX: number;
  38477. /**
  38478. * Gets the value of the `Y` button
  38479. */
  38480. /**
  38481. * Sets the value of the `Y` button
  38482. */
  38483. buttonY: number;
  38484. /**
  38485. * Gets the value of the `Start` button
  38486. */
  38487. /**
  38488. * Sets the value of the `Start` button
  38489. */
  38490. buttonStart: number;
  38491. /**
  38492. * Gets the value of the `Back` button
  38493. */
  38494. /**
  38495. * Sets the value of the `Back` button
  38496. */
  38497. buttonBack: number;
  38498. /**
  38499. * Gets the value of the `Left` button
  38500. */
  38501. /**
  38502. * Sets the value of the `Left` button
  38503. */
  38504. buttonLB: number;
  38505. /**
  38506. * Gets the value of the `Right` button
  38507. */
  38508. /**
  38509. * Sets the value of the `Right` button
  38510. */
  38511. buttonRB: number;
  38512. /**
  38513. * Gets the value of the Left joystick
  38514. */
  38515. /**
  38516. * Sets the value of the Left joystick
  38517. */
  38518. buttonLeftStick: number;
  38519. /**
  38520. * Gets the value of the Right joystick
  38521. */
  38522. /**
  38523. * Sets the value of the Right joystick
  38524. */
  38525. buttonRightStick: number;
  38526. /**
  38527. * Gets the value of D-pad up
  38528. */
  38529. /**
  38530. * Sets the value of D-pad up
  38531. */
  38532. dPadUp: number;
  38533. /**
  38534. * Gets the value of D-pad down
  38535. */
  38536. /**
  38537. * Sets the value of D-pad down
  38538. */
  38539. dPadDown: number;
  38540. /**
  38541. * Gets the value of D-pad left
  38542. */
  38543. /**
  38544. * Sets the value of D-pad left
  38545. */
  38546. dPadLeft: number;
  38547. /**
  38548. * Gets the value of D-pad right
  38549. */
  38550. /**
  38551. * Sets the value of D-pad right
  38552. */
  38553. dPadRight: number;
  38554. /**
  38555. * Force the gamepad to synchronize with device values
  38556. */
  38557. update(): void;
  38558. /**
  38559. * Disposes the gamepad
  38560. */
  38561. dispose(): void;
  38562. }
  38563. }
  38564. declare module BABYLON {
  38565. /**
  38566. * Defines supported buttons for DualShock compatible gamepads
  38567. */
  38568. export enum DualShockButton {
  38569. /** Cross */
  38570. Cross = 0,
  38571. /** Circle */
  38572. Circle = 1,
  38573. /** Square */
  38574. Square = 2,
  38575. /** Triangle */
  38576. Triangle = 3,
  38577. /** Options */
  38578. Options = 4,
  38579. /** Share */
  38580. Share = 5,
  38581. /** L1 */
  38582. L1 = 6,
  38583. /** R1 */
  38584. R1 = 7,
  38585. /** Left stick */
  38586. LeftStick = 8,
  38587. /** Right stick */
  38588. RightStick = 9
  38589. }
  38590. /** Defines values for DualShock DPad */
  38591. export enum DualShockDpad {
  38592. /** Up */
  38593. Up = 0,
  38594. /** Down */
  38595. Down = 1,
  38596. /** Left */
  38597. Left = 2,
  38598. /** Right */
  38599. Right = 3
  38600. }
  38601. /**
  38602. * Defines a DualShock gamepad
  38603. */
  38604. export class DualShockPad extends Gamepad {
  38605. private _leftTrigger;
  38606. private _rightTrigger;
  38607. private _onlefttriggerchanged;
  38608. private _onrighttriggerchanged;
  38609. private _onbuttondown;
  38610. private _onbuttonup;
  38611. private _ondpaddown;
  38612. private _ondpadup;
  38613. /** Observable raised when a button is pressed */
  38614. onButtonDownObservable: Observable<DualShockButton>;
  38615. /** Observable raised when a button is released */
  38616. onButtonUpObservable: Observable<DualShockButton>;
  38617. /** Observable raised when a pad is pressed */
  38618. onPadDownObservable: Observable<DualShockDpad>;
  38619. /** Observable raised when a pad is released */
  38620. onPadUpObservable: Observable<DualShockDpad>;
  38621. private _buttonCross;
  38622. private _buttonCircle;
  38623. private _buttonSquare;
  38624. private _buttonTriangle;
  38625. private _buttonShare;
  38626. private _buttonOptions;
  38627. private _buttonL1;
  38628. private _buttonR1;
  38629. private _buttonLeftStick;
  38630. private _buttonRightStick;
  38631. private _dPadUp;
  38632. private _dPadDown;
  38633. private _dPadLeft;
  38634. private _dPadRight;
  38635. /**
  38636. * Creates a new DualShock gamepad object
  38637. * @param id defines the id of this gamepad
  38638. * @param index defines its index
  38639. * @param gamepad defines the internal HTML gamepad object
  38640. */
  38641. constructor(id: string, index: number, gamepad: any);
  38642. /**
  38643. * Defines the callback to call when left trigger is pressed
  38644. * @param callback defines the callback to use
  38645. */
  38646. onlefttriggerchanged(callback: (value: number) => void): void;
  38647. /**
  38648. * Defines the callback to call when right trigger is pressed
  38649. * @param callback defines the callback to use
  38650. */
  38651. onrighttriggerchanged(callback: (value: number) => void): void;
  38652. /**
  38653. * Gets the left trigger value
  38654. */
  38655. /**
  38656. * Sets the left trigger value
  38657. */
  38658. leftTrigger: number;
  38659. /**
  38660. * Gets the right trigger value
  38661. */
  38662. /**
  38663. * Sets the right trigger value
  38664. */
  38665. rightTrigger: number;
  38666. /**
  38667. * Defines the callback to call when a button is pressed
  38668. * @param callback defines the callback to use
  38669. */
  38670. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  38671. /**
  38672. * Defines the callback to call when a button is released
  38673. * @param callback defines the callback to use
  38674. */
  38675. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  38676. /**
  38677. * Defines the callback to call when a pad is pressed
  38678. * @param callback defines the callback to use
  38679. */
  38680. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  38681. /**
  38682. * Defines the callback to call when a pad is released
  38683. * @param callback defines the callback to use
  38684. */
  38685. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  38686. private _setButtonValue;
  38687. private _setDPadValue;
  38688. /**
  38689. * Gets the value of the `Cross` button
  38690. */
  38691. /**
  38692. * Sets the value of the `Cross` button
  38693. */
  38694. buttonCross: number;
  38695. /**
  38696. * Gets the value of the `Circle` button
  38697. */
  38698. /**
  38699. * Sets the value of the `Circle` button
  38700. */
  38701. buttonCircle: number;
  38702. /**
  38703. * Gets the value of the `Square` button
  38704. */
  38705. /**
  38706. * Sets the value of the `Square` button
  38707. */
  38708. buttonSquare: number;
  38709. /**
  38710. * Gets the value of the `Triangle` button
  38711. */
  38712. /**
  38713. * Sets the value of the `Triangle` button
  38714. */
  38715. buttonTriangle: number;
  38716. /**
  38717. * Gets the value of the `Options` button
  38718. */
  38719. /**
  38720. * Sets the value of the `Options` button
  38721. */
  38722. buttonOptions: number;
  38723. /**
  38724. * Gets the value of the `Share` button
  38725. */
  38726. /**
  38727. * Sets the value of the `Share` button
  38728. */
  38729. buttonShare: number;
  38730. /**
  38731. * Gets the value of the `L1` button
  38732. */
  38733. /**
  38734. * Sets the value of the `L1` button
  38735. */
  38736. buttonL1: number;
  38737. /**
  38738. * Gets the value of the `R1` button
  38739. */
  38740. /**
  38741. * Sets the value of the `R1` button
  38742. */
  38743. buttonR1: number;
  38744. /**
  38745. * Gets the value of the Left joystick
  38746. */
  38747. /**
  38748. * Sets the value of the Left joystick
  38749. */
  38750. buttonLeftStick: number;
  38751. /**
  38752. * Gets the value of the Right joystick
  38753. */
  38754. /**
  38755. * Sets the value of the Right joystick
  38756. */
  38757. buttonRightStick: number;
  38758. /**
  38759. * Gets the value of D-pad up
  38760. */
  38761. /**
  38762. * Sets the value of D-pad up
  38763. */
  38764. dPadUp: number;
  38765. /**
  38766. * Gets the value of D-pad down
  38767. */
  38768. /**
  38769. * Sets the value of D-pad down
  38770. */
  38771. dPadDown: number;
  38772. /**
  38773. * Gets the value of D-pad left
  38774. */
  38775. /**
  38776. * Sets the value of D-pad left
  38777. */
  38778. dPadLeft: number;
  38779. /**
  38780. * Gets the value of D-pad right
  38781. */
  38782. /**
  38783. * Sets the value of D-pad right
  38784. */
  38785. dPadRight: number;
  38786. /**
  38787. * Force the gamepad to synchronize with device values
  38788. */
  38789. update(): void;
  38790. /**
  38791. * Disposes the gamepad
  38792. */
  38793. dispose(): void;
  38794. }
  38795. }
  38796. declare module BABYLON {
  38797. /**
  38798. * Manager for handling gamepads
  38799. */
  38800. export class GamepadManager {
  38801. private _scene?;
  38802. private _babylonGamepads;
  38803. private _oneGamepadConnected;
  38804. /** @hidden */
  38805. _isMonitoring: boolean;
  38806. private _gamepadEventSupported;
  38807. private _gamepadSupport;
  38808. /**
  38809. * observable to be triggered when the gamepad controller has been connected
  38810. */
  38811. onGamepadConnectedObservable: Observable<Gamepad>;
  38812. /**
  38813. * observable to be triggered when the gamepad controller has been disconnected
  38814. */
  38815. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38816. private _onGamepadConnectedEvent;
  38817. private _onGamepadDisconnectedEvent;
  38818. /**
  38819. * Initializes the gamepad manager
  38820. * @param _scene BabylonJS scene
  38821. */
  38822. constructor(_scene?: Scene | undefined);
  38823. /**
  38824. * The gamepads in the game pad manager
  38825. */
  38826. readonly gamepads: Gamepad[];
  38827. /**
  38828. * Get the gamepad controllers based on type
  38829. * @param type The type of gamepad controller
  38830. * @returns Nullable gamepad
  38831. */
  38832. getGamepadByType(type?: number): Nullable<Gamepad>;
  38833. /**
  38834. * Disposes the gamepad manager
  38835. */
  38836. dispose(): void;
  38837. private _addNewGamepad;
  38838. private _startMonitoringGamepads;
  38839. private _stopMonitoringGamepads;
  38840. /** @hidden */
  38841. _checkGamepadsStatus(): void;
  38842. private _updateGamepadObjects;
  38843. }
  38844. }
  38845. declare module BABYLON {
  38846. interface Scene {
  38847. /** @hidden */
  38848. _gamepadManager: Nullable<GamepadManager>;
  38849. /**
  38850. * Gets the gamepad manager associated with the scene
  38851. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38852. */
  38853. gamepadManager: GamepadManager;
  38854. }
  38855. /**
  38856. * Interface representing a free camera inputs manager
  38857. */
  38858. interface FreeCameraInputsManager {
  38859. /**
  38860. * Adds gamepad input support to the FreeCameraInputsManager.
  38861. * @returns the FreeCameraInputsManager
  38862. */
  38863. addGamepad(): FreeCameraInputsManager;
  38864. }
  38865. /**
  38866. * Interface representing an arc rotate camera inputs manager
  38867. */
  38868. interface ArcRotateCameraInputsManager {
  38869. /**
  38870. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38871. * @returns the camera inputs manager
  38872. */
  38873. addGamepad(): ArcRotateCameraInputsManager;
  38874. }
  38875. /**
  38876. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38877. */
  38878. export class GamepadSystemSceneComponent implements ISceneComponent {
  38879. /**
  38880. * The component name helpfull to identify the component in the list of scene components.
  38881. */
  38882. readonly name: string;
  38883. /**
  38884. * The scene the component belongs to.
  38885. */
  38886. scene: Scene;
  38887. /**
  38888. * Creates a new instance of the component for the given scene
  38889. * @param scene Defines the scene to register the component in
  38890. */
  38891. constructor(scene: Scene);
  38892. /**
  38893. * Registers the component in a given scene
  38894. */
  38895. register(): void;
  38896. /**
  38897. * Rebuilds the elements related to this component in case of
  38898. * context lost for instance.
  38899. */
  38900. rebuild(): void;
  38901. /**
  38902. * Disposes the component and the associated ressources
  38903. */
  38904. dispose(): void;
  38905. private _beforeCameraUpdate;
  38906. }
  38907. }
  38908. declare module BABYLON {
  38909. /**
  38910. * 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,
  38911. * which still works and will still be found in many Playgrounds.
  38912. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38913. */
  38914. export class UniversalCamera extends TouchCamera {
  38915. /**
  38916. * Defines the gamepad rotation sensiblity.
  38917. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38918. */
  38919. gamepadAngularSensibility: number;
  38920. /**
  38921. * Defines the gamepad move sensiblity.
  38922. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38923. */
  38924. gamepadMoveSensibility: number;
  38925. /**
  38926. * 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,
  38927. * which still works and will still be found in many Playgrounds.
  38928. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38929. * @param name Define the name of the camera in the scene
  38930. * @param position Define the start position of the camera in the scene
  38931. * @param scene Define the scene the camera belongs to
  38932. */
  38933. constructor(name: string, position: Vector3, scene: Scene);
  38934. /**
  38935. * Gets the current object class name.
  38936. * @return the class name
  38937. */
  38938. getClassName(): string;
  38939. }
  38940. }
  38941. declare module BABYLON {
  38942. /**
  38943. * This represents a FPS type of camera. This is only here for back compat purpose.
  38944. * Please use the UniversalCamera instead as both are identical.
  38945. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38946. */
  38947. export class GamepadCamera extends UniversalCamera {
  38948. /**
  38949. * Instantiates a new Gamepad Camera
  38950. * This represents a FPS type of camera. This is only here for back compat purpose.
  38951. * Please use the UniversalCamera instead as both are identical.
  38952. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38953. * @param name Define the name of the camera in the scene
  38954. * @param position Define the start position of the camera in the scene
  38955. * @param scene Define the scene the camera belongs to
  38956. */
  38957. constructor(name: string, position: Vector3, scene: Scene);
  38958. /**
  38959. * Gets the current object class name.
  38960. * @return the class name
  38961. */
  38962. getClassName(): string;
  38963. }
  38964. }
  38965. declare module BABYLON {
  38966. /** @hidden */
  38967. export var passPixelShader: {
  38968. name: string;
  38969. shader: string;
  38970. };
  38971. }
  38972. declare module BABYLON {
  38973. /** @hidden */
  38974. export var passCubePixelShader: {
  38975. name: string;
  38976. shader: string;
  38977. };
  38978. }
  38979. declare module BABYLON {
  38980. /**
  38981. * PassPostProcess which produces an output the same as it's input
  38982. */
  38983. export class PassPostProcess extends PostProcess {
  38984. /**
  38985. * Creates the PassPostProcess
  38986. * @param name The name of the effect.
  38987. * @param options The required width/height ratio to downsize to before computing the render pass.
  38988. * @param camera The camera to apply the render pass to.
  38989. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38990. * @param engine The engine which the post process will be applied. (default: current engine)
  38991. * @param reusable If the post process can be reused on the same frame. (default: false)
  38992. * @param textureType The type of texture to be used when performing the post processing.
  38993. * @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)
  38994. */
  38995. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38996. }
  38997. /**
  38998. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38999. */
  39000. export class PassCubePostProcess extends PostProcess {
  39001. private _face;
  39002. /**
  39003. * Gets or sets the cube face to display.
  39004. * * 0 is +X
  39005. * * 1 is -X
  39006. * * 2 is +Y
  39007. * * 3 is -Y
  39008. * * 4 is +Z
  39009. * * 5 is -Z
  39010. */
  39011. face: number;
  39012. /**
  39013. * Creates the PassCubePostProcess
  39014. * @param name The name of the effect.
  39015. * @param options The required width/height ratio to downsize to before computing the render pass.
  39016. * @param camera The camera to apply the render pass to.
  39017. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39018. * @param engine The engine which the post process will be applied. (default: current engine)
  39019. * @param reusable If the post process can be reused on the same frame. (default: false)
  39020. * @param textureType The type of texture to be used when performing the post processing.
  39021. * @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)
  39022. */
  39023. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39024. }
  39025. }
  39026. declare module BABYLON {
  39027. /** @hidden */
  39028. export var anaglyphPixelShader: {
  39029. name: string;
  39030. shader: string;
  39031. };
  39032. }
  39033. declare module BABYLON {
  39034. /**
  39035. * Postprocess used to generate anaglyphic rendering
  39036. */
  39037. export class AnaglyphPostProcess extends PostProcess {
  39038. private _passedProcess;
  39039. /**
  39040. * Creates a new AnaglyphPostProcess
  39041. * @param name defines postprocess name
  39042. * @param options defines creation options or target ratio scale
  39043. * @param rigCameras defines cameras using this postprocess
  39044. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39045. * @param engine defines hosting engine
  39046. * @param reusable defines if the postprocess will be reused multiple times per frame
  39047. */
  39048. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39049. }
  39050. }
  39051. declare module BABYLON {
  39052. /**
  39053. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39054. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39055. */
  39056. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39057. /**
  39058. * Creates a new AnaglyphArcRotateCamera
  39059. * @param name defines camera name
  39060. * @param alpha defines alpha angle (in radians)
  39061. * @param beta defines beta angle (in radians)
  39062. * @param radius defines radius
  39063. * @param target defines camera target
  39064. * @param interaxialDistance defines distance between each color axis
  39065. * @param scene defines the hosting scene
  39066. */
  39067. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39068. /**
  39069. * Gets camera class name
  39070. * @returns AnaglyphArcRotateCamera
  39071. */
  39072. getClassName(): string;
  39073. }
  39074. }
  39075. declare module BABYLON {
  39076. /**
  39077. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39078. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39079. */
  39080. export class AnaglyphFreeCamera extends FreeCamera {
  39081. /**
  39082. * Creates a new AnaglyphFreeCamera
  39083. * @param name defines camera name
  39084. * @param position defines initial position
  39085. * @param interaxialDistance defines distance between each color axis
  39086. * @param scene defines the hosting scene
  39087. */
  39088. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39089. /**
  39090. * Gets camera class name
  39091. * @returns AnaglyphFreeCamera
  39092. */
  39093. getClassName(): string;
  39094. }
  39095. }
  39096. declare module BABYLON {
  39097. /**
  39098. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39099. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39100. */
  39101. export class AnaglyphGamepadCamera extends GamepadCamera {
  39102. /**
  39103. * Creates a new AnaglyphGamepadCamera
  39104. * @param name defines camera name
  39105. * @param position defines initial position
  39106. * @param interaxialDistance defines distance between each color axis
  39107. * @param scene defines the hosting scene
  39108. */
  39109. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39110. /**
  39111. * Gets camera class name
  39112. * @returns AnaglyphGamepadCamera
  39113. */
  39114. getClassName(): string;
  39115. }
  39116. }
  39117. declare module BABYLON {
  39118. /**
  39119. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39120. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39121. */
  39122. export class AnaglyphUniversalCamera extends UniversalCamera {
  39123. /**
  39124. * Creates a new AnaglyphUniversalCamera
  39125. * @param name defines camera name
  39126. * @param position defines initial position
  39127. * @param interaxialDistance defines distance between each color axis
  39128. * @param scene defines the hosting scene
  39129. */
  39130. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39131. /**
  39132. * Gets camera class name
  39133. * @returns AnaglyphUniversalCamera
  39134. */
  39135. getClassName(): string;
  39136. }
  39137. }
  39138. declare module BABYLON {
  39139. /** @hidden */
  39140. export var stereoscopicInterlacePixelShader: {
  39141. name: string;
  39142. shader: string;
  39143. };
  39144. }
  39145. declare module BABYLON {
  39146. /**
  39147. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39148. */
  39149. export class StereoscopicInterlacePostProcess extends PostProcess {
  39150. private _stepSize;
  39151. private _passedProcess;
  39152. /**
  39153. * Initializes a StereoscopicInterlacePostProcess
  39154. * @param name The name of the effect.
  39155. * @param rigCameras The rig cameras to be appled to the post process
  39156. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39157. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39158. * @param engine The engine which the post process will be applied. (default: current engine)
  39159. * @param reusable If the post process can be reused on the same frame. (default: false)
  39160. */
  39161. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39162. }
  39163. }
  39164. declare module BABYLON {
  39165. /**
  39166. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39167. * @see http://doc.babylonjs.com/features/cameras
  39168. */
  39169. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39170. /**
  39171. * Creates a new StereoscopicArcRotateCamera
  39172. * @param name defines camera name
  39173. * @param alpha defines alpha angle (in radians)
  39174. * @param beta defines beta angle (in radians)
  39175. * @param radius defines radius
  39176. * @param target defines camera target
  39177. * @param interaxialDistance defines distance between each color axis
  39178. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39179. * @param scene defines the hosting scene
  39180. */
  39181. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39182. /**
  39183. * Gets camera class name
  39184. * @returns StereoscopicArcRotateCamera
  39185. */
  39186. getClassName(): string;
  39187. }
  39188. }
  39189. declare module BABYLON {
  39190. /**
  39191. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39192. * @see http://doc.babylonjs.com/features/cameras
  39193. */
  39194. export class StereoscopicFreeCamera extends FreeCamera {
  39195. /**
  39196. * Creates a new StereoscopicFreeCamera
  39197. * @param name defines camera name
  39198. * @param position defines initial position
  39199. * @param interaxialDistance defines distance between each color axis
  39200. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39201. * @param scene defines the hosting scene
  39202. */
  39203. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39204. /**
  39205. * Gets camera class name
  39206. * @returns StereoscopicFreeCamera
  39207. */
  39208. getClassName(): string;
  39209. }
  39210. }
  39211. declare module BABYLON {
  39212. /**
  39213. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39214. * @see http://doc.babylonjs.com/features/cameras
  39215. */
  39216. export class StereoscopicGamepadCamera extends GamepadCamera {
  39217. /**
  39218. * Creates a new StereoscopicGamepadCamera
  39219. * @param name defines camera name
  39220. * @param position defines initial position
  39221. * @param interaxialDistance defines distance between each color axis
  39222. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39223. * @param scene defines the hosting scene
  39224. */
  39225. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39226. /**
  39227. * Gets camera class name
  39228. * @returns StereoscopicGamepadCamera
  39229. */
  39230. getClassName(): string;
  39231. }
  39232. }
  39233. declare module BABYLON {
  39234. /**
  39235. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39236. * @see http://doc.babylonjs.com/features/cameras
  39237. */
  39238. export class StereoscopicUniversalCamera extends UniversalCamera {
  39239. /**
  39240. * Creates a new StereoscopicUniversalCamera
  39241. * @param name defines camera name
  39242. * @param position defines initial position
  39243. * @param interaxialDistance defines distance between each color axis
  39244. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39245. * @param scene defines the hosting scene
  39246. */
  39247. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39248. /**
  39249. * Gets camera class name
  39250. * @returns StereoscopicUniversalCamera
  39251. */
  39252. getClassName(): string;
  39253. }
  39254. }
  39255. declare module BABYLON {
  39256. /**
  39257. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39258. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39259. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39260. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39261. */
  39262. export class VirtualJoysticksCamera extends FreeCamera {
  39263. /**
  39264. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39265. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39266. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39267. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39268. * @param name Define the name of the camera in the scene
  39269. * @param position Define the start position of the camera in the scene
  39270. * @param scene Define the scene the camera belongs to
  39271. */
  39272. constructor(name: string, position: Vector3, scene: Scene);
  39273. /**
  39274. * Gets the current object class name.
  39275. * @return the class name
  39276. */
  39277. getClassName(): string;
  39278. }
  39279. }
  39280. declare module BABYLON {
  39281. /**
  39282. * This represents all the required metrics to create a VR camera.
  39283. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39284. */
  39285. export class VRCameraMetrics {
  39286. /**
  39287. * Define the horizontal resolution off the screen.
  39288. */
  39289. hResolution: number;
  39290. /**
  39291. * Define the vertical resolution off the screen.
  39292. */
  39293. vResolution: number;
  39294. /**
  39295. * Define the horizontal screen size.
  39296. */
  39297. hScreenSize: number;
  39298. /**
  39299. * Define the vertical screen size.
  39300. */
  39301. vScreenSize: number;
  39302. /**
  39303. * Define the vertical screen center position.
  39304. */
  39305. vScreenCenter: number;
  39306. /**
  39307. * Define the distance of the eyes to the screen.
  39308. */
  39309. eyeToScreenDistance: number;
  39310. /**
  39311. * Define the distance between both lenses
  39312. */
  39313. lensSeparationDistance: number;
  39314. /**
  39315. * Define the distance between both viewer's eyes.
  39316. */
  39317. interpupillaryDistance: number;
  39318. /**
  39319. * Define the distortion factor of the VR postprocess.
  39320. * Please, touch with care.
  39321. */
  39322. distortionK: number[];
  39323. /**
  39324. * Define the chromatic aberration correction factors for the VR post process.
  39325. */
  39326. chromaAbCorrection: number[];
  39327. /**
  39328. * Define the scale factor of the post process.
  39329. * The smaller the better but the slower.
  39330. */
  39331. postProcessScaleFactor: number;
  39332. /**
  39333. * Define an offset for the lens center.
  39334. */
  39335. lensCenterOffset: number;
  39336. /**
  39337. * Define if the current vr camera should compensate the distortion of the lense or not.
  39338. */
  39339. compensateDistortion: boolean;
  39340. /**
  39341. * Defines if multiview should be enabled when rendering (Default: false)
  39342. */
  39343. multiviewEnabled: boolean;
  39344. /**
  39345. * Gets the rendering aspect ratio based on the provided resolutions.
  39346. */
  39347. readonly aspectRatio: number;
  39348. /**
  39349. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39350. */
  39351. readonly aspectRatioFov: number;
  39352. /**
  39353. * @hidden
  39354. */
  39355. readonly leftHMatrix: Matrix;
  39356. /**
  39357. * @hidden
  39358. */
  39359. readonly rightHMatrix: Matrix;
  39360. /**
  39361. * @hidden
  39362. */
  39363. readonly leftPreViewMatrix: Matrix;
  39364. /**
  39365. * @hidden
  39366. */
  39367. readonly rightPreViewMatrix: Matrix;
  39368. /**
  39369. * Get the default VRMetrics based on the most generic setup.
  39370. * @returns the default vr metrics
  39371. */
  39372. static GetDefault(): VRCameraMetrics;
  39373. }
  39374. }
  39375. declare module BABYLON {
  39376. /** @hidden */
  39377. export var vrDistortionCorrectionPixelShader: {
  39378. name: string;
  39379. shader: string;
  39380. };
  39381. }
  39382. declare module BABYLON {
  39383. /**
  39384. * VRDistortionCorrectionPostProcess used for mobile VR
  39385. */
  39386. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39387. private _isRightEye;
  39388. private _distortionFactors;
  39389. private _postProcessScaleFactor;
  39390. private _lensCenterOffset;
  39391. private _scaleIn;
  39392. private _scaleFactor;
  39393. private _lensCenter;
  39394. /**
  39395. * Initializes the VRDistortionCorrectionPostProcess
  39396. * @param name The name of the effect.
  39397. * @param camera The camera to apply the render pass to.
  39398. * @param isRightEye If this is for the right eye distortion
  39399. * @param vrMetrics All the required metrics for the VR camera
  39400. */
  39401. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39402. }
  39403. }
  39404. declare module BABYLON {
  39405. /**
  39406. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39407. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39408. */
  39409. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39410. /**
  39411. * Creates a new VRDeviceOrientationArcRotateCamera
  39412. * @param name defines camera name
  39413. * @param alpha defines the camera rotation along the logitudinal axis
  39414. * @param beta defines the camera rotation along the latitudinal axis
  39415. * @param radius defines the camera distance from its target
  39416. * @param target defines the camera target
  39417. * @param scene defines the scene the camera belongs to
  39418. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39419. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39420. */
  39421. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39422. /**
  39423. * Gets camera class name
  39424. * @returns VRDeviceOrientationArcRotateCamera
  39425. */
  39426. getClassName(): string;
  39427. }
  39428. }
  39429. declare module BABYLON {
  39430. /**
  39431. * Camera used to simulate VR rendering (based on FreeCamera)
  39432. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39433. */
  39434. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39435. /**
  39436. * Creates a new VRDeviceOrientationFreeCamera
  39437. * @param name defines camera name
  39438. * @param position defines the start position of the camera
  39439. * @param scene defines the scene the camera belongs to
  39440. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39441. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39442. */
  39443. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39444. /**
  39445. * Gets camera class name
  39446. * @returns VRDeviceOrientationFreeCamera
  39447. */
  39448. getClassName(): string;
  39449. }
  39450. }
  39451. declare module BABYLON {
  39452. /**
  39453. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39454. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39455. */
  39456. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39457. /**
  39458. * Creates a new VRDeviceOrientationGamepadCamera
  39459. * @param name defines camera name
  39460. * @param position defines the start position of the camera
  39461. * @param scene defines the scene the camera belongs to
  39462. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39463. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39464. */
  39465. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39466. /**
  39467. * Gets camera class name
  39468. * @returns VRDeviceOrientationGamepadCamera
  39469. */
  39470. getClassName(): string;
  39471. }
  39472. }
  39473. declare module BABYLON {
  39474. /**
  39475. * Base class of materials working in push mode in babylon JS
  39476. * @hidden
  39477. */
  39478. export class PushMaterial extends Material {
  39479. protected _activeEffect: Effect;
  39480. protected _normalMatrix: Matrix;
  39481. /**
  39482. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39483. * This means that the material can keep using a previous shader while a new one is being compiled.
  39484. * This is mostly used when shader parallel compilation is supported (true by default)
  39485. */
  39486. allowShaderHotSwapping: boolean;
  39487. constructor(name: string, scene: Scene);
  39488. getEffect(): Effect;
  39489. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39490. /**
  39491. * Binds the given world matrix to the active effect
  39492. *
  39493. * @param world the matrix to bind
  39494. */
  39495. bindOnlyWorldMatrix(world: Matrix): void;
  39496. /**
  39497. * Binds the given normal matrix to the active effect
  39498. *
  39499. * @param normalMatrix the matrix to bind
  39500. */
  39501. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39502. bind(world: Matrix, mesh?: Mesh): void;
  39503. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39504. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39505. }
  39506. }
  39507. declare module BABYLON {
  39508. /**
  39509. * This groups all the flags used to control the materials channel.
  39510. */
  39511. export class MaterialFlags {
  39512. private static _DiffuseTextureEnabled;
  39513. /**
  39514. * Are diffuse textures enabled in the application.
  39515. */
  39516. static DiffuseTextureEnabled: boolean;
  39517. private static _AmbientTextureEnabled;
  39518. /**
  39519. * Are ambient textures enabled in the application.
  39520. */
  39521. static AmbientTextureEnabled: boolean;
  39522. private static _OpacityTextureEnabled;
  39523. /**
  39524. * Are opacity textures enabled in the application.
  39525. */
  39526. static OpacityTextureEnabled: boolean;
  39527. private static _ReflectionTextureEnabled;
  39528. /**
  39529. * Are reflection textures enabled in the application.
  39530. */
  39531. static ReflectionTextureEnabled: boolean;
  39532. private static _EmissiveTextureEnabled;
  39533. /**
  39534. * Are emissive textures enabled in the application.
  39535. */
  39536. static EmissiveTextureEnabled: boolean;
  39537. private static _SpecularTextureEnabled;
  39538. /**
  39539. * Are specular textures enabled in the application.
  39540. */
  39541. static SpecularTextureEnabled: boolean;
  39542. private static _BumpTextureEnabled;
  39543. /**
  39544. * Are bump textures enabled in the application.
  39545. */
  39546. static BumpTextureEnabled: boolean;
  39547. private static _LightmapTextureEnabled;
  39548. /**
  39549. * Are lightmap textures enabled in the application.
  39550. */
  39551. static LightmapTextureEnabled: boolean;
  39552. private static _RefractionTextureEnabled;
  39553. /**
  39554. * Are refraction textures enabled in the application.
  39555. */
  39556. static RefractionTextureEnabled: boolean;
  39557. private static _ColorGradingTextureEnabled;
  39558. /**
  39559. * Are color grading textures enabled in the application.
  39560. */
  39561. static ColorGradingTextureEnabled: boolean;
  39562. private static _FresnelEnabled;
  39563. /**
  39564. * Are fresnels enabled in the application.
  39565. */
  39566. static FresnelEnabled: boolean;
  39567. private static _ClearCoatTextureEnabled;
  39568. /**
  39569. * Are clear coat textures enabled in the application.
  39570. */
  39571. static ClearCoatTextureEnabled: boolean;
  39572. private static _ClearCoatBumpTextureEnabled;
  39573. /**
  39574. * Are clear coat bump textures enabled in the application.
  39575. */
  39576. static ClearCoatBumpTextureEnabled: boolean;
  39577. private static _ClearCoatTintTextureEnabled;
  39578. /**
  39579. * Are clear coat tint textures enabled in the application.
  39580. */
  39581. static ClearCoatTintTextureEnabled: boolean;
  39582. private static _SheenTextureEnabled;
  39583. /**
  39584. * Are sheen textures enabled in the application.
  39585. */
  39586. static SheenTextureEnabled: boolean;
  39587. private static _AnisotropicTextureEnabled;
  39588. /**
  39589. * Are anisotropic textures enabled in the application.
  39590. */
  39591. static AnisotropicTextureEnabled: boolean;
  39592. private static _ThicknessTextureEnabled;
  39593. /**
  39594. * Are thickness textures enabled in the application.
  39595. */
  39596. static ThicknessTextureEnabled: boolean;
  39597. }
  39598. }
  39599. declare module BABYLON {
  39600. /** @hidden */
  39601. export var defaultFragmentDeclaration: {
  39602. name: string;
  39603. shader: string;
  39604. };
  39605. }
  39606. declare module BABYLON {
  39607. /** @hidden */
  39608. export var defaultUboDeclaration: {
  39609. name: string;
  39610. shader: string;
  39611. };
  39612. }
  39613. declare module BABYLON {
  39614. /** @hidden */
  39615. export var lightFragmentDeclaration: {
  39616. name: string;
  39617. shader: string;
  39618. };
  39619. }
  39620. declare module BABYLON {
  39621. /** @hidden */
  39622. export var lightUboDeclaration: {
  39623. name: string;
  39624. shader: string;
  39625. };
  39626. }
  39627. declare module BABYLON {
  39628. /** @hidden */
  39629. export var lightsFragmentFunctions: {
  39630. name: string;
  39631. shader: string;
  39632. };
  39633. }
  39634. declare module BABYLON {
  39635. /** @hidden */
  39636. export var shadowsFragmentFunctions: {
  39637. name: string;
  39638. shader: string;
  39639. };
  39640. }
  39641. declare module BABYLON {
  39642. /** @hidden */
  39643. export var fresnelFunction: {
  39644. name: string;
  39645. shader: string;
  39646. };
  39647. }
  39648. declare module BABYLON {
  39649. /** @hidden */
  39650. export var reflectionFunction: {
  39651. name: string;
  39652. shader: string;
  39653. };
  39654. }
  39655. declare module BABYLON {
  39656. /** @hidden */
  39657. export var bumpFragmentFunctions: {
  39658. name: string;
  39659. shader: string;
  39660. };
  39661. }
  39662. declare module BABYLON {
  39663. /** @hidden */
  39664. export var logDepthDeclaration: {
  39665. name: string;
  39666. shader: string;
  39667. };
  39668. }
  39669. declare module BABYLON {
  39670. /** @hidden */
  39671. export var bumpFragment: {
  39672. name: string;
  39673. shader: string;
  39674. };
  39675. }
  39676. declare module BABYLON {
  39677. /** @hidden */
  39678. export var depthPrePass: {
  39679. name: string;
  39680. shader: string;
  39681. };
  39682. }
  39683. declare module BABYLON {
  39684. /** @hidden */
  39685. export var lightFragment: {
  39686. name: string;
  39687. shader: string;
  39688. };
  39689. }
  39690. declare module BABYLON {
  39691. /** @hidden */
  39692. export var logDepthFragment: {
  39693. name: string;
  39694. shader: string;
  39695. };
  39696. }
  39697. declare module BABYLON {
  39698. /** @hidden */
  39699. export var defaultPixelShader: {
  39700. name: string;
  39701. shader: string;
  39702. };
  39703. }
  39704. declare module BABYLON {
  39705. /** @hidden */
  39706. export var defaultVertexDeclaration: {
  39707. name: string;
  39708. shader: string;
  39709. };
  39710. }
  39711. declare module BABYLON {
  39712. /** @hidden */
  39713. export var bumpVertexDeclaration: {
  39714. name: string;
  39715. shader: string;
  39716. };
  39717. }
  39718. declare module BABYLON {
  39719. /** @hidden */
  39720. export var bumpVertex: {
  39721. name: string;
  39722. shader: string;
  39723. };
  39724. }
  39725. declare module BABYLON {
  39726. /** @hidden */
  39727. export var fogVertex: {
  39728. name: string;
  39729. shader: string;
  39730. };
  39731. }
  39732. declare module BABYLON {
  39733. /** @hidden */
  39734. export var shadowsVertex: {
  39735. name: string;
  39736. shader: string;
  39737. };
  39738. }
  39739. declare module BABYLON {
  39740. /** @hidden */
  39741. export var pointCloudVertex: {
  39742. name: string;
  39743. shader: string;
  39744. };
  39745. }
  39746. declare module BABYLON {
  39747. /** @hidden */
  39748. export var logDepthVertex: {
  39749. name: string;
  39750. shader: string;
  39751. };
  39752. }
  39753. declare module BABYLON {
  39754. /** @hidden */
  39755. export var defaultVertexShader: {
  39756. name: string;
  39757. shader: string;
  39758. };
  39759. }
  39760. declare module BABYLON {
  39761. /** @hidden */
  39762. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39763. MAINUV1: boolean;
  39764. MAINUV2: boolean;
  39765. DIFFUSE: boolean;
  39766. DIFFUSEDIRECTUV: number;
  39767. AMBIENT: boolean;
  39768. AMBIENTDIRECTUV: number;
  39769. OPACITY: boolean;
  39770. OPACITYDIRECTUV: number;
  39771. OPACITYRGB: boolean;
  39772. REFLECTION: boolean;
  39773. EMISSIVE: boolean;
  39774. EMISSIVEDIRECTUV: number;
  39775. SPECULAR: boolean;
  39776. SPECULARDIRECTUV: number;
  39777. BUMP: boolean;
  39778. BUMPDIRECTUV: number;
  39779. PARALLAX: boolean;
  39780. PARALLAXOCCLUSION: boolean;
  39781. SPECULAROVERALPHA: boolean;
  39782. CLIPPLANE: boolean;
  39783. CLIPPLANE2: boolean;
  39784. CLIPPLANE3: boolean;
  39785. CLIPPLANE4: boolean;
  39786. ALPHATEST: boolean;
  39787. DEPTHPREPASS: boolean;
  39788. ALPHAFROMDIFFUSE: boolean;
  39789. POINTSIZE: boolean;
  39790. FOG: boolean;
  39791. SPECULARTERM: boolean;
  39792. DIFFUSEFRESNEL: boolean;
  39793. OPACITYFRESNEL: boolean;
  39794. REFLECTIONFRESNEL: boolean;
  39795. REFRACTIONFRESNEL: boolean;
  39796. EMISSIVEFRESNEL: boolean;
  39797. FRESNEL: boolean;
  39798. NORMAL: boolean;
  39799. UV1: boolean;
  39800. UV2: boolean;
  39801. VERTEXCOLOR: boolean;
  39802. VERTEXALPHA: boolean;
  39803. NUM_BONE_INFLUENCERS: number;
  39804. BonesPerMesh: number;
  39805. BONETEXTURE: boolean;
  39806. INSTANCES: boolean;
  39807. GLOSSINESS: boolean;
  39808. ROUGHNESS: boolean;
  39809. EMISSIVEASILLUMINATION: boolean;
  39810. LINKEMISSIVEWITHDIFFUSE: boolean;
  39811. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39812. LIGHTMAP: boolean;
  39813. LIGHTMAPDIRECTUV: number;
  39814. OBJECTSPACE_NORMALMAP: boolean;
  39815. USELIGHTMAPASSHADOWMAP: boolean;
  39816. REFLECTIONMAP_3D: boolean;
  39817. REFLECTIONMAP_SPHERICAL: boolean;
  39818. REFLECTIONMAP_PLANAR: boolean;
  39819. REFLECTIONMAP_CUBIC: boolean;
  39820. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39821. REFLECTIONMAP_PROJECTION: boolean;
  39822. REFLECTIONMAP_SKYBOX: boolean;
  39823. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39824. REFLECTIONMAP_EXPLICIT: boolean;
  39825. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39826. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39827. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39828. INVERTCUBICMAP: boolean;
  39829. LOGARITHMICDEPTH: boolean;
  39830. REFRACTION: boolean;
  39831. REFRACTIONMAP_3D: boolean;
  39832. REFLECTIONOVERALPHA: boolean;
  39833. TWOSIDEDLIGHTING: boolean;
  39834. SHADOWFLOAT: boolean;
  39835. MORPHTARGETS: boolean;
  39836. MORPHTARGETS_NORMAL: boolean;
  39837. MORPHTARGETS_TANGENT: boolean;
  39838. MORPHTARGETS_UV: boolean;
  39839. NUM_MORPH_INFLUENCERS: number;
  39840. NONUNIFORMSCALING: boolean;
  39841. PREMULTIPLYALPHA: boolean;
  39842. IMAGEPROCESSING: boolean;
  39843. VIGNETTE: boolean;
  39844. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39845. VIGNETTEBLENDMODEOPAQUE: boolean;
  39846. TONEMAPPING: boolean;
  39847. TONEMAPPING_ACES: boolean;
  39848. CONTRAST: boolean;
  39849. COLORCURVES: boolean;
  39850. COLORGRADING: boolean;
  39851. COLORGRADING3D: boolean;
  39852. SAMPLER3DGREENDEPTH: boolean;
  39853. SAMPLER3DBGRMAP: boolean;
  39854. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39855. MULTIVIEW: boolean;
  39856. /**
  39857. * If the reflection texture on this material is in linear color space
  39858. * @hidden
  39859. */
  39860. IS_REFLECTION_LINEAR: boolean;
  39861. /**
  39862. * If the refraction texture on this material is in linear color space
  39863. * @hidden
  39864. */
  39865. IS_REFRACTION_LINEAR: boolean;
  39866. EXPOSURE: boolean;
  39867. constructor();
  39868. setReflectionMode(modeToEnable: string): void;
  39869. }
  39870. /**
  39871. * This is the default material used in Babylon. It is the best trade off between quality
  39872. * and performances.
  39873. * @see http://doc.babylonjs.com/babylon101/materials
  39874. */
  39875. export class StandardMaterial extends PushMaterial {
  39876. private _diffuseTexture;
  39877. /**
  39878. * The basic texture of the material as viewed under a light.
  39879. */
  39880. diffuseTexture: Nullable<BaseTexture>;
  39881. private _ambientTexture;
  39882. /**
  39883. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39884. */
  39885. ambientTexture: Nullable<BaseTexture>;
  39886. private _opacityTexture;
  39887. /**
  39888. * Define the transparency of the material from a texture.
  39889. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39890. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39891. */
  39892. opacityTexture: Nullable<BaseTexture>;
  39893. private _reflectionTexture;
  39894. /**
  39895. * Define the texture used to display the reflection.
  39896. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39897. */
  39898. reflectionTexture: Nullable<BaseTexture>;
  39899. private _emissiveTexture;
  39900. /**
  39901. * Define texture of the material as if self lit.
  39902. * This will be mixed in the final result even in the absence of light.
  39903. */
  39904. emissiveTexture: Nullable<BaseTexture>;
  39905. private _specularTexture;
  39906. /**
  39907. * Define how the color and intensity of the highlight given by the light in the material.
  39908. */
  39909. specularTexture: Nullable<BaseTexture>;
  39910. private _bumpTexture;
  39911. /**
  39912. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39913. * 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.
  39914. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39915. */
  39916. bumpTexture: Nullable<BaseTexture>;
  39917. private _lightmapTexture;
  39918. /**
  39919. * Complex lighting can be computationally expensive to compute at runtime.
  39920. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39921. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39922. */
  39923. lightmapTexture: Nullable<BaseTexture>;
  39924. private _refractionTexture;
  39925. /**
  39926. * Define the texture used to display the refraction.
  39927. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39928. */
  39929. refractionTexture: Nullable<BaseTexture>;
  39930. /**
  39931. * The color of the material lit by the environmental background lighting.
  39932. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39933. */
  39934. ambientColor: Color3;
  39935. /**
  39936. * The basic color of the material as viewed under a light.
  39937. */
  39938. diffuseColor: Color3;
  39939. /**
  39940. * Define how the color and intensity of the highlight given by the light in the material.
  39941. */
  39942. specularColor: Color3;
  39943. /**
  39944. * Define the color of the material as if self lit.
  39945. * This will be mixed in the final result even in the absence of light.
  39946. */
  39947. emissiveColor: Color3;
  39948. /**
  39949. * Defines how sharp are the highlights in the material.
  39950. * The bigger the value the sharper giving a more glossy feeling to the result.
  39951. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39952. */
  39953. specularPower: number;
  39954. private _useAlphaFromDiffuseTexture;
  39955. /**
  39956. * Does the transparency come from the diffuse texture alpha channel.
  39957. */
  39958. useAlphaFromDiffuseTexture: boolean;
  39959. private _useEmissiveAsIllumination;
  39960. /**
  39961. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39962. */
  39963. useEmissiveAsIllumination: boolean;
  39964. private _linkEmissiveWithDiffuse;
  39965. /**
  39966. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39967. * the emissive level when the final color is close to one.
  39968. */
  39969. linkEmissiveWithDiffuse: boolean;
  39970. private _useSpecularOverAlpha;
  39971. /**
  39972. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39973. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39974. */
  39975. useSpecularOverAlpha: boolean;
  39976. private _useReflectionOverAlpha;
  39977. /**
  39978. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39979. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39980. */
  39981. useReflectionOverAlpha: boolean;
  39982. private _disableLighting;
  39983. /**
  39984. * Does lights from the scene impacts this material.
  39985. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39986. */
  39987. disableLighting: boolean;
  39988. private _useObjectSpaceNormalMap;
  39989. /**
  39990. * Allows using an object space normal map (instead of tangent space).
  39991. */
  39992. useObjectSpaceNormalMap: boolean;
  39993. private _useParallax;
  39994. /**
  39995. * Is parallax enabled or not.
  39996. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39997. */
  39998. useParallax: boolean;
  39999. private _useParallaxOcclusion;
  40000. /**
  40001. * Is parallax occlusion enabled or not.
  40002. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40003. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40004. */
  40005. useParallaxOcclusion: boolean;
  40006. /**
  40007. * 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.
  40008. */
  40009. parallaxScaleBias: number;
  40010. private _roughness;
  40011. /**
  40012. * Helps to define how blurry the reflections should appears in the material.
  40013. */
  40014. roughness: number;
  40015. /**
  40016. * In case of refraction, define the value of the index of refraction.
  40017. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40018. */
  40019. indexOfRefraction: number;
  40020. /**
  40021. * Invert the refraction texture alongside the y axis.
  40022. * It can be useful with procedural textures or probe for instance.
  40023. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40024. */
  40025. invertRefractionY: boolean;
  40026. /**
  40027. * Defines the alpha limits in alpha test mode.
  40028. */
  40029. alphaCutOff: number;
  40030. private _useLightmapAsShadowmap;
  40031. /**
  40032. * In case of light mapping, define whether the map contains light or shadow informations.
  40033. */
  40034. useLightmapAsShadowmap: boolean;
  40035. private _diffuseFresnelParameters;
  40036. /**
  40037. * Define the diffuse fresnel parameters of the material.
  40038. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40039. */
  40040. diffuseFresnelParameters: FresnelParameters;
  40041. private _opacityFresnelParameters;
  40042. /**
  40043. * Define the opacity fresnel parameters of the material.
  40044. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40045. */
  40046. opacityFresnelParameters: FresnelParameters;
  40047. private _reflectionFresnelParameters;
  40048. /**
  40049. * Define the reflection fresnel parameters of the material.
  40050. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40051. */
  40052. reflectionFresnelParameters: FresnelParameters;
  40053. private _refractionFresnelParameters;
  40054. /**
  40055. * Define the refraction fresnel parameters of the material.
  40056. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40057. */
  40058. refractionFresnelParameters: FresnelParameters;
  40059. private _emissiveFresnelParameters;
  40060. /**
  40061. * Define the emissive fresnel parameters of the material.
  40062. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40063. */
  40064. emissiveFresnelParameters: FresnelParameters;
  40065. private _useReflectionFresnelFromSpecular;
  40066. /**
  40067. * If true automatically deducts the fresnels values from the material specularity.
  40068. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40069. */
  40070. useReflectionFresnelFromSpecular: boolean;
  40071. private _useGlossinessFromSpecularMapAlpha;
  40072. /**
  40073. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40074. */
  40075. useGlossinessFromSpecularMapAlpha: boolean;
  40076. private _maxSimultaneousLights;
  40077. /**
  40078. * Defines the maximum number of lights that can be used in the material
  40079. */
  40080. maxSimultaneousLights: number;
  40081. private _invertNormalMapX;
  40082. /**
  40083. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40084. */
  40085. invertNormalMapX: boolean;
  40086. private _invertNormalMapY;
  40087. /**
  40088. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40089. */
  40090. invertNormalMapY: boolean;
  40091. private _twoSidedLighting;
  40092. /**
  40093. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40094. */
  40095. twoSidedLighting: boolean;
  40096. /**
  40097. * Default configuration related to image processing available in the standard Material.
  40098. */
  40099. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40100. /**
  40101. * Gets the image processing configuration used either in this material.
  40102. */
  40103. /**
  40104. * Sets the Default image processing configuration used either in the this material.
  40105. *
  40106. * If sets to null, the scene one is in use.
  40107. */
  40108. imageProcessingConfiguration: ImageProcessingConfiguration;
  40109. /**
  40110. * Keep track of the image processing observer to allow dispose and replace.
  40111. */
  40112. private _imageProcessingObserver;
  40113. /**
  40114. * Attaches a new image processing configuration to the Standard Material.
  40115. * @param configuration
  40116. */
  40117. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40118. /**
  40119. * Gets wether the color curves effect is enabled.
  40120. */
  40121. /**
  40122. * Sets wether the color curves effect is enabled.
  40123. */
  40124. cameraColorCurvesEnabled: boolean;
  40125. /**
  40126. * Gets wether the color grading effect is enabled.
  40127. */
  40128. /**
  40129. * Gets wether the color grading effect is enabled.
  40130. */
  40131. cameraColorGradingEnabled: boolean;
  40132. /**
  40133. * Gets wether tonemapping is enabled or not.
  40134. */
  40135. /**
  40136. * Sets wether tonemapping is enabled or not
  40137. */
  40138. cameraToneMappingEnabled: boolean;
  40139. /**
  40140. * The camera exposure used on this material.
  40141. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40142. * This corresponds to a photographic exposure.
  40143. */
  40144. /**
  40145. * The camera exposure used on this material.
  40146. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40147. * This corresponds to a photographic exposure.
  40148. */
  40149. cameraExposure: number;
  40150. /**
  40151. * Gets The camera contrast used on this material.
  40152. */
  40153. /**
  40154. * Sets The camera contrast used on this material.
  40155. */
  40156. cameraContrast: number;
  40157. /**
  40158. * Gets the Color Grading 2D Lookup Texture.
  40159. */
  40160. /**
  40161. * Sets the Color Grading 2D Lookup Texture.
  40162. */
  40163. cameraColorGradingTexture: Nullable<BaseTexture>;
  40164. /**
  40165. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40166. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40167. * 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;
  40168. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40169. */
  40170. /**
  40171. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40172. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40173. * 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;
  40174. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40175. */
  40176. cameraColorCurves: Nullable<ColorCurves>;
  40177. /**
  40178. * Custom callback helping to override the default shader used in the material.
  40179. */
  40180. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40181. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40182. protected _worldViewProjectionMatrix: Matrix;
  40183. protected _globalAmbientColor: Color3;
  40184. protected _useLogarithmicDepth: boolean;
  40185. /**
  40186. * Instantiates a new standard material.
  40187. * This is the default material used in Babylon. It is the best trade off between quality
  40188. * and performances.
  40189. * @see http://doc.babylonjs.com/babylon101/materials
  40190. * @param name Define the name of the material in the scene
  40191. * @param scene Define the scene the material belong to
  40192. */
  40193. constructor(name: string, scene: Scene);
  40194. /**
  40195. * Gets a boolean indicating that current material needs to register RTT
  40196. */
  40197. readonly hasRenderTargetTextures: boolean;
  40198. /**
  40199. * Gets the current class name of the material e.g. "StandardMaterial"
  40200. * Mainly use in serialization.
  40201. * @returns the class name
  40202. */
  40203. getClassName(): string;
  40204. /**
  40205. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40206. * You can try switching to logarithmic depth.
  40207. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40208. */
  40209. useLogarithmicDepth: boolean;
  40210. /**
  40211. * Specifies if the material will require alpha blending
  40212. * @returns a boolean specifying if alpha blending is needed
  40213. */
  40214. needAlphaBlending(): boolean;
  40215. /**
  40216. * Specifies if this material should be rendered in alpha test mode
  40217. * @returns a boolean specifying if an alpha test is needed.
  40218. */
  40219. needAlphaTesting(): boolean;
  40220. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40221. /**
  40222. * Get the texture used for alpha test purpose.
  40223. * @returns the diffuse texture in case of the standard material.
  40224. */
  40225. getAlphaTestTexture(): Nullable<BaseTexture>;
  40226. /**
  40227. * Get if the submesh is ready to be used and all its information available.
  40228. * Child classes can use it to update shaders
  40229. * @param mesh defines the mesh to check
  40230. * @param subMesh defines which submesh to check
  40231. * @param useInstances specifies that instances should be used
  40232. * @returns a boolean indicating that the submesh is ready or not
  40233. */
  40234. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40235. /**
  40236. * Builds the material UBO layouts.
  40237. * Used internally during the effect preparation.
  40238. */
  40239. buildUniformLayout(): void;
  40240. /**
  40241. * Unbinds the material from the mesh
  40242. */
  40243. unbind(): void;
  40244. /**
  40245. * Binds the submesh to this material by preparing the effect and shader to draw
  40246. * @param world defines the world transformation matrix
  40247. * @param mesh defines the mesh containing the submesh
  40248. * @param subMesh defines the submesh to bind the material to
  40249. */
  40250. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40251. /**
  40252. * Get the list of animatables in the material.
  40253. * @returns the list of animatables object used in the material
  40254. */
  40255. getAnimatables(): IAnimatable[];
  40256. /**
  40257. * Gets the active textures from the material
  40258. * @returns an array of textures
  40259. */
  40260. getActiveTextures(): BaseTexture[];
  40261. /**
  40262. * Specifies if the material uses a texture
  40263. * @param texture defines the texture to check against the material
  40264. * @returns a boolean specifying if the material uses the texture
  40265. */
  40266. hasTexture(texture: BaseTexture): boolean;
  40267. /**
  40268. * Disposes the material
  40269. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40270. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40271. */
  40272. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40273. /**
  40274. * Makes a duplicate of the material, and gives it a new name
  40275. * @param name defines the new name for the duplicated material
  40276. * @returns the cloned material
  40277. */
  40278. clone(name: string): StandardMaterial;
  40279. /**
  40280. * Serializes this material in a JSON representation
  40281. * @returns the serialized material object
  40282. */
  40283. serialize(): any;
  40284. /**
  40285. * Creates a standard material from parsed material data
  40286. * @param source defines the JSON representation of the material
  40287. * @param scene defines the hosting scene
  40288. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40289. * @returns a new standard material
  40290. */
  40291. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40292. /**
  40293. * Are diffuse textures enabled in the application.
  40294. */
  40295. static DiffuseTextureEnabled: boolean;
  40296. /**
  40297. * Are ambient textures enabled in the application.
  40298. */
  40299. static AmbientTextureEnabled: boolean;
  40300. /**
  40301. * Are opacity textures enabled in the application.
  40302. */
  40303. static OpacityTextureEnabled: boolean;
  40304. /**
  40305. * Are reflection textures enabled in the application.
  40306. */
  40307. static ReflectionTextureEnabled: boolean;
  40308. /**
  40309. * Are emissive textures enabled in the application.
  40310. */
  40311. static EmissiveTextureEnabled: boolean;
  40312. /**
  40313. * Are specular textures enabled in the application.
  40314. */
  40315. static SpecularTextureEnabled: boolean;
  40316. /**
  40317. * Are bump textures enabled in the application.
  40318. */
  40319. static BumpTextureEnabled: boolean;
  40320. /**
  40321. * Are lightmap textures enabled in the application.
  40322. */
  40323. static LightmapTextureEnabled: boolean;
  40324. /**
  40325. * Are refraction textures enabled in the application.
  40326. */
  40327. static RefractionTextureEnabled: boolean;
  40328. /**
  40329. * Are color grading textures enabled in the application.
  40330. */
  40331. static ColorGradingTextureEnabled: boolean;
  40332. /**
  40333. * Are fresnels enabled in the application.
  40334. */
  40335. static FresnelEnabled: boolean;
  40336. }
  40337. }
  40338. declare module BABYLON {
  40339. /**
  40340. * A class extending Texture allowing drawing on a texture
  40341. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40342. */
  40343. export class DynamicTexture extends Texture {
  40344. private _generateMipMaps;
  40345. private _canvas;
  40346. private _context;
  40347. private _engine;
  40348. /**
  40349. * Creates a DynamicTexture
  40350. * @param name defines the name of the texture
  40351. * @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
  40352. * @param scene defines the scene where you want the texture
  40353. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40354. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40355. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40356. */
  40357. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40358. /**
  40359. * Get the current class name of the texture useful for serialization or dynamic coding.
  40360. * @returns "DynamicTexture"
  40361. */
  40362. getClassName(): string;
  40363. /**
  40364. * Gets the current state of canRescale
  40365. */
  40366. readonly canRescale: boolean;
  40367. private _recreate;
  40368. /**
  40369. * Scales the texture
  40370. * @param ratio the scale factor to apply to both width and height
  40371. */
  40372. scale(ratio: number): void;
  40373. /**
  40374. * Resizes the texture
  40375. * @param width the new width
  40376. * @param height the new height
  40377. */
  40378. scaleTo(width: number, height: number): void;
  40379. /**
  40380. * Gets the context of the canvas used by the texture
  40381. * @returns the canvas context of the dynamic texture
  40382. */
  40383. getContext(): CanvasRenderingContext2D;
  40384. /**
  40385. * Clears the texture
  40386. */
  40387. clear(): void;
  40388. /**
  40389. * Updates the texture
  40390. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40391. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40392. */
  40393. update(invertY?: boolean, premulAlpha?: boolean): void;
  40394. /**
  40395. * Draws text onto the texture
  40396. * @param text defines the text to be drawn
  40397. * @param x defines the placement of the text from the left
  40398. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40399. * @param font defines the font to be used with font-style, font-size, font-name
  40400. * @param color defines the color used for the text
  40401. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40402. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40403. * @param update defines whether texture is immediately update (default is true)
  40404. */
  40405. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40406. /**
  40407. * Clones the texture
  40408. * @returns the clone of the texture.
  40409. */
  40410. clone(): DynamicTexture;
  40411. /**
  40412. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40413. * @returns a serialized dynamic texture object
  40414. */
  40415. serialize(): any;
  40416. /** @hidden */
  40417. _rebuild(): void;
  40418. }
  40419. }
  40420. declare module BABYLON {
  40421. /** @hidden */
  40422. export var imageProcessingPixelShader: {
  40423. name: string;
  40424. shader: string;
  40425. };
  40426. }
  40427. declare module BABYLON {
  40428. /**
  40429. * ImageProcessingPostProcess
  40430. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40431. */
  40432. export class ImageProcessingPostProcess extends PostProcess {
  40433. /**
  40434. * Default configuration related to image processing available in the PBR Material.
  40435. */
  40436. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40437. /**
  40438. * Gets the image processing configuration used either in this material.
  40439. */
  40440. /**
  40441. * Sets the Default image processing configuration used either in the this material.
  40442. *
  40443. * If sets to null, the scene one is in use.
  40444. */
  40445. imageProcessingConfiguration: ImageProcessingConfiguration;
  40446. /**
  40447. * Keep track of the image processing observer to allow dispose and replace.
  40448. */
  40449. private _imageProcessingObserver;
  40450. /**
  40451. * Attaches a new image processing configuration to the PBR Material.
  40452. * @param configuration
  40453. */
  40454. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40455. /**
  40456. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40457. */
  40458. /**
  40459. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40460. */
  40461. colorCurves: Nullable<ColorCurves>;
  40462. /**
  40463. * Gets wether the color curves effect is enabled.
  40464. */
  40465. /**
  40466. * Sets wether the color curves effect is enabled.
  40467. */
  40468. colorCurvesEnabled: boolean;
  40469. /**
  40470. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40471. */
  40472. /**
  40473. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40474. */
  40475. colorGradingTexture: Nullable<BaseTexture>;
  40476. /**
  40477. * Gets wether the color grading effect is enabled.
  40478. */
  40479. /**
  40480. * Gets wether the color grading effect is enabled.
  40481. */
  40482. colorGradingEnabled: boolean;
  40483. /**
  40484. * Gets exposure used in the effect.
  40485. */
  40486. /**
  40487. * Sets exposure used in the effect.
  40488. */
  40489. exposure: number;
  40490. /**
  40491. * Gets wether tonemapping is enabled or not.
  40492. */
  40493. /**
  40494. * Sets wether tonemapping is enabled or not
  40495. */
  40496. toneMappingEnabled: boolean;
  40497. /**
  40498. * Gets the type of tone mapping effect.
  40499. */
  40500. /**
  40501. * Sets the type of tone mapping effect.
  40502. */
  40503. toneMappingType: number;
  40504. /**
  40505. * Gets contrast used in the effect.
  40506. */
  40507. /**
  40508. * Sets contrast used in the effect.
  40509. */
  40510. contrast: number;
  40511. /**
  40512. * Gets Vignette stretch size.
  40513. */
  40514. /**
  40515. * Sets Vignette stretch size.
  40516. */
  40517. vignetteStretch: number;
  40518. /**
  40519. * Gets Vignette centre X Offset.
  40520. */
  40521. /**
  40522. * Sets Vignette centre X Offset.
  40523. */
  40524. vignetteCentreX: number;
  40525. /**
  40526. * Gets Vignette centre Y Offset.
  40527. */
  40528. /**
  40529. * Sets Vignette centre Y Offset.
  40530. */
  40531. vignetteCentreY: number;
  40532. /**
  40533. * Gets Vignette weight or intensity of the vignette effect.
  40534. */
  40535. /**
  40536. * Sets Vignette weight or intensity of the vignette effect.
  40537. */
  40538. vignetteWeight: number;
  40539. /**
  40540. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40541. * if vignetteEnabled is set to true.
  40542. */
  40543. /**
  40544. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40545. * if vignetteEnabled is set to true.
  40546. */
  40547. vignetteColor: Color4;
  40548. /**
  40549. * Gets Camera field of view used by the Vignette effect.
  40550. */
  40551. /**
  40552. * Sets Camera field of view used by the Vignette effect.
  40553. */
  40554. vignetteCameraFov: number;
  40555. /**
  40556. * Gets the vignette blend mode allowing different kind of effect.
  40557. */
  40558. /**
  40559. * Sets the vignette blend mode allowing different kind of effect.
  40560. */
  40561. vignetteBlendMode: number;
  40562. /**
  40563. * Gets wether the vignette effect is enabled.
  40564. */
  40565. /**
  40566. * Sets wether the vignette effect is enabled.
  40567. */
  40568. vignetteEnabled: boolean;
  40569. private _fromLinearSpace;
  40570. /**
  40571. * Gets wether the input of the processing is in Gamma or Linear Space.
  40572. */
  40573. /**
  40574. * Sets wether the input of the processing is in Gamma or Linear Space.
  40575. */
  40576. fromLinearSpace: boolean;
  40577. /**
  40578. * Defines cache preventing GC.
  40579. */
  40580. private _defines;
  40581. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40582. /**
  40583. * "ImageProcessingPostProcess"
  40584. * @returns "ImageProcessingPostProcess"
  40585. */
  40586. getClassName(): string;
  40587. protected _updateParameters(): void;
  40588. dispose(camera?: Camera): void;
  40589. }
  40590. }
  40591. declare module BABYLON {
  40592. /**
  40593. * Class containing static functions to help procedurally build meshes
  40594. */
  40595. export class GroundBuilder {
  40596. /**
  40597. * Creates a ground mesh
  40598. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40599. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40600. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40601. * @param name defines the name of the mesh
  40602. * @param options defines the options used to create the mesh
  40603. * @param scene defines the hosting scene
  40604. * @returns the ground mesh
  40605. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40606. */
  40607. static CreateGround(name: string, options: {
  40608. width?: number;
  40609. height?: number;
  40610. subdivisions?: number;
  40611. subdivisionsX?: number;
  40612. subdivisionsY?: number;
  40613. updatable?: boolean;
  40614. }, scene: any): Mesh;
  40615. /**
  40616. * Creates a tiled ground mesh
  40617. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40618. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40619. * * 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
  40620. * * 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
  40621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40622. * @param name defines the name of the mesh
  40623. * @param options defines the options used to create the mesh
  40624. * @param scene defines the hosting scene
  40625. * @returns the tiled ground mesh
  40626. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40627. */
  40628. static CreateTiledGround(name: string, options: {
  40629. xmin: number;
  40630. zmin: number;
  40631. xmax: number;
  40632. zmax: number;
  40633. subdivisions?: {
  40634. w: number;
  40635. h: number;
  40636. };
  40637. precision?: {
  40638. w: number;
  40639. h: number;
  40640. };
  40641. updatable?: boolean;
  40642. }, scene?: Nullable<Scene>): Mesh;
  40643. /**
  40644. * Creates a ground mesh from a height map
  40645. * * The parameter `url` sets the URL of the height map image resource.
  40646. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40647. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40648. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40649. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40650. * * 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.
  40651. * * 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).
  40652. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40653. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40654. * @param name defines the name of the mesh
  40655. * @param url defines the url to the height map
  40656. * @param options defines the options used to create the mesh
  40657. * @param scene defines the hosting scene
  40658. * @returns the ground mesh
  40659. * @see https://doc.babylonjs.com/babylon101/height_map
  40660. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40661. */
  40662. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40663. width?: number;
  40664. height?: number;
  40665. subdivisions?: number;
  40666. minHeight?: number;
  40667. maxHeight?: number;
  40668. colorFilter?: Color3;
  40669. alphaFilter?: number;
  40670. updatable?: boolean;
  40671. onReady?: (mesh: GroundMesh) => void;
  40672. }, scene?: Nullable<Scene>): GroundMesh;
  40673. }
  40674. }
  40675. declare module BABYLON {
  40676. /**
  40677. * Class containing static functions to help procedurally build meshes
  40678. */
  40679. export class TorusBuilder {
  40680. /**
  40681. * Creates a torus mesh
  40682. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40683. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40684. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40685. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40686. * * 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
  40687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40688. * @param name defines the name of the mesh
  40689. * @param options defines the options used to create the mesh
  40690. * @param scene defines the hosting scene
  40691. * @returns the torus mesh
  40692. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40693. */
  40694. static CreateTorus(name: string, options: {
  40695. diameter?: number;
  40696. thickness?: number;
  40697. tessellation?: number;
  40698. updatable?: boolean;
  40699. sideOrientation?: number;
  40700. frontUVs?: Vector4;
  40701. backUVs?: Vector4;
  40702. }, scene: any): Mesh;
  40703. }
  40704. }
  40705. declare module BABYLON {
  40706. /**
  40707. * Class containing static functions to help procedurally build meshes
  40708. */
  40709. export class CylinderBuilder {
  40710. /**
  40711. * Creates a cylinder or a cone mesh
  40712. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40713. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40714. * * 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.
  40715. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40716. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40717. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40718. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40719. * * 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).
  40720. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40721. * * 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).
  40722. * * 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
  40723. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40724. * * 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
  40725. * * 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.
  40726. * * If `enclose` is false, a ring surface is one element.
  40727. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40728. * * 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
  40729. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40730. * * 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
  40731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40732. * @param name defines the name of the mesh
  40733. * @param options defines the options used to create the mesh
  40734. * @param scene defines the hosting scene
  40735. * @returns the cylinder mesh
  40736. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40737. */
  40738. static CreateCylinder(name: string, options: {
  40739. height?: number;
  40740. diameterTop?: number;
  40741. diameterBottom?: number;
  40742. diameter?: number;
  40743. tessellation?: number;
  40744. subdivisions?: number;
  40745. arc?: number;
  40746. faceColors?: Color4[];
  40747. faceUV?: Vector4[];
  40748. updatable?: boolean;
  40749. hasRings?: boolean;
  40750. enclose?: boolean;
  40751. cap?: number;
  40752. sideOrientation?: number;
  40753. frontUVs?: Vector4;
  40754. backUVs?: Vector4;
  40755. }, scene: any): Mesh;
  40756. }
  40757. }
  40758. declare module BABYLON {
  40759. /**
  40760. * Options to modify the vr teleportation behavior.
  40761. */
  40762. export interface VRTeleportationOptions {
  40763. /**
  40764. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40765. */
  40766. floorMeshName?: string;
  40767. /**
  40768. * A list of meshes to be used as the teleportation floor. (default: empty)
  40769. */
  40770. floorMeshes?: Mesh[];
  40771. }
  40772. /**
  40773. * Options to modify the vr experience helper's behavior.
  40774. */
  40775. export interface VRExperienceHelperOptions extends WebVROptions {
  40776. /**
  40777. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40778. */
  40779. createDeviceOrientationCamera?: boolean;
  40780. /**
  40781. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40782. */
  40783. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40784. /**
  40785. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40786. */
  40787. laserToggle?: boolean;
  40788. /**
  40789. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40790. */
  40791. floorMeshes?: Mesh[];
  40792. /**
  40793. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40794. */
  40795. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40796. }
  40797. /**
  40798. * Event containing information after VR has been entered
  40799. */
  40800. export class OnAfterEnteringVRObservableEvent {
  40801. /**
  40802. * If entering vr was successful
  40803. */
  40804. success: boolean;
  40805. }
  40806. /**
  40807. * Helps to quickly add VR support to an existing scene.
  40808. * See http://doc.babylonjs.com/how_to/webvr_helper
  40809. */
  40810. export class VRExperienceHelper {
  40811. /** Options to modify the vr experience helper's behavior. */
  40812. webVROptions: VRExperienceHelperOptions;
  40813. private _scene;
  40814. private _position;
  40815. private _btnVR;
  40816. private _btnVRDisplayed;
  40817. private _webVRsupported;
  40818. private _webVRready;
  40819. private _webVRrequesting;
  40820. private _webVRpresenting;
  40821. private _hasEnteredVR;
  40822. private _fullscreenVRpresenting;
  40823. private _canvas;
  40824. private _webVRCamera;
  40825. private _vrDeviceOrientationCamera;
  40826. private _deviceOrientationCamera;
  40827. private _existingCamera;
  40828. private _onKeyDown;
  40829. private _onVrDisplayPresentChange;
  40830. private _onVRDisplayChanged;
  40831. private _onVRRequestPresentStart;
  40832. private _onVRRequestPresentComplete;
  40833. /**
  40834. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  40835. */
  40836. enableGazeEvenWhenNoPointerLock: boolean;
  40837. /**
  40838. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  40839. */
  40840. exitVROnDoubleTap: boolean;
  40841. /**
  40842. * Observable raised right before entering VR.
  40843. */
  40844. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40845. /**
  40846. * Observable raised when entering VR has completed.
  40847. */
  40848. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40849. /**
  40850. * Observable raised when exiting VR.
  40851. */
  40852. onExitingVRObservable: Observable<VRExperienceHelper>;
  40853. /**
  40854. * Observable raised when controller mesh is loaded.
  40855. */
  40856. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40857. /** Return this.onEnteringVRObservable
  40858. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40859. */
  40860. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40861. /** Return this.onExitingVRObservable
  40862. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40863. */
  40864. readonly onExitingVR: Observable<VRExperienceHelper>;
  40865. /** Return this.onControllerMeshLoadedObservable
  40866. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40867. */
  40868. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40869. private _rayLength;
  40870. private _useCustomVRButton;
  40871. private _teleportationRequested;
  40872. private _teleportActive;
  40873. private _floorMeshName;
  40874. private _floorMeshesCollection;
  40875. private _rotationAllowed;
  40876. private _teleportBackwardsVector;
  40877. private _teleportationTarget;
  40878. private _isDefaultTeleportationTarget;
  40879. private _postProcessMove;
  40880. private _teleportationFillColor;
  40881. private _teleportationBorderColor;
  40882. private _rotationAngle;
  40883. private _haloCenter;
  40884. private _cameraGazer;
  40885. private _padSensibilityUp;
  40886. private _padSensibilityDown;
  40887. private _leftController;
  40888. private _rightController;
  40889. /**
  40890. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40891. */
  40892. onNewMeshSelected: Observable<AbstractMesh>;
  40893. /**
  40894. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  40895. * This observable will provide the mesh and the controller used to select the mesh
  40896. */
  40897. onMeshSelectedWithController: Observable<{
  40898. mesh: AbstractMesh;
  40899. controller: WebVRController;
  40900. }>;
  40901. /**
  40902. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40903. */
  40904. onNewMeshPicked: Observable<PickingInfo>;
  40905. private _circleEase;
  40906. /**
  40907. * Observable raised before camera teleportation
  40908. */
  40909. onBeforeCameraTeleport: Observable<Vector3>;
  40910. /**
  40911. * Observable raised after camera teleportation
  40912. */
  40913. onAfterCameraTeleport: Observable<Vector3>;
  40914. /**
  40915. * Observable raised when current selected mesh gets unselected
  40916. */
  40917. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40918. private _raySelectionPredicate;
  40919. /**
  40920. * To be optionaly changed by user to define custom ray selection
  40921. */
  40922. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40923. /**
  40924. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40925. */
  40926. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40927. /**
  40928. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40929. */
  40930. teleportationEnabled: boolean;
  40931. private _defaultHeight;
  40932. private _teleportationInitialized;
  40933. private _interactionsEnabled;
  40934. private _interactionsRequested;
  40935. private _displayGaze;
  40936. private _displayLaserPointer;
  40937. /**
  40938. * The mesh used to display where the user is going to teleport.
  40939. */
  40940. /**
  40941. * Sets the mesh to be used to display where the user is going to teleport.
  40942. */
  40943. teleportationTarget: Mesh;
  40944. /**
  40945. * 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
  40946. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40947. * See http://doc.babylonjs.com/resources/baking_transformations
  40948. */
  40949. gazeTrackerMesh: Mesh;
  40950. /**
  40951. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40952. */
  40953. updateGazeTrackerScale: boolean;
  40954. /**
  40955. * If the gaze trackers color should be updated when selecting meshes
  40956. */
  40957. updateGazeTrackerColor: boolean;
  40958. /**
  40959. * The gaze tracking mesh corresponding to the left controller
  40960. */
  40961. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40962. /**
  40963. * The gaze tracking mesh corresponding to the right controller
  40964. */
  40965. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40966. /**
  40967. * If the ray of the gaze should be displayed.
  40968. */
  40969. /**
  40970. * Sets if the ray of the gaze should be displayed.
  40971. */
  40972. displayGaze: boolean;
  40973. /**
  40974. * If the ray of the LaserPointer should be displayed.
  40975. */
  40976. /**
  40977. * Sets if the ray of the LaserPointer should be displayed.
  40978. */
  40979. displayLaserPointer: boolean;
  40980. /**
  40981. * The deviceOrientationCamera used as the camera when not in VR.
  40982. */
  40983. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40984. /**
  40985. * Based on the current WebVR support, returns the current VR camera used.
  40986. */
  40987. readonly currentVRCamera: Nullable<Camera>;
  40988. /**
  40989. * The webVRCamera which is used when in VR.
  40990. */
  40991. readonly webVRCamera: WebVRFreeCamera;
  40992. /**
  40993. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40994. */
  40995. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40996. /**
  40997. * The html button that is used to trigger entering into VR.
  40998. */
  40999. readonly vrButton: Nullable<HTMLButtonElement>;
  41000. private readonly _teleportationRequestInitiated;
  41001. /**
  41002. * Defines wether or not Pointer lock should be requested when switching to
  41003. * full screen.
  41004. */
  41005. requestPointerLockOnFullScreen: boolean;
  41006. /**
  41007. * Instantiates a VRExperienceHelper.
  41008. * Helps to quickly add VR support to an existing scene.
  41009. * @param scene The scene the VRExperienceHelper belongs to.
  41010. * @param webVROptions Options to modify the vr experience helper's behavior.
  41011. */
  41012. constructor(scene: Scene,
  41013. /** Options to modify the vr experience helper's behavior. */
  41014. webVROptions?: VRExperienceHelperOptions);
  41015. private _onDefaultMeshLoaded;
  41016. private _onResize;
  41017. private _onFullscreenChange;
  41018. /**
  41019. * Gets a value indicating if we are currently in VR mode.
  41020. */
  41021. readonly isInVRMode: boolean;
  41022. private onVrDisplayPresentChange;
  41023. private onVRDisplayChanged;
  41024. private moveButtonToBottomRight;
  41025. private displayVRButton;
  41026. private updateButtonVisibility;
  41027. private _cachedAngularSensibility;
  41028. /**
  41029. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41030. * Otherwise, will use the fullscreen API.
  41031. */
  41032. enterVR(): void;
  41033. /**
  41034. * Attempt to exit VR, or fullscreen.
  41035. */
  41036. exitVR(): void;
  41037. /**
  41038. * The position of the vr experience helper.
  41039. */
  41040. /**
  41041. * Sets the position of the vr experience helper.
  41042. */
  41043. position: Vector3;
  41044. /**
  41045. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41046. */
  41047. enableInteractions(): void;
  41048. private readonly _noControllerIsActive;
  41049. private beforeRender;
  41050. private _isTeleportationFloor;
  41051. /**
  41052. * Adds a floor mesh to be used for teleportation.
  41053. * @param floorMesh the mesh to be used for teleportation.
  41054. */
  41055. addFloorMesh(floorMesh: Mesh): void;
  41056. /**
  41057. * Removes a floor mesh from being used for teleportation.
  41058. * @param floorMesh the mesh to be removed.
  41059. */
  41060. removeFloorMesh(floorMesh: Mesh): void;
  41061. /**
  41062. * Enables interactions and teleportation using the VR controllers and gaze.
  41063. * @param vrTeleportationOptions options to modify teleportation behavior.
  41064. */
  41065. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41066. private _onNewGamepadConnected;
  41067. private _tryEnableInteractionOnController;
  41068. private _onNewGamepadDisconnected;
  41069. private _enableInteractionOnController;
  41070. private _checkTeleportWithRay;
  41071. private _checkRotate;
  41072. private _checkTeleportBackwards;
  41073. private _enableTeleportationOnController;
  41074. private _createTeleportationCircles;
  41075. private _displayTeleportationTarget;
  41076. private _hideTeleportationTarget;
  41077. private _rotateCamera;
  41078. private _moveTeleportationSelectorTo;
  41079. private _workingVector;
  41080. private _workingQuaternion;
  41081. private _workingMatrix;
  41082. /**
  41083. * Teleports the users feet to the desired location
  41084. * @param location The location where the user's feet should be placed
  41085. */
  41086. teleportCamera(location: Vector3): void;
  41087. private _convertNormalToDirectionOfRay;
  41088. private _castRayAndSelectObject;
  41089. private _notifySelectedMeshUnselected;
  41090. /**
  41091. * Sets the color of the laser ray from the vr controllers.
  41092. * @param color new color for the ray.
  41093. */
  41094. changeLaserColor(color: Color3): void;
  41095. /**
  41096. * Sets the color of the ray from the vr headsets gaze.
  41097. * @param color new color for the ray.
  41098. */
  41099. changeGazeColor(color: Color3): void;
  41100. /**
  41101. * Exits VR and disposes of the vr experience helper
  41102. */
  41103. dispose(): void;
  41104. /**
  41105. * Gets the name of the VRExperienceHelper class
  41106. * @returns "VRExperienceHelper"
  41107. */
  41108. getClassName(): string;
  41109. }
  41110. }
  41111. declare module BABYLON {
  41112. /**
  41113. * Manages an XRSession to work with Babylon's engine
  41114. * @see https://doc.babylonjs.com/how_to/webxr
  41115. */
  41116. export class WebXRSessionManager implements IDisposable {
  41117. private scene;
  41118. /**
  41119. * Fires every time a new xrFrame arrives which can be used to update the camera
  41120. */
  41121. onXRFrameObservable: Observable<any>;
  41122. /**
  41123. * Fires when the xr session is ended either by the device or manually done
  41124. */
  41125. onXRSessionEnded: Observable<any>;
  41126. /**
  41127. * Underlying xr session
  41128. */
  41129. session: XRSession;
  41130. /**
  41131. * Type of reference space used when creating the session
  41132. */
  41133. referenceSpace: XRReferenceSpace;
  41134. /** @hidden */
  41135. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41136. /**
  41137. * Current XR frame
  41138. */
  41139. currentFrame: Nullable<XRFrame>;
  41140. private _xrNavigator;
  41141. private baseLayer;
  41142. /**
  41143. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41144. * @param scene The scene which the session should be created for
  41145. */
  41146. constructor(scene: Scene);
  41147. /**
  41148. * Initializes the manager
  41149. * After initialization enterXR can be called to start an XR session
  41150. * @returns Promise which resolves after it is initialized
  41151. */
  41152. initializeAsync(): Promise<void>;
  41153. /**
  41154. * Initializes an xr session
  41155. * @param xrSessionMode mode to initialize
  41156. * @returns a promise which will resolve once the session has been initialized
  41157. */
  41158. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  41159. /**
  41160. * Sets the reference space on the xr session
  41161. * @param referenceSpace space to set
  41162. * @returns a promise that will resolve once the reference space has been set
  41163. */
  41164. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41165. /**
  41166. * Updates the render state of the session
  41167. * @param state state to set
  41168. * @returns a promise that resolves once the render state has been updated
  41169. */
  41170. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41171. /**
  41172. * Starts rendering to the xr layer
  41173. * @returns a promise that will resolve once rendering has started
  41174. */
  41175. startRenderingToXRAsync(): Promise<void>;
  41176. /**
  41177. * Stops the xrSession and restores the renderloop
  41178. * @returns Promise which resolves after it exits XR
  41179. */
  41180. exitXRAsync(): Promise<unknown>;
  41181. /**
  41182. * Checks if a session would be supported for the creation options specified
  41183. * @param sessionMode session mode to check if supported eg. immersive-vr
  41184. * @returns true if supported
  41185. */
  41186. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41187. /**
  41188. * @hidden
  41189. * Converts the render layer of xrSession to a render target
  41190. * @param session session to create render target for
  41191. * @param scene scene the new render target should be created for
  41192. */
  41193. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41194. /**
  41195. * Disposes of the session manager
  41196. */
  41197. dispose(): void;
  41198. }
  41199. }
  41200. declare module BABYLON {
  41201. /**
  41202. * WebXR Camera which holds the views for the xrSession
  41203. * @see https://doc.babylonjs.com/how_to/webxr
  41204. */
  41205. export class WebXRCamera extends FreeCamera {
  41206. private static _TmpMatrix;
  41207. /**
  41208. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41209. * @param name the name of the camera
  41210. * @param scene the scene to add the camera to
  41211. */
  41212. constructor(name: string, scene: Scene);
  41213. private _updateNumberOfRigCameras;
  41214. /** @hidden */
  41215. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41216. /**
  41217. * Updates the cameras position from the current pose information of the XR session
  41218. * @param xrSessionManager the session containing pose information
  41219. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41220. */
  41221. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41222. }
  41223. }
  41224. declare module BABYLON {
  41225. /**
  41226. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41227. */
  41228. export class WebXRManagedOutputCanvas implements IDisposable {
  41229. private helper;
  41230. private _canvas;
  41231. /**
  41232. * xrpresent context of the canvas which can be used to display/mirror xr content
  41233. */
  41234. canvasContext: WebGLRenderingContext;
  41235. /**
  41236. * xr layer for the canvas
  41237. */
  41238. xrLayer: Nullable<XRWebGLLayer>;
  41239. /**
  41240. * Initializes the xr layer for the session
  41241. * @param xrSession xr session
  41242. * @returns a promise that will resolve once the XR Layer has been created
  41243. */
  41244. initializeXRLayerAsync(xrSession: any): any;
  41245. /**
  41246. * Initializes the canvas to be added/removed upon entering/exiting xr
  41247. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41248. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41249. */
  41250. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41251. /**
  41252. * Disposes of the object
  41253. */
  41254. dispose(): void;
  41255. private _setManagedOutputCanvas;
  41256. private _addCanvas;
  41257. private _removeCanvas;
  41258. }
  41259. }
  41260. declare module BABYLON {
  41261. /**
  41262. * States of the webXR experience
  41263. */
  41264. export enum WebXRState {
  41265. /**
  41266. * Transitioning to being in XR mode
  41267. */
  41268. ENTERING_XR = 0,
  41269. /**
  41270. * Transitioning to non XR mode
  41271. */
  41272. EXITING_XR = 1,
  41273. /**
  41274. * In XR mode and presenting
  41275. */
  41276. IN_XR = 2,
  41277. /**
  41278. * Not entered XR mode
  41279. */
  41280. NOT_IN_XR = 3
  41281. }
  41282. /**
  41283. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41284. * @see https://doc.babylonjs.com/how_to/webxr
  41285. */
  41286. export class WebXRExperienceHelper implements IDisposable {
  41287. private scene;
  41288. /**
  41289. * 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
  41290. */
  41291. container: AbstractMesh;
  41292. /**
  41293. * Camera used to render xr content
  41294. */
  41295. camera: WebXRCamera;
  41296. /**
  41297. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41298. */
  41299. state: WebXRState;
  41300. private _setState;
  41301. private static _TmpVector;
  41302. /**
  41303. * Fires when the state of the experience helper has changed
  41304. */
  41305. onStateChangedObservable: Observable<WebXRState>;
  41306. /** Session manager used to keep track of xr session */
  41307. sessionManager: WebXRSessionManager;
  41308. private _nonVRCamera;
  41309. private _originalSceneAutoClear;
  41310. private _supported;
  41311. /**
  41312. * Creates the experience helper
  41313. * @param scene the scene to attach the experience helper to
  41314. * @returns a promise for the experience helper
  41315. */
  41316. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41317. /**
  41318. * Creates a WebXRExperienceHelper
  41319. * @param scene The scene the helper should be created in
  41320. */
  41321. private constructor();
  41322. /**
  41323. * Exits XR mode and returns the scene to its original state
  41324. * @returns promise that resolves after xr mode has exited
  41325. */
  41326. exitXRAsync(): Promise<unknown>;
  41327. /**
  41328. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41329. * @param sessionCreationOptions options for the XR session
  41330. * @param referenceSpaceType frame of reference of the XR session
  41331. * @param outputCanvas the output canvas that will be used to enter XR mode
  41332. * @returns promise that resolves after xr mode has entered
  41333. */
  41334. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  41335. /**
  41336. * Updates the global position of the camera by moving the camera's container
  41337. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41338. * @param position The desired global position of the camera
  41339. */
  41340. setPositionOfCameraUsingContainer(position: Vector3): void;
  41341. /**
  41342. * Rotates the xr camera by rotating the camera's container around the camera's position
  41343. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41344. * @param rotation the desired quaternion rotation to apply to the camera
  41345. */
  41346. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41347. /**
  41348. * Disposes of the experience helper
  41349. */
  41350. dispose(): void;
  41351. }
  41352. }
  41353. declare module BABYLON {
  41354. /**
  41355. * Button which can be used to enter a different mode of XR
  41356. */
  41357. export class WebXREnterExitUIButton {
  41358. /** button element */
  41359. element: HTMLElement;
  41360. /** XR initialization options for the button */
  41361. sessionMode: XRSessionMode;
  41362. /** Reference space type */
  41363. referenceSpaceType: XRReferenceSpaceType;
  41364. /**
  41365. * Creates a WebXREnterExitUIButton
  41366. * @param element button element
  41367. * @param sessionMode XR initialization session mode
  41368. * @param referenceSpaceType the type of reference space to be used
  41369. */
  41370. constructor(
  41371. /** button element */
  41372. element: HTMLElement,
  41373. /** XR initialization options for the button */
  41374. sessionMode: XRSessionMode,
  41375. /** Reference space type */
  41376. referenceSpaceType: XRReferenceSpaceType);
  41377. /**
  41378. * Overwritable function which can be used to update the button's visuals when the state changes
  41379. * @param activeButton the current active button in the UI
  41380. */
  41381. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41382. }
  41383. /**
  41384. * Options to create the webXR UI
  41385. */
  41386. export class WebXREnterExitUIOptions {
  41387. /**
  41388. * Context to enter xr with
  41389. */
  41390. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  41391. /**
  41392. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41393. */
  41394. customButtons?: Array<WebXREnterExitUIButton>;
  41395. }
  41396. /**
  41397. * UI to allow the user to enter/exit XR mode
  41398. */
  41399. export class WebXREnterExitUI implements IDisposable {
  41400. private scene;
  41401. private _overlay;
  41402. private _buttons;
  41403. private _activeButton;
  41404. /**
  41405. * Fired every time the active button is changed.
  41406. *
  41407. * When xr is entered via a button that launches xr that button will be the callback parameter
  41408. *
  41409. * When exiting xr the callback parameter will be null)
  41410. */
  41411. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41412. /**
  41413. * Creates UI to allow the user to enter/exit XR mode
  41414. * @param scene the scene to add the ui to
  41415. * @param helper the xr experience helper to enter/exit xr with
  41416. * @param options options to configure the UI
  41417. * @returns the created ui
  41418. */
  41419. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41420. private constructor();
  41421. private _updateButtons;
  41422. /**
  41423. * Disposes of the object
  41424. */
  41425. dispose(): void;
  41426. }
  41427. }
  41428. declare module BABYLON {
  41429. /**
  41430. * Represents an XR input
  41431. */
  41432. export class WebXRController {
  41433. private scene;
  41434. /** The underlying input source for the controller */
  41435. inputSource: XRInputSource;
  41436. private parentContainer;
  41437. /**
  41438. * 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
  41439. */
  41440. grip?: AbstractMesh;
  41441. /**
  41442. * Pointer which can be used to select objects or attach a visible laser to
  41443. */
  41444. pointer: AbstractMesh;
  41445. /**
  41446. * Event that fires when the controller is removed/disposed
  41447. */
  41448. onDisposeObservable: Observable<{}>;
  41449. private _tmpMatrix;
  41450. private _tmpQuaternion;
  41451. private _tmpVector;
  41452. /**
  41453. * Creates the controller
  41454. * @see https://doc.babylonjs.com/how_to/webxr
  41455. * @param scene the scene which the controller should be associated to
  41456. * @param inputSource the underlying input source for the controller
  41457. * @param parentContainer parent that the controller meshes should be children of
  41458. */
  41459. constructor(scene: Scene,
  41460. /** The underlying input source for the controller */
  41461. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41462. /**
  41463. * Updates the controller pose based on the given XRFrame
  41464. * @param xrFrame xr frame to update the pose with
  41465. * @param referenceSpace reference space to use
  41466. */
  41467. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41468. /**
  41469. * Gets a world space ray coming from the controller
  41470. * @param result the resulting ray
  41471. */
  41472. getWorldPointerRayToRef(result: Ray): void;
  41473. /**
  41474. * Disposes of the object
  41475. */
  41476. dispose(): void;
  41477. }
  41478. }
  41479. declare module BABYLON {
  41480. /**
  41481. * XR input used to track XR inputs such as controllers/rays
  41482. */
  41483. export class WebXRInput implements IDisposable {
  41484. /**
  41485. * Base experience the input listens to
  41486. */
  41487. baseExperience: WebXRExperienceHelper;
  41488. /**
  41489. * XR controllers being tracked
  41490. */
  41491. controllers: Array<WebXRController>;
  41492. private _frameObserver;
  41493. private _stateObserver;
  41494. /**
  41495. * Event when a controller has been connected/added
  41496. */
  41497. onControllerAddedObservable: Observable<WebXRController>;
  41498. /**
  41499. * Event when a controller has been removed/disconnected
  41500. */
  41501. onControllerRemovedObservable: Observable<WebXRController>;
  41502. /**
  41503. * Initializes the WebXRInput
  41504. * @param baseExperience experience helper which the input should be created for
  41505. */
  41506. constructor(
  41507. /**
  41508. * Base experience the input listens to
  41509. */
  41510. baseExperience: WebXRExperienceHelper);
  41511. private _onInputSourcesChange;
  41512. private _addAndRemoveControllers;
  41513. /**
  41514. * Disposes of the object
  41515. */
  41516. dispose(): void;
  41517. }
  41518. }
  41519. declare module BABYLON {
  41520. /**
  41521. * Enables teleportation
  41522. */
  41523. export class WebXRControllerTeleportation {
  41524. private _teleportationFillColor;
  41525. private _teleportationBorderColor;
  41526. private _tmpRay;
  41527. private _tmpVector;
  41528. /**
  41529. * Creates a WebXRControllerTeleportation
  41530. * @param input input manager to add teleportation to
  41531. * @param floorMeshes floormeshes which can be teleported to
  41532. */
  41533. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41534. }
  41535. }
  41536. declare module BABYLON {
  41537. /**
  41538. * Handles pointer input automatically for the pointer of XR controllers
  41539. */
  41540. export class WebXRControllerPointerSelection {
  41541. private static _idCounter;
  41542. private _tmpRay;
  41543. /**
  41544. * Creates a WebXRControllerPointerSelection
  41545. * @param input input manager to setup pointer selection
  41546. */
  41547. constructor(input: WebXRInput);
  41548. private _convertNormalToDirectionOfRay;
  41549. private _updatePointerDistance;
  41550. }
  41551. }
  41552. declare module BABYLON {
  41553. /**
  41554. * Class used to represent data loading progression
  41555. */
  41556. export class SceneLoaderProgressEvent {
  41557. /** defines if data length to load can be evaluated */
  41558. readonly lengthComputable: boolean;
  41559. /** defines the loaded data length */
  41560. readonly loaded: number;
  41561. /** defines the data length to load */
  41562. readonly total: number;
  41563. /**
  41564. * Create a new progress event
  41565. * @param lengthComputable defines if data length to load can be evaluated
  41566. * @param loaded defines the loaded data length
  41567. * @param total defines the data length to load
  41568. */
  41569. constructor(
  41570. /** defines if data length to load can be evaluated */
  41571. lengthComputable: boolean,
  41572. /** defines the loaded data length */
  41573. loaded: number,
  41574. /** defines the data length to load */
  41575. total: number);
  41576. /**
  41577. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41578. * @param event defines the source event
  41579. * @returns a new SceneLoaderProgressEvent
  41580. */
  41581. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41582. }
  41583. /**
  41584. * Interface used by SceneLoader plugins to define supported file extensions
  41585. */
  41586. export interface ISceneLoaderPluginExtensions {
  41587. /**
  41588. * Defines the list of supported extensions
  41589. */
  41590. [extension: string]: {
  41591. isBinary: boolean;
  41592. };
  41593. }
  41594. /**
  41595. * Interface used by SceneLoader plugin factory
  41596. */
  41597. export interface ISceneLoaderPluginFactory {
  41598. /**
  41599. * Defines the name of the factory
  41600. */
  41601. name: string;
  41602. /**
  41603. * Function called to create a new plugin
  41604. * @return the new plugin
  41605. */
  41606. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41607. /**
  41608. * Boolean indicating if the plugin can direct load specific data
  41609. */
  41610. canDirectLoad?: (data: string) => boolean;
  41611. }
  41612. /**
  41613. * Interface used to define a SceneLoader plugin
  41614. */
  41615. export interface ISceneLoaderPlugin {
  41616. /**
  41617. * The friendly name of this plugin.
  41618. */
  41619. name: string;
  41620. /**
  41621. * The file extensions supported by this plugin.
  41622. */
  41623. extensions: string | ISceneLoaderPluginExtensions;
  41624. /**
  41625. * Import meshes into a scene.
  41626. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41627. * @param scene The scene to import into
  41628. * @param data The data to import
  41629. * @param rootUrl The root url for scene and resources
  41630. * @param meshes The meshes array to import into
  41631. * @param particleSystems The particle systems array to import into
  41632. * @param skeletons The skeletons array to import into
  41633. * @param onError The callback when import fails
  41634. * @returns True if successful or false otherwise
  41635. */
  41636. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41637. /**
  41638. * Load into a scene.
  41639. * @param scene The scene to load into
  41640. * @param data The data to import
  41641. * @param rootUrl The root url for scene and resources
  41642. * @param onError The callback when import fails
  41643. * @returns true if successful or false otherwise
  41644. */
  41645. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41646. /**
  41647. * The callback that returns true if the data can be directly loaded.
  41648. */
  41649. canDirectLoad?: (data: string) => boolean;
  41650. /**
  41651. * The callback that allows custom handling of the root url based on the response url.
  41652. */
  41653. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41654. /**
  41655. * Load into an asset container.
  41656. * @param scene The scene to load into
  41657. * @param data The data to import
  41658. * @param rootUrl The root url for scene and resources
  41659. * @param onError The callback when import fails
  41660. * @returns The loaded asset container
  41661. */
  41662. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41663. }
  41664. /**
  41665. * Interface used to define an async SceneLoader plugin
  41666. */
  41667. export interface ISceneLoaderPluginAsync {
  41668. /**
  41669. * The friendly name of this plugin.
  41670. */
  41671. name: string;
  41672. /**
  41673. * The file extensions supported by this plugin.
  41674. */
  41675. extensions: string | ISceneLoaderPluginExtensions;
  41676. /**
  41677. * Import meshes into a scene.
  41678. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41679. * @param scene The scene to import into
  41680. * @param data The data to import
  41681. * @param rootUrl The root url for scene and resources
  41682. * @param onProgress The callback when the load progresses
  41683. * @param fileName Defines the name of the file to load
  41684. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41685. */
  41686. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41687. meshes: AbstractMesh[];
  41688. particleSystems: IParticleSystem[];
  41689. skeletons: Skeleton[];
  41690. animationGroups: AnimationGroup[];
  41691. }>;
  41692. /**
  41693. * Load into a scene.
  41694. * @param scene The scene to load into
  41695. * @param data The data to import
  41696. * @param rootUrl The root url for scene and resources
  41697. * @param onProgress The callback when the load progresses
  41698. * @param fileName Defines the name of the file to load
  41699. * @returns Nothing
  41700. */
  41701. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41702. /**
  41703. * The callback that returns true if the data can be directly loaded.
  41704. */
  41705. canDirectLoad?: (data: string) => boolean;
  41706. /**
  41707. * The callback that allows custom handling of the root url based on the response url.
  41708. */
  41709. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41710. /**
  41711. * Load into an asset container.
  41712. * @param scene The scene to load into
  41713. * @param data The data to import
  41714. * @param rootUrl The root url for scene and resources
  41715. * @param onProgress The callback when the load progresses
  41716. * @param fileName Defines the name of the file to load
  41717. * @returns The loaded asset container
  41718. */
  41719. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41720. }
  41721. /**
  41722. * Class used to load scene from various file formats using registered plugins
  41723. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41724. */
  41725. export class SceneLoader {
  41726. /**
  41727. * No logging while loading
  41728. */
  41729. static readonly NO_LOGGING: number;
  41730. /**
  41731. * Minimal logging while loading
  41732. */
  41733. static readonly MINIMAL_LOGGING: number;
  41734. /**
  41735. * Summary logging while loading
  41736. */
  41737. static readonly SUMMARY_LOGGING: number;
  41738. /**
  41739. * Detailled logging while loading
  41740. */
  41741. static readonly DETAILED_LOGGING: number;
  41742. /**
  41743. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41744. */
  41745. static ForceFullSceneLoadingForIncremental: boolean;
  41746. /**
  41747. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41748. */
  41749. static ShowLoadingScreen: boolean;
  41750. /**
  41751. * Defines the current logging level (while loading the scene)
  41752. * @ignorenaming
  41753. */
  41754. static loggingLevel: number;
  41755. /**
  41756. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41757. */
  41758. static CleanBoneMatrixWeights: boolean;
  41759. /**
  41760. * Event raised when a plugin is used to load a scene
  41761. */
  41762. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41763. private static _registeredPlugins;
  41764. private static _getDefaultPlugin;
  41765. private static _getPluginForExtension;
  41766. private static _getPluginForDirectLoad;
  41767. private static _getPluginForFilename;
  41768. private static _getDirectLoad;
  41769. private static _loadData;
  41770. private static _getFileInfo;
  41771. /**
  41772. * Gets a plugin that can load the given extension
  41773. * @param extension defines the extension to load
  41774. * @returns a plugin or null if none works
  41775. */
  41776. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41777. /**
  41778. * Gets a boolean indicating that the given extension can be loaded
  41779. * @param extension defines the extension to load
  41780. * @returns true if the extension is supported
  41781. */
  41782. static IsPluginForExtensionAvailable(extension: string): boolean;
  41783. /**
  41784. * Adds a new plugin to the list of registered plugins
  41785. * @param plugin defines the plugin to add
  41786. */
  41787. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41788. /**
  41789. * Import meshes into a scene
  41790. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41791. * @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)
  41792. * @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)
  41793. * @param scene the instance of BABYLON.Scene to append to
  41794. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41795. * @param onProgress a callback with a progress event for each file being loaded
  41796. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41797. * @param pluginExtension the extension used to determine the plugin
  41798. * @returns The loaded plugin
  41799. */
  41800. 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>;
  41801. /**
  41802. * Import meshes into a scene
  41803. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41804. * @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)
  41805. * @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)
  41806. * @param scene the instance of BABYLON.Scene to append to
  41807. * @param onProgress a callback with a progress event for each file being loaded
  41808. * @param pluginExtension the extension used to determine the plugin
  41809. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41810. */
  41811. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41812. meshes: AbstractMesh[];
  41813. particleSystems: IParticleSystem[];
  41814. skeletons: Skeleton[];
  41815. animationGroups: AnimationGroup[];
  41816. }>;
  41817. /**
  41818. * Load a scene
  41819. * @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)
  41820. * @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)
  41821. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41822. * @param onSuccess a callback with the scene when import succeeds
  41823. * @param onProgress a callback with a progress event for each file being loaded
  41824. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41825. * @param pluginExtension the extension used to determine the plugin
  41826. * @returns The loaded plugin
  41827. */
  41828. 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>;
  41829. /**
  41830. * Load a scene
  41831. * @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)
  41832. * @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)
  41833. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41834. * @param onProgress a callback with a progress event for each file being loaded
  41835. * @param pluginExtension the extension used to determine the plugin
  41836. * @returns The loaded scene
  41837. */
  41838. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41839. /**
  41840. * Append a scene
  41841. * @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)
  41842. * @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)
  41843. * @param scene is the instance of BABYLON.Scene to append to
  41844. * @param onSuccess a callback with the scene when import succeeds
  41845. * @param onProgress a callback with a progress event for each file being loaded
  41846. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41847. * @param pluginExtension the extension used to determine the plugin
  41848. * @returns The loaded plugin
  41849. */
  41850. 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>;
  41851. /**
  41852. * Append a scene
  41853. * @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)
  41854. * @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)
  41855. * @param scene is the instance of BABYLON.Scene to append to
  41856. * @param onProgress a callback with a progress event for each file being loaded
  41857. * @param pluginExtension the extension used to determine the plugin
  41858. * @returns The given scene
  41859. */
  41860. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41861. /**
  41862. * Load a scene into an asset container
  41863. * @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)
  41864. * @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)
  41865. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41866. * @param onSuccess a callback with the scene when import succeeds
  41867. * @param onProgress a callback with a progress event for each file being loaded
  41868. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41869. * @param pluginExtension the extension used to determine the plugin
  41870. * @returns The loaded plugin
  41871. */
  41872. 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>;
  41873. /**
  41874. * Load a scene into an asset container
  41875. * @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)
  41876. * @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)
  41877. * @param scene is the instance of Scene to append to
  41878. * @param onProgress a callback with a progress event for each file being loaded
  41879. * @param pluginExtension the extension used to determine the plugin
  41880. * @returns The loaded asset container
  41881. */
  41882. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41883. }
  41884. }
  41885. declare module BABYLON {
  41886. /**
  41887. * Generic Controller
  41888. */
  41889. export class GenericController extends WebVRController {
  41890. /**
  41891. * Base Url for the controller model.
  41892. */
  41893. static readonly MODEL_BASE_URL: string;
  41894. /**
  41895. * File name for the controller model.
  41896. */
  41897. static readonly MODEL_FILENAME: string;
  41898. /**
  41899. * Creates a new GenericController from a gamepad
  41900. * @param vrGamepad the gamepad that the controller should be created from
  41901. */
  41902. constructor(vrGamepad: any);
  41903. /**
  41904. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41905. * @param scene scene in which to add meshes
  41906. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41907. */
  41908. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41909. /**
  41910. * Called once for each button that changed state since the last frame
  41911. * @param buttonIdx Which button index changed
  41912. * @param state New state of the button
  41913. * @param changes Which properties on the state changed since last frame
  41914. */
  41915. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41916. }
  41917. }
  41918. declare module BABYLON {
  41919. /**
  41920. * Defines the WindowsMotionController object that the state of the windows motion controller
  41921. */
  41922. export class WindowsMotionController extends WebVRController {
  41923. /**
  41924. * The base url used to load the left and right controller models
  41925. */
  41926. static MODEL_BASE_URL: string;
  41927. /**
  41928. * The name of the left controller model file
  41929. */
  41930. static MODEL_LEFT_FILENAME: string;
  41931. /**
  41932. * The name of the right controller model file
  41933. */
  41934. static MODEL_RIGHT_FILENAME: string;
  41935. /**
  41936. * The controller name prefix for this controller type
  41937. */
  41938. static readonly GAMEPAD_ID_PREFIX: string;
  41939. /**
  41940. * The controller id pattern for this controller type
  41941. */
  41942. private static readonly GAMEPAD_ID_PATTERN;
  41943. private _loadedMeshInfo;
  41944. private readonly _mapping;
  41945. /**
  41946. * Fired when the trackpad on this controller is clicked
  41947. */
  41948. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41949. /**
  41950. * Fired when the trackpad on this controller is modified
  41951. */
  41952. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41953. /**
  41954. * The current x and y values of this controller's trackpad
  41955. */
  41956. trackpad: StickValues;
  41957. /**
  41958. * Creates a new WindowsMotionController from a gamepad
  41959. * @param vrGamepad the gamepad that the controller should be created from
  41960. */
  41961. constructor(vrGamepad: any);
  41962. /**
  41963. * Fired when the trigger on this controller is modified
  41964. */
  41965. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41966. /**
  41967. * Fired when the menu button on this controller is modified
  41968. */
  41969. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41970. /**
  41971. * Fired when the grip button on this controller is modified
  41972. */
  41973. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41974. /**
  41975. * Fired when the thumbstick button on this controller is modified
  41976. */
  41977. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41978. /**
  41979. * Fired when the touchpad button on this controller is modified
  41980. */
  41981. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41982. /**
  41983. * Fired when the touchpad values on this controller are modified
  41984. */
  41985. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41986. private _updateTrackpad;
  41987. /**
  41988. * Called once per frame by the engine.
  41989. */
  41990. update(): void;
  41991. /**
  41992. * Called once for each button that changed state since the last frame
  41993. * @param buttonIdx Which button index changed
  41994. * @param state New state of the button
  41995. * @param changes Which properties on the state changed since last frame
  41996. */
  41997. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41998. /**
  41999. * Moves the buttons on the controller mesh based on their current state
  42000. * @param buttonName the name of the button to move
  42001. * @param buttonValue the value of the button which determines the buttons new position
  42002. */
  42003. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42004. /**
  42005. * Moves the axis on the controller mesh based on its current state
  42006. * @param axis the index of the axis
  42007. * @param axisValue the value of the axis which determines the meshes new position
  42008. * @hidden
  42009. */
  42010. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42011. /**
  42012. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42013. * @param scene scene in which to add meshes
  42014. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42015. */
  42016. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42017. /**
  42018. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42019. * can be transformed by button presses and axes values, based on this._mapping.
  42020. *
  42021. * @param scene scene in which the meshes exist
  42022. * @param meshes list of meshes that make up the controller model to process
  42023. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42024. */
  42025. private processModel;
  42026. private createMeshInfo;
  42027. /**
  42028. * Gets the ray of the controller in the direction the controller is pointing
  42029. * @param length the length the resulting ray should be
  42030. * @returns a ray in the direction the controller is pointing
  42031. */
  42032. getForwardRay(length?: number): Ray;
  42033. /**
  42034. * Disposes of the controller
  42035. */
  42036. dispose(): void;
  42037. }
  42038. }
  42039. declare module BABYLON {
  42040. /**
  42041. * Oculus Touch Controller
  42042. */
  42043. export class OculusTouchController extends WebVRController {
  42044. /**
  42045. * Base Url for the controller model.
  42046. */
  42047. static MODEL_BASE_URL: string;
  42048. /**
  42049. * File name for the left controller model.
  42050. */
  42051. static MODEL_LEFT_FILENAME: string;
  42052. /**
  42053. * File name for the right controller model.
  42054. */
  42055. static MODEL_RIGHT_FILENAME: string;
  42056. /**
  42057. * Base Url for the Quest controller model.
  42058. */
  42059. static QUEST_MODEL_BASE_URL: string;
  42060. /**
  42061. * @hidden
  42062. * If the controllers are running on a device that needs the updated Quest controller models
  42063. */
  42064. static _IsQuest: boolean;
  42065. /**
  42066. * Fired when the secondary trigger on this controller is modified
  42067. */
  42068. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42069. /**
  42070. * Fired when the thumb rest on this controller is modified
  42071. */
  42072. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42073. /**
  42074. * Creates a new OculusTouchController from a gamepad
  42075. * @param vrGamepad the gamepad that the controller should be created from
  42076. */
  42077. constructor(vrGamepad: any);
  42078. /**
  42079. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42080. * @param scene scene in which to add meshes
  42081. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42082. */
  42083. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42084. /**
  42085. * Fired when the A button on this controller is modified
  42086. */
  42087. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42088. /**
  42089. * Fired when the B button on this controller is modified
  42090. */
  42091. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42092. /**
  42093. * Fired when the X button on this controller is modified
  42094. */
  42095. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42096. /**
  42097. * Fired when the Y button on this controller is modified
  42098. */
  42099. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42100. /**
  42101. * Called once for each button that changed state since the last frame
  42102. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42103. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42104. * 2) secondary trigger (same)
  42105. * 3) A (right) X (left), touch, pressed = value
  42106. * 4) B / Y
  42107. * 5) thumb rest
  42108. * @param buttonIdx Which button index changed
  42109. * @param state New state of the button
  42110. * @param changes Which properties on the state changed since last frame
  42111. */
  42112. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42113. }
  42114. }
  42115. declare module BABYLON {
  42116. /**
  42117. * Vive Controller
  42118. */
  42119. export class ViveController extends WebVRController {
  42120. /**
  42121. * Base Url for the controller model.
  42122. */
  42123. static MODEL_BASE_URL: string;
  42124. /**
  42125. * File name for the controller model.
  42126. */
  42127. static MODEL_FILENAME: string;
  42128. /**
  42129. * Creates a new ViveController from a gamepad
  42130. * @param vrGamepad the gamepad that the controller should be created from
  42131. */
  42132. constructor(vrGamepad: any);
  42133. /**
  42134. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42135. * @param scene scene in which to add meshes
  42136. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42137. */
  42138. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42139. /**
  42140. * Fired when the left button on this controller is modified
  42141. */
  42142. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42143. /**
  42144. * Fired when the right button on this controller is modified
  42145. */
  42146. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42147. /**
  42148. * Fired when the menu button on this controller is modified
  42149. */
  42150. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42151. /**
  42152. * Called once for each button that changed state since the last frame
  42153. * Vive mapping:
  42154. * 0: touchpad
  42155. * 1: trigger
  42156. * 2: left AND right buttons
  42157. * 3: menu button
  42158. * @param buttonIdx Which button index changed
  42159. * @param state New state of the button
  42160. * @param changes Which properties on the state changed since last frame
  42161. */
  42162. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42163. }
  42164. }
  42165. declare module BABYLON {
  42166. /**
  42167. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42168. */
  42169. export class WebXRControllerModelLoader {
  42170. /**
  42171. * Creates the WebXRControllerModelLoader
  42172. * @param input xr input that creates the controllers
  42173. */
  42174. constructor(input: WebXRInput);
  42175. }
  42176. }
  42177. declare module BABYLON {
  42178. /**
  42179. * Contains an array of blocks representing the octree
  42180. */
  42181. export interface IOctreeContainer<T> {
  42182. /**
  42183. * Blocks within the octree
  42184. */
  42185. blocks: Array<OctreeBlock<T>>;
  42186. }
  42187. /**
  42188. * Class used to store a cell in an octree
  42189. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42190. */
  42191. export class OctreeBlock<T> {
  42192. /**
  42193. * Gets the content of the current block
  42194. */
  42195. entries: T[];
  42196. /**
  42197. * Gets the list of block children
  42198. */
  42199. blocks: Array<OctreeBlock<T>>;
  42200. private _depth;
  42201. private _maxDepth;
  42202. private _capacity;
  42203. private _minPoint;
  42204. private _maxPoint;
  42205. private _boundingVectors;
  42206. private _creationFunc;
  42207. /**
  42208. * Creates a new block
  42209. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42210. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42211. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42212. * @param depth defines the current depth of this block in the octree
  42213. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42214. * @param creationFunc defines a callback to call when an element is added to the block
  42215. */
  42216. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42217. /**
  42218. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42219. */
  42220. readonly capacity: number;
  42221. /**
  42222. * Gets the minimum vector (in world space) of the block's bounding box
  42223. */
  42224. readonly minPoint: Vector3;
  42225. /**
  42226. * Gets the maximum vector (in world space) of the block's bounding box
  42227. */
  42228. readonly maxPoint: Vector3;
  42229. /**
  42230. * Add a new element to this block
  42231. * @param entry defines the element to add
  42232. */
  42233. addEntry(entry: T): void;
  42234. /**
  42235. * Remove an element from this block
  42236. * @param entry defines the element to remove
  42237. */
  42238. removeEntry(entry: T): void;
  42239. /**
  42240. * Add an array of elements to this block
  42241. * @param entries defines the array of elements to add
  42242. */
  42243. addEntries(entries: T[]): void;
  42244. /**
  42245. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42246. * @param frustumPlanes defines the frustum planes to test
  42247. * @param selection defines the array to store current content if selection is positive
  42248. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42249. */
  42250. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42251. /**
  42252. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42253. * @param sphereCenter defines the bounding sphere center
  42254. * @param sphereRadius defines the bounding sphere radius
  42255. * @param selection defines the array to store current content if selection is positive
  42256. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42257. */
  42258. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42259. /**
  42260. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42261. * @param ray defines the ray to test with
  42262. * @param selection defines the array to store current content if selection is positive
  42263. */
  42264. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42265. /**
  42266. * Subdivide the content into child blocks (this block will then be empty)
  42267. */
  42268. createInnerBlocks(): void;
  42269. /**
  42270. * @hidden
  42271. */
  42272. 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;
  42273. }
  42274. }
  42275. declare module BABYLON {
  42276. /**
  42277. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42278. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42279. */
  42280. export class Octree<T> {
  42281. /** 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.) */
  42282. maxDepth: number;
  42283. /**
  42284. * Blocks within the octree containing objects
  42285. */
  42286. blocks: Array<OctreeBlock<T>>;
  42287. /**
  42288. * Content stored in the octree
  42289. */
  42290. dynamicContent: T[];
  42291. private _maxBlockCapacity;
  42292. private _selectionContent;
  42293. private _creationFunc;
  42294. /**
  42295. * Creates a octree
  42296. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42297. * @param creationFunc function to be used to instatiate the octree
  42298. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42299. * @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.)
  42300. */
  42301. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42302. /** 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.) */
  42303. maxDepth?: number);
  42304. /**
  42305. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42306. * @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);
  42307. * @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);
  42308. * @param entries meshes to be added to the octree blocks
  42309. */
  42310. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42311. /**
  42312. * Adds a mesh to the octree
  42313. * @param entry Mesh to add to the octree
  42314. */
  42315. addMesh(entry: T): void;
  42316. /**
  42317. * Remove an element from the octree
  42318. * @param entry defines the element to remove
  42319. */
  42320. removeMesh(entry: T): void;
  42321. /**
  42322. * Selects an array of meshes within the frustum
  42323. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42324. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42325. * @returns array of meshes within the frustum
  42326. */
  42327. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42328. /**
  42329. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42330. * @param sphereCenter defines the bounding sphere center
  42331. * @param sphereRadius defines the bounding sphere radius
  42332. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42333. * @returns an array of objects that intersect the sphere
  42334. */
  42335. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42336. /**
  42337. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42338. * @param ray defines the ray to test with
  42339. * @returns array of intersected objects
  42340. */
  42341. intersectsRay(ray: Ray): SmartArray<T>;
  42342. /**
  42343. * Adds a mesh into the octree block if it intersects the block
  42344. */
  42345. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42346. /**
  42347. * Adds a submesh into the octree block if it intersects the block
  42348. */
  42349. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42350. }
  42351. }
  42352. declare module BABYLON {
  42353. interface Scene {
  42354. /**
  42355. * @hidden
  42356. * Backing Filed
  42357. */
  42358. _selectionOctree: Octree<AbstractMesh>;
  42359. /**
  42360. * Gets the octree used to boost mesh selection (picking)
  42361. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42362. */
  42363. selectionOctree: Octree<AbstractMesh>;
  42364. /**
  42365. * Creates or updates the octree used to boost selection (picking)
  42366. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42367. * @param maxCapacity defines the maximum capacity per leaf
  42368. * @param maxDepth defines the maximum depth of the octree
  42369. * @returns an octree of AbstractMesh
  42370. */
  42371. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42372. }
  42373. interface AbstractMesh {
  42374. /**
  42375. * @hidden
  42376. * Backing Field
  42377. */
  42378. _submeshesOctree: Octree<SubMesh>;
  42379. /**
  42380. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42381. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42382. * @param maxCapacity defines the maximum size of each block (64 by default)
  42383. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42384. * @returns the new octree
  42385. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42386. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42387. */
  42388. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42389. }
  42390. /**
  42391. * Defines the octree scene component responsible to manage any octrees
  42392. * in a given scene.
  42393. */
  42394. export class OctreeSceneComponent {
  42395. /**
  42396. * The component name help to identify the component in the list of scene components.
  42397. */
  42398. readonly name: string;
  42399. /**
  42400. * The scene the component belongs to.
  42401. */
  42402. scene: Scene;
  42403. /**
  42404. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42405. */
  42406. readonly checksIsEnabled: boolean;
  42407. /**
  42408. * Creates a new instance of the component for the given scene
  42409. * @param scene Defines the scene to register the component in
  42410. */
  42411. constructor(scene: Scene);
  42412. /**
  42413. * Registers the component in a given scene
  42414. */
  42415. register(): void;
  42416. /**
  42417. * Return the list of active meshes
  42418. * @returns the list of active meshes
  42419. */
  42420. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42421. /**
  42422. * Return the list of active sub meshes
  42423. * @param mesh The mesh to get the candidates sub meshes from
  42424. * @returns the list of active sub meshes
  42425. */
  42426. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42427. private _tempRay;
  42428. /**
  42429. * Return the list of sub meshes intersecting with a given local ray
  42430. * @param mesh defines the mesh to find the submesh for
  42431. * @param localRay defines the ray in local space
  42432. * @returns the list of intersecting sub meshes
  42433. */
  42434. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42435. /**
  42436. * Return the list of sub meshes colliding with a collider
  42437. * @param mesh defines the mesh to find the submesh for
  42438. * @param collider defines the collider to evaluate the collision against
  42439. * @returns the list of colliding sub meshes
  42440. */
  42441. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42442. /**
  42443. * Rebuilds the elements related to this component in case of
  42444. * context lost for instance.
  42445. */
  42446. rebuild(): void;
  42447. /**
  42448. * Disposes the component and the associated ressources.
  42449. */
  42450. dispose(): void;
  42451. }
  42452. }
  42453. declare module BABYLON {
  42454. /**
  42455. * Renders a layer on top of an existing scene
  42456. */
  42457. export class UtilityLayerRenderer implements IDisposable {
  42458. /** the original scene that will be rendered on top of */
  42459. originalScene: Scene;
  42460. private _pointerCaptures;
  42461. private _lastPointerEvents;
  42462. private static _DefaultUtilityLayer;
  42463. private static _DefaultKeepDepthUtilityLayer;
  42464. private _sharedGizmoLight;
  42465. private _renderCamera;
  42466. /**
  42467. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42468. * @returns the camera that is used when rendering the utility layer
  42469. */
  42470. getRenderCamera(): Nullable<Camera>;
  42471. /**
  42472. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42473. * @param cam the camera that should be used when rendering the utility layer
  42474. */
  42475. setRenderCamera(cam: Nullable<Camera>): void;
  42476. /**
  42477. * @hidden
  42478. * Light which used by gizmos to get light shading
  42479. */
  42480. _getSharedGizmoLight(): HemisphericLight;
  42481. /**
  42482. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42483. */
  42484. pickUtilitySceneFirst: boolean;
  42485. /**
  42486. * 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)
  42487. */
  42488. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42489. /**
  42490. * 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)
  42491. */
  42492. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42493. /**
  42494. * The scene that is rendered on top of the original scene
  42495. */
  42496. utilityLayerScene: Scene;
  42497. /**
  42498. * If the utility layer should automatically be rendered on top of existing scene
  42499. */
  42500. shouldRender: boolean;
  42501. /**
  42502. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42503. */
  42504. onlyCheckPointerDownEvents: boolean;
  42505. /**
  42506. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42507. */
  42508. processAllEvents: boolean;
  42509. /**
  42510. * Observable raised when the pointer move from the utility layer scene to the main scene
  42511. */
  42512. onPointerOutObservable: Observable<number>;
  42513. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42514. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42515. private _afterRenderObserver;
  42516. private _sceneDisposeObserver;
  42517. private _originalPointerObserver;
  42518. /**
  42519. * Instantiates a UtilityLayerRenderer
  42520. * @param originalScene the original scene that will be rendered on top of
  42521. * @param handleEvents boolean indicating if the utility layer should handle events
  42522. */
  42523. constructor(
  42524. /** the original scene that will be rendered on top of */
  42525. originalScene: Scene, handleEvents?: boolean);
  42526. private _notifyObservers;
  42527. /**
  42528. * Renders the utility layers scene on top of the original scene
  42529. */
  42530. render(): void;
  42531. /**
  42532. * Disposes of the renderer
  42533. */
  42534. dispose(): void;
  42535. private _updateCamera;
  42536. }
  42537. }
  42538. declare module BABYLON {
  42539. /**
  42540. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42541. */
  42542. export class Gizmo implements IDisposable {
  42543. /** The utility layer the gizmo will be added to */
  42544. gizmoLayer: UtilityLayerRenderer;
  42545. /**
  42546. * The root mesh of the gizmo
  42547. */
  42548. _rootMesh: Mesh;
  42549. private _attachedMesh;
  42550. /**
  42551. * Ratio for the scale of the gizmo (Default: 1)
  42552. */
  42553. scaleRatio: number;
  42554. /**
  42555. * If a custom mesh has been set (Default: false)
  42556. */
  42557. protected _customMeshSet: boolean;
  42558. /**
  42559. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42560. * * When set, interactions will be enabled
  42561. */
  42562. attachedMesh: Nullable<AbstractMesh>;
  42563. /**
  42564. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42565. * @param mesh The mesh to replace the default mesh of the gizmo
  42566. */
  42567. setCustomMesh(mesh: Mesh): void;
  42568. /**
  42569. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42570. */
  42571. updateGizmoRotationToMatchAttachedMesh: boolean;
  42572. /**
  42573. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42574. */
  42575. updateGizmoPositionToMatchAttachedMesh: boolean;
  42576. /**
  42577. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42578. */
  42579. updateScale: boolean;
  42580. protected _interactionsEnabled: boolean;
  42581. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42582. private _beforeRenderObserver;
  42583. private _tempVector;
  42584. /**
  42585. * Creates a gizmo
  42586. * @param gizmoLayer The utility layer the gizmo will be added to
  42587. */
  42588. constructor(
  42589. /** The utility layer the gizmo will be added to */
  42590. gizmoLayer?: UtilityLayerRenderer);
  42591. /**
  42592. * Updates the gizmo to match the attached mesh's position/rotation
  42593. */
  42594. protected _update(): void;
  42595. /**
  42596. * Disposes of the gizmo
  42597. */
  42598. dispose(): void;
  42599. }
  42600. }
  42601. declare module BABYLON {
  42602. /**
  42603. * Single plane drag gizmo
  42604. */
  42605. export class PlaneDragGizmo extends Gizmo {
  42606. /**
  42607. * Drag behavior responsible for the gizmos dragging interactions
  42608. */
  42609. dragBehavior: PointerDragBehavior;
  42610. private _pointerObserver;
  42611. /**
  42612. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42613. */
  42614. snapDistance: number;
  42615. /**
  42616. * Event that fires each time the gizmo snaps to a new location.
  42617. * * snapDistance is the the change in distance
  42618. */
  42619. onSnapObservable: Observable<{
  42620. snapDistance: number;
  42621. }>;
  42622. private _plane;
  42623. private _coloredMaterial;
  42624. private _hoverMaterial;
  42625. private _isEnabled;
  42626. private _parent;
  42627. /** @hidden */
  42628. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42629. /** @hidden */
  42630. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42631. /**
  42632. * Creates a PlaneDragGizmo
  42633. * @param gizmoLayer The utility layer the gizmo will be added to
  42634. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42635. * @param color The color of the gizmo
  42636. */
  42637. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42638. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42639. /**
  42640. * If the gizmo is enabled
  42641. */
  42642. isEnabled: boolean;
  42643. /**
  42644. * Disposes of the gizmo
  42645. */
  42646. dispose(): void;
  42647. }
  42648. }
  42649. declare module BABYLON {
  42650. /**
  42651. * Gizmo that enables dragging a mesh along 3 axis
  42652. */
  42653. export class PositionGizmo extends Gizmo {
  42654. /**
  42655. * Internal gizmo used for interactions on the x axis
  42656. */
  42657. xGizmo: AxisDragGizmo;
  42658. /**
  42659. * Internal gizmo used for interactions on the y axis
  42660. */
  42661. yGizmo: AxisDragGizmo;
  42662. /**
  42663. * Internal gizmo used for interactions on the z axis
  42664. */
  42665. zGizmo: AxisDragGizmo;
  42666. /**
  42667. * Internal gizmo used for interactions on the yz plane
  42668. */
  42669. xPlaneGizmo: PlaneDragGizmo;
  42670. /**
  42671. * Internal gizmo used for interactions on the xz plane
  42672. */
  42673. yPlaneGizmo: PlaneDragGizmo;
  42674. /**
  42675. * Internal gizmo used for interactions on the xy plane
  42676. */
  42677. zPlaneGizmo: PlaneDragGizmo;
  42678. /**
  42679. * private variables
  42680. */
  42681. private _meshAttached;
  42682. private _updateGizmoRotationToMatchAttachedMesh;
  42683. private _snapDistance;
  42684. private _scaleRatio;
  42685. /** Fires an event when any of it's sub gizmos are dragged */
  42686. onDragStartObservable: Observable<unknown>;
  42687. /** Fires an event when any of it's sub gizmos are released from dragging */
  42688. onDragEndObservable: Observable<unknown>;
  42689. /**
  42690. * If set to true, planar drag is enabled
  42691. */
  42692. private _planarGizmoEnabled;
  42693. attachedMesh: Nullable<AbstractMesh>;
  42694. /**
  42695. * Creates a PositionGizmo
  42696. * @param gizmoLayer The utility layer the gizmo will be added to
  42697. */
  42698. constructor(gizmoLayer?: UtilityLayerRenderer);
  42699. /**
  42700. * If the planar drag gizmo is enabled
  42701. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42702. */
  42703. planarGizmoEnabled: boolean;
  42704. updateGizmoRotationToMatchAttachedMesh: boolean;
  42705. /**
  42706. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42707. */
  42708. snapDistance: number;
  42709. /**
  42710. * Ratio for the scale of the gizmo (Default: 1)
  42711. */
  42712. scaleRatio: number;
  42713. /**
  42714. * Disposes of the gizmo
  42715. */
  42716. dispose(): void;
  42717. /**
  42718. * CustomMeshes are not supported by this gizmo
  42719. * @param mesh The mesh to replace the default mesh of the gizmo
  42720. */
  42721. setCustomMesh(mesh: Mesh): void;
  42722. }
  42723. }
  42724. declare module BABYLON {
  42725. /**
  42726. * Single axis drag gizmo
  42727. */
  42728. export class AxisDragGizmo extends Gizmo {
  42729. /**
  42730. * Drag behavior responsible for the gizmos dragging interactions
  42731. */
  42732. dragBehavior: PointerDragBehavior;
  42733. private _pointerObserver;
  42734. /**
  42735. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42736. */
  42737. snapDistance: number;
  42738. /**
  42739. * Event that fires each time the gizmo snaps to a new location.
  42740. * * snapDistance is the the change in distance
  42741. */
  42742. onSnapObservable: Observable<{
  42743. snapDistance: number;
  42744. }>;
  42745. private _isEnabled;
  42746. private _parent;
  42747. private _arrow;
  42748. private _coloredMaterial;
  42749. private _hoverMaterial;
  42750. /** @hidden */
  42751. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42752. /** @hidden */
  42753. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42754. /**
  42755. * Creates an AxisDragGizmo
  42756. * @param gizmoLayer The utility layer the gizmo will be added to
  42757. * @param dragAxis The axis which the gizmo will be able to drag on
  42758. * @param color The color of the gizmo
  42759. */
  42760. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42761. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42762. /**
  42763. * If the gizmo is enabled
  42764. */
  42765. isEnabled: boolean;
  42766. /**
  42767. * Disposes of the gizmo
  42768. */
  42769. dispose(): void;
  42770. }
  42771. }
  42772. declare module BABYLON.Debug {
  42773. /**
  42774. * The Axes viewer will show 3 axes in a specific point in space
  42775. */
  42776. export class AxesViewer {
  42777. private _xAxis;
  42778. private _yAxis;
  42779. private _zAxis;
  42780. private _scaleLinesFactor;
  42781. private _instanced;
  42782. /**
  42783. * Gets the hosting scene
  42784. */
  42785. scene: Scene;
  42786. /**
  42787. * Gets or sets a number used to scale line length
  42788. */
  42789. scaleLines: number;
  42790. /** Gets the node hierarchy used to render x-axis */
  42791. readonly xAxis: TransformNode;
  42792. /** Gets the node hierarchy used to render y-axis */
  42793. readonly yAxis: TransformNode;
  42794. /** Gets the node hierarchy used to render z-axis */
  42795. readonly zAxis: TransformNode;
  42796. /**
  42797. * Creates a new AxesViewer
  42798. * @param scene defines the hosting scene
  42799. * @param scaleLines defines a number used to scale line length (1 by default)
  42800. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42801. * @param xAxis defines the node hierarchy used to render the x-axis
  42802. * @param yAxis defines the node hierarchy used to render the y-axis
  42803. * @param zAxis defines the node hierarchy used to render the z-axis
  42804. */
  42805. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42806. /**
  42807. * Force the viewer to update
  42808. * @param position defines the position of the viewer
  42809. * @param xaxis defines the x axis of the viewer
  42810. * @param yaxis defines the y axis of the viewer
  42811. * @param zaxis defines the z axis of the viewer
  42812. */
  42813. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42814. /**
  42815. * Creates an instance of this axes viewer.
  42816. * @returns a new axes viewer with instanced meshes
  42817. */
  42818. createInstance(): AxesViewer;
  42819. /** Releases resources */
  42820. dispose(): void;
  42821. private static _SetRenderingGroupId;
  42822. }
  42823. }
  42824. declare module BABYLON.Debug {
  42825. /**
  42826. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42827. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42828. */
  42829. export class BoneAxesViewer extends AxesViewer {
  42830. /**
  42831. * Gets or sets the target mesh where to display the axes viewer
  42832. */
  42833. mesh: Nullable<Mesh>;
  42834. /**
  42835. * Gets or sets the target bone where to display the axes viewer
  42836. */
  42837. bone: Nullable<Bone>;
  42838. /** Gets current position */
  42839. pos: Vector3;
  42840. /** Gets direction of X axis */
  42841. xaxis: Vector3;
  42842. /** Gets direction of Y axis */
  42843. yaxis: Vector3;
  42844. /** Gets direction of Z axis */
  42845. zaxis: Vector3;
  42846. /**
  42847. * Creates a new BoneAxesViewer
  42848. * @param scene defines the hosting scene
  42849. * @param bone defines the target bone
  42850. * @param mesh defines the target mesh
  42851. * @param scaleLines defines a scaling factor for line length (1 by default)
  42852. */
  42853. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42854. /**
  42855. * Force the viewer to update
  42856. */
  42857. update(): void;
  42858. /** Releases resources */
  42859. dispose(): void;
  42860. }
  42861. }
  42862. declare module BABYLON {
  42863. /**
  42864. * Interface used to define scene explorer extensibility option
  42865. */
  42866. export interface IExplorerExtensibilityOption {
  42867. /**
  42868. * Define the option label
  42869. */
  42870. label: string;
  42871. /**
  42872. * Defines the action to execute on click
  42873. */
  42874. action: (entity: any) => void;
  42875. }
  42876. /**
  42877. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42878. */
  42879. export interface IExplorerExtensibilityGroup {
  42880. /**
  42881. * Defines a predicate to test if a given type mut be extended
  42882. */
  42883. predicate: (entity: any) => boolean;
  42884. /**
  42885. * Gets the list of options added to a type
  42886. */
  42887. entries: IExplorerExtensibilityOption[];
  42888. }
  42889. /**
  42890. * Interface used to define the options to use to create the Inspector
  42891. */
  42892. export interface IInspectorOptions {
  42893. /**
  42894. * Display in overlay mode (default: false)
  42895. */
  42896. overlay?: boolean;
  42897. /**
  42898. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42899. */
  42900. globalRoot?: HTMLElement;
  42901. /**
  42902. * Display the Scene explorer
  42903. */
  42904. showExplorer?: boolean;
  42905. /**
  42906. * Display the property inspector
  42907. */
  42908. showInspector?: boolean;
  42909. /**
  42910. * Display in embed mode (both panes on the right)
  42911. */
  42912. embedMode?: boolean;
  42913. /**
  42914. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42915. */
  42916. handleResize?: boolean;
  42917. /**
  42918. * Allow the panes to popup (default: true)
  42919. */
  42920. enablePopup?: boolean;
  42921. /**
  42922. * Allow the panes to be closed by users (default: true)
  42923. */
  42924. enableClose?: boolean;
  42925. /**
  42926. * Optional list of extensibility entries
  42927. */
  42928. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42929. /**
  42930. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42931. */
  42932. inspectorURL?: string;
  42933. }
  42934. interface Scene {
  42935. /**
  42936. * @hidden
  42937. * Backing field
  42938. */
  42939. _debugLayer: DebugLayer;
  42940. /**
  42941. * Gets the debug layer (aka Inspector) associated with the scene
  42942. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42943. */
  42944. debugLayer: DebugLayer;
  42945. }
  42946. /**
  42947. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42948. * what is happening in your scene
  42949. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42950. */
  42951. export class DebugLayer {
  42952. /**
  42953. * Define the url to get the inspector script from.
  42954. * By default it uses the babylonjs CDN.
  42955. * @ignoreNaming
  42956. */
  42957. static InspectorURL: string;
  42958. private _scene;
  42959. private BJSINSPECTOR;
  42960. private _onPropertyChangedObservable?;
  42961. /**
  42962. * Observable triggered when a property is changed through the inspector.
  42963. */
  42964. readonly onPropertyChangedObservable: any;
  42965. /**
  42966. * Instantiates a new debug layer.
  42967. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42968. * what is happening in your scene
  42969. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42970. * @param scene Defines the scene to inspect
  42971. */
  42972. constructor(scene: Scene);
  42973. /** Creates the inspector window. */
  42974. private _createInspector;
  42975. /**
  42976. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42977. * @param entity defines the entity to select
  42978. * @param lineContainerTitle defines the specific block to highlight
  42979. */
  42980. select(entity: any, lineContainerTitle?: string): void;
  42981. /** Get the inspector from bundle or global */
  42982. private _getGlobalInspector;
  42983. /**
  42984. * Get if the inspector is visible or not.
  42985. * @returns true if visible otherwise, false
  42986. */
  42987. isVisible(): boolean;
  42988. /**
  42989. * Hide the inspector and close its window.
  42990. */
  42991. hide(): void;
  42992. /**
  42993. * Launch the debugLayer.
  42994. * @param config Define the configuration of the inspector
  42995. * @return a promise fulfilled when the debug layer is visible
  42996. */
  42997. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42998. }
  42999. }
  43000. declare module BABYLON {
  43001. /**
  43002. * Class containing static functions to help procedurally build meshes
  43003. */
  43004. export class BoxBuilder {
  43005. /**
  43006. * Creates a box mesh
  43007. * * The parameter `size` sets the size (float) of each box side (default 1)
  43008. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43009. * * 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)
  43010. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43011. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43012. * * 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
  43013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43014. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43015. * @param name defines the name of the mesh
  43016. * @param options defines the options used to create the mesh
  43017. * @param scene defines the hosting scene
  43018. * @returns the box mesh
  43019. */
  43020. static CreateBox(name: string, options: {
  43021. size?: number;
  43022. width?: number;
  43023. height?: number;
  43024. depth?: number;
  43025. faceUV?: Vector4[];
  43026. faceColors?: Color4[];
  43027. sideOrientation?: number;
  43028. frontUVs?: Vector4;
  43029. backUVs?: Vector4;
  43030. wrap?: boolean;
  43031. topBaseAt?: number;
  43032. bottomBaseAt?: number;
  43033. updatable?: boolean;
  43034. }, scene?: Nullable<Scene>): Mesh;
  43035. }
  43036. }
  43037. declare module BABYLON {
  43038. /**
  43039. * Class containing static functions to help procedurally build meshes
  43040. */
  43041. export class SphereBuilder {
  43042. /**
  43043. * Creates a sphere mesh
  43044. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43045. * * 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`)
  43046. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43047. * * 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
  43048. * * 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)
  43049. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43050. * * 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
  43051. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43052. * @param name defines the name of the mesh
  43053. * @param options defines the options used to create the mesh
  43054. * @param scene defines the hosting scene
  43055. * @returns the sphere mesh
  43056. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43057. */
  43058. static CreateSphere(name: string, options: {
  43059. segments?: number;
  43060. diameter?: number;
  43061. diameterX?: number;
  43062. diameterY?: number;
  43063. diameterZ?: number;
  43064. arc?: number;
  43065. slice?: number;
  43066. sideOrientation?: number;
  43067. frontUVs?: Vector4;
  43068. backUVs?: Vector4;
  43069. updatable?: boolean;
  43070. }, scene: any): Mesh;
  43071. }
  43072. }
  43073. declare module BABYLON.Debug {
  43074. /**
  43075. * Used to show the physics impostor around the specific mesh
  43076. */
  43077. export class PhysicsViewer {
  43078. /** @hidden */
  43079. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43080. /** @hidden */
  43081. protected _meshes: Array<Nullable<AbstractMesh>>;
  43082. /** @hidden */
  43083. protected _scene: Nullable<Scene>;
  43084. /** @hidden */
  43085. protected _numMeshes: number;
  43086. /** @hidden */
  43087. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43088. private _renderFunction;
  43089. private _utilityLayer;
  43090. private _debugBoxMesh;
  43091. private _debugSphereMesh;
  43092. private _debugCylinderMesh;
  43093. private _debugMaterial;
  43094. private _debugMeshMeshes;
  43095. /**
  43096. * Creates a new PhysicsViewer
  43097. * @param scene defines the hosting scene
  43098. */
  43099. constructor(scene: Scene);
  43100. /** @hidden */
  43101. protected _updateDebugMeshes(): void;
  43102. /**
  43103. * Renders a specified physic impostor
  43104. * @param impostor defines the impostor to render
  43105. * @param targetMesh defines the mesh represented by the impostor
  43106. * @returns the new debug mesh used to render the impostor
  43107. */
  43108. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43109. /**
  43110. * Hides a specified physic impostor
  43111. * @param impostor defines the impostor to hide
  43112. */
  43113. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43114. private _getDebugMaterial;
  43115. private _getDebugBoxMesh;
  43116. private _getDebugSphereMesh;
  43117. private _getDebugCylinderMesh;
  43118. private _getDebugMeshMesh;
  43119. private _getDebugMesh;
  43120. /** Releases all resources */
  43121. dispose(): void;
  43122. }
  43123. }
  43124. declare module BABYLON {
  43125. /**
  43126. * Class containing static functions to help procedurally build meshes
  43127. */
  43128. export class LinesBuilder {
  43129. /**
  43130. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43131. * * 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
  43132. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43133. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43134. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43135. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43136. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43137. * * 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
  43138. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43140. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43141. * @param name defines the name of the new line system
  43142. * @param options defines the options used to create the line system
  43143. * @param scene defines the hosting scene
  43144. * @returns a new line system mesh
  43145. */
  43146. static CreateLineSystem(name: string, options: {
  43147. lines: Vector3[][];
  43148. updatable?: boolean;
  43149. instance?: Nullable<LinesMesh>;
  43150. colors?: Nullable<Color4[][]>;
  43151. useVertexAlpha?: boolean;
  43152. }, scene: Nullable<Scene>): LinesMesh;
  43153. /**
  43154. * Creates a line mesh
  43155. * 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
  43156. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43157. * * The parameter `points` is an array successive Vector3
  43158. * * 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
  43159. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43160. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43161. * * When updating an instance, remember that only point positions can change, not the number of points
  43162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43163. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43164. * @param name defines the name of the new line system
  43165. * @param options defines the options used to create the line system
  43166. * @param scene defines the hosting scene
  43167. * @returns a new line mesh
  43168. */
  43169. static CreateLines(name: string, options: {
  43170. points: Vector3[];
  43171. updatable?: boolean;
  43172. instance?: Nullable<LinesMesh>;
  43173. colors?: Color4[];
  43174. useVertexAlpha?: boolean;
  43175. }, scene?: Nullable<Scene>): LinesMesh;
  43176. /**
  43177. * Creates a dashed line mesh
  43178. * * 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
  43179. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43180. * * The parameter `points` is an array successive Vector3
  43181. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43182. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43183. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43184. * * 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
  43185. * * When updating an instance, remember that only point positions can change, not the number of points
  43186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43187. * @param name defines the name of the mesh
  43188. * @param options defines the options used to create the mesh
  43189. * @param scene defines the hosting scene
  43190. * @returns the dashed line mesh
  43191. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43192. */
  43193. static CreateDashedLines(name: string, options: {
  43194. points: Vector3[];
  43195. dashSize?: number;
  43196. gapSize?: number;
  43197. dashNb?: number;
  43198. updatable?: boolean;
  43199. instance?: LinesMesh;
  43200. }, scene?: Nullable<Scene>): LinesMesh;
  43201. }
  43202. }
  43203. declare module BABYLON {
  43204. /**
  43205. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43206. * in order to better appreciate the issue one might have.
  43207. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43208. */
  43209. export class RayHelper {
  43210. /**
  43211. * Defines the ray we are currently tryin to visualize.
  43212. */
  43213. ray: Nullable<Ray>;
  43214. private _renderPoints;
  43215. private _renderLine;
  43216. private _renderFunction;
  43217. private _scene;
  43218. private _updateToMeshFunction;
  43219. private _attachedToMesh;
  43220. private _meshSpaceDirection;
  43221. private _meshSpaceOrigin;
  43222. /**
  43223. * Helper function to create a colored helper in a scene in one line.
  43224. * @param ray Defines the ray we are currently tryin to visualize
  43225. * @param scene Defines the scene the ray is used in
  43226. * @param color Defines the color we want to see the ray in
  43227. * @returns The newly created ray helper.
  43228. */
  43229. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43230. /**
  43231. * Instantiate a new ray helper.
  43232. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43233. * in order to better appreciate the issue one might have.
  43234. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43235. * @param ray Defines the ray we are currently tryin to visualize
  43236. */
  43237. constructor(ray: Ray);
  43238. /**
  43239. * Shows the ray we are willing to debug.
  43240. * @param scene Defines the scene the ray needs to be rendered in
  43241. * @param color Defines the color the ray needs to be rendered in
  43242. */
  43243. show(scene: Scene, color?: Color3): void;
  43244. /**
  43245. * Hides the ray we are debugging.
  43246. */
  43247. hide(): void;
  43248. private _render;
  43249. /**
  43250. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43251. * @param mesh Defines the mesh we want the helper attached to
  43252. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43253. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43254. * @param length Defines the length of the ray
  43255. */
  43256. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43257. /**
  43258. * Detach the ray helper from the mesh it has previously been attached to.
  43259. */
  43260. detachFromMesh(): void;
  43261. private _updateToMesh;
  43262. /**
  43263. * Dispose the helper and release its associated resources.
  43264. */
  43265. dispose(): void;
  43266. }
  43267. }
  43268. declare module BABYLON.Debug {
  43269. /**
  43270. * Class used to render a debug view of a given skeleton
  43271. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43272. */
  43273. export class SkeletonViewer {
  43274. /** defines the skeleton to render */
  43275. skeleton: Skeleton;
  43276. /** defines the mesh attached to the skeleton */
  43277. mesh: AbstractMesh;
  43278. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43279. autoUpdateBonesMatrices: boolean;
  43280. /** defines the rendering group id to use with the viewer */
  43281. renderingGroupId: number;
  43282. /** Gets or sets the color used to render the skeleton */
  43283. color: Color3;
  43284. private _scene;
  43285. private _debugLines;
  43286. private _debugMesh;
  43287. private _isEnabled;
  43288. private _renderFunction;
  43289. private _utilityLayer;
  43290. /**
  43291. * Returns the mesh used to render the bones
  43292. */
  43293. readonly debugMesh: Nullable<LinesMesh>;
  43294. /**
  43295. * Creates a new SkeletonViewer
  43296. * @param skeleton defines the skeleton to render
  43297. * @param mesh defines the mesh attached to the skeleton
  43298. * @param scene defines the hosting scene
  43299. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43300. * @param renderingGroupId defines the rendering group id to use with the viewer
  43301. */
  43302. constructor(
  43303. /** defines the skeleton to render */
  43304. skeleton: Skeleton,
  43305. /** defines the mesh attached to the skeleton */
  43306. mesh: AbstractMesh, scene: Scene,
  43307. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43308. autoUpdateBonesMatrices?: boolean,
  43309. /** defines the rendering group id to use with the viewer */
  43310. renderingGroupId?: number);
  43311. /** Gets or sets a boolean indicating if the viewer is enabled */
  43312. isEnabled: boolean;
  43313. private _getBonePosition;
  43314. private _getLinesForBonesWithLength;
  43315. private _getLinesForBonesNoLength;
  43316. /** Update the viewer to sync with current skeleton state */
  43317. update(): void;
  43318. /** Release associated resources */
  43319. dispose(): void;
  43320. }
  43321. }
  43322. declare module BABYLON {
  43323. /**
  43324. * Options to create the null engine
  43325. */
  43326. export class NullEngineOptions {
  43327. /**
  43328. * Render width (Default: 512)
  43329. */
  43330. renderWidth: number;
  43331. /**
  43332. * Render height (Default: 256)
  43333. */
  43334. renderHeight: number;
  43335. /**
  43336. * Texture size (Default: 512)
  43337. */
  43338. textureSize: number;
  43339. /**
  43340. * If delta time between frames should be constant
  43341. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43342. */
  43343. deterministicLockstep: boolean;
  43344. /**
  43345. * Maximum about of steps between frames (Default: 4)
  43346. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43347. */
  43348. lockstepMaxSteps: number;
  43349. }
  43350. /**
  43351. * The null engine class provides support for headless version of babylon.js.
  43352. * This can be used in server side scenario or for testing purposes
  43353. */
  43354. export class NullEngine extends Engine {
  43355. private _options;
  43356. /**
  43357. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43358. */
  43359. isDeterministicLockStep(): boolean;
  43360. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43361. getLockstepMaxSteps(): number;
  43362. /**
  43363. * Sets hardware scaling, used to save performance if needed
  43364. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43365. */
  43366. getHardwareScalingLevel(): number;
  43367. constructor(options?: NullEngineOptions);
  43368. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43369. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43370. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43371. getRenderWidth(useScreen?: boolean): number;
  43372. getRenderHeight(useScreen?: boolean): number;
  43373. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43374. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43375. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43376. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43377. bindSamplers(effect: Effect): void;
  43378. enableEffect(effect: Effect): void;
  43379. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43380. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43381. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43382. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43383. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43384. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43385. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43386. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43387. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43388. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43389. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43390. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43391. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43392. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43393. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43394. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43395. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43396. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43397. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43398. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43399. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43400. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43401. bindBuffers(vertexBuffers: {
  43402. [key: string]: VertexBuffer;
  43403. }, indexBuffer: DataBuffer, effect: Effect): void;
  43404. wipeCaches(bruteForce?: boolean): void;
  43405. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43406. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43407. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43408. /** @hidden */
  43409. _createTexture(): WebGLTexture;
  43410. /** @hidden */
  43411. _releaseTexture(texture: InternalTexture): void;
  43412. 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;
  43413. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43414. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43415. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43416. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43417. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43418. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43419. areAllEffectsReady(): boolean;
  43420. /**
  43421. * @hidden
  43422. * Get the current error code of the webGL context
  43423. * @returns the error code
  43424. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43425. */
  43426. getError(): number;
  43427. /** @hidden */
  43428. _getUnpackAlignement(): number;
  43429. /** @hidden */
  43430. _unpackFlipY(value: boolean): void;
  43431. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43432. /**
  43433. * Updates a dynamic vertex buffer.
  43434. * @param vertexBuffer the vertex buffer to update
  43435. * @param data the data used to update the vertex buffer
  43436. * @param byteOffset the byte offset of the data (optional)
  43437. * @param byteLength the byte length of the data (optional)
  43438. */
  43439. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43440. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43441. /** @hidden */
  43442. _bindTexture(channel: number, texture: InternalTexture): void;
  43443. /** @hidden */
  43444. _releaseBuffer(buffer: DataBuffer): boolean;
  43445. releaseEffects(): void;
  43446. displayLoadingUI(): void;
  43447. hideLoadingUI(): void;
  43448. /** @hidden */
  43449. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43450. /** @hidden */
  43451. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43452. /** @hidden */
  43453. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43454. /** @hidden */
  43455. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43456. }
  43457. }
  43458. declare module BABYLON {
  43459. /** @hidden */
  43460. export class _OcclusionDataStorage {
  43461. /** @hidden */
  43462. occlusionInternalRetryCounter: number;
  43463. /** @hidden */
  43464. isOcclusionQueryInProgress: boolean;
  43465. /** @hidden */
  43466. isOccluded: boolean;
  43467. /** @hidden */
  43468. occlusionRetryCount: number;
  43469. /** @hidden */
  43470. occlusionType: number;
  43471. /** @hidden */
  43472. occlusionQueryAlgorithmType: number;
  43473. }
  43474. interface Engine {
  43475. /**
  43476. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43477. * @return the new query
  43478. */
  43479. createQuery(): WebGLQuery;
  43480. /**
  43481. * Delete and release a webGL query
  43482. * @param query defines the query to delete
  43483. * @return the current engine
  43484. */
  43485. deleteQuery(query: WebGLQuery): Engine;
  43486. /**
  43487. * Check if a given query has resolved and got its value
  43488. * @param query defines the query to check
  43489. * @returns true if the query got its value
  43490. */
  43491. isQueryResultAvailable(query: WebGLQuery): boolean;
  43492. /**
  43493. * Gets the value of a given query
  43494. * @param query defines the query to check
  43495. * @returns the value of the query
  43496. */
  43497. getQueryResult(query: WebGLQuery): number;
  43498. /**
  43499. * Initiates an occlusion query
  43500. * @param algorithmType defines the algorithm to use
  43501. * @param query defines the query to use
  43502. * @returns the current engine
  43503. * @see http://doc.babylonjs.com/features/occlusionquery
  43504. */
  43505. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43506. /**
  43507. * Ends an occlusion query
  43508. * @see http://doc.babylonjs.com/features/occlusionquery
  43509. * @param algorithmType defines the algorithm to use
  43510. * @returns the current engine
  43511. */
  43512. endOcclusionQuery(algorithmType: number): Engine;
  43513. /**
  43514. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43515. * Please note that only one query can be issued at a time
  43516. * @returns a time token used to track the time span
  43517. */
  43518. startTimeQuery(): Nullable<_TimeToken>;
  43519. /**
  43520. * Ends a time query
  43521. * @param token defines the token used to measure the time span
  43522. * @returns the time spent (in ns)
  43523. */
  43524. endTimeQuery(token: _TimeToken): int;
  43525. /** @hidden */
  43526. _currentNonTimestampToken: Nullable<_TimeToken>;
  43527. /** @hidden */
  43528. _createTimeQuery(): WebGLQuery;
  43529. /** @hidden */
  43530. _deleteTimeQuery(query: WebGLQuery): void;
  43531. /** @hidden */
  43532. _getGlAlgorithmType(algorithmType: number): number;
  43533. /** @hidden */
  43534. _getTimeQueryResult(query: WebGLQuery): any;
  43535. /** @hidden */
  43536. _getTimeQueryAvailability(query: WebGLQuery): any;
  43537. }
  43538. interface AbstractMesh {
  43539. /**
  43540. * Backing filed
  43541. * @hidden
  43542. */
  43543. __occlusionDataStorage: _OcclusionDataStorage;
  43544. /**
  43545. * Access property
  43546. * @hidden
  43547. */
  43548. _occlusionDataStorage: _OcclusionDataStorage;
  43549. /**
  43550. * 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.
  43551. * The default value is -1 which means don't break the query and wait till the result
  43552. * @see http://doc.babylonjs.com/features/occlusionquery
  43553. */
  43554. occlusionRetryCount: number;
  43555. /**
  43556. * 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:
  43557. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43558. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43559. * * 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.
  43560. * @see http://doc.babylonjs.com/features/occlusionquery
  43561. */
  43562. occlusionType: number;
  43563. /**
  43564. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43565. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43566. * * 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.
  43567. * @see http://doc.babylonjs.com/features/occlusionquery
  43568. */
  43569. occlusionQueryAlgorithmType: number;
  43570. /**
  43571. * 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
  43572. * @see http://doc.babylonjs.com/features/occlusionquery
  43573. */
  43574. isOccluded: boolean;
  43575. /**
  43576. * Flag to check the progress status of the query
  43577. * @see http://doc.babylonjs.com/features/occlusionquery
  43578. */
  43579. isOcclusionQueryInProgress: boolean;
  43580. }
  43581. }
  43582. declare module BABYLON {
  43583. /** @hidden */
  43584. export var _forceTransformFeedbackToBundle: boolean;
  43585. interface Engine {
  43586. /**
  43587. * Creates a webGL transform feedback object
  43588. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43589. * @returns the webGL transform feedback object
  43590. */
  43591. createTransformFeedback(): WebGLTransformFeedback;
  43592. /**
  43593. * Delete a webGL transform feedback object
  43594. * @param value defines the webGL transform feedback object to delete
  43595. */
  43596. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43597. /**
  43598. * Bind a webGL transform feedback object to the webgl context
  43599. * @param value defines the webGL transform feedback object to bind
  43600. */
  43601. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43602. /**
  43603. * Begins a transform feedback operation
  43604. * @param usePoints defines if points or triangles must be used
  43605. */
  43606. beginTransformFeedback(usePoints: boolean): void;
  43607. /**
  43608. * Ends a transform feedback operation
  43609. */
  43610. endTransformFeedback(): void;
  43611. /**
  43612. * Specify the varyings to use with transform feedback
  43613. * @param program defines the associated webGL program
  43614. * @param value defines the list of strings representing the varying names
  43615. */
  43616. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43617. /**
  43618. * Bind a webGL buffer for a transform feedback operation
  43619. * @param value defines the webGL buffer to bind
  43620. */
  43621. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43622. }
  43623. }
  43624. declare module BABYLON {
  43625. /**
  43626. * Creation options of the multi render target texture.
  43627. */
  43628. export interface IMultiRenderTargetOptions {
  43629. /**
  43630. * Define if the texture needs to create mip maps after render.
  43631. */
  43632. generateMipMaps?: boolean;
  43633. /**
  43634. * Define the types of all the draw buffers we want to create
  43635. */
  43636. types?: number[];
  43637. /**
  43638. * Define the sampling modes of all the draw buffers we want to create
  43639. */
  43640. samplingModes?: number[];
  43641. /**
  43642. * Define if a depth buffer is required
  43643. */
  43644. generateDepthBuffer?: boolean;
  43645. /**
  43646. * Define if a stencil buffer is required
  43647. */
  43648. generateStencilBuffer?: boolean;
  43649. /**
  43650. * Define if a depth texture is required instead of a depth buffer
  43651. */
  43652. generateDepthTexture?: boolean;
  43653. /**
  43654. * Define the number of desired draw buffers
  43655. */
  43656. textureCount?: number;
  43657. /**
  43658. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43659. */
  43660. doNotChangeAspectRatio?: boolean;
  43661. /**
  43662. * Define the default type of the buffers we are creating
  43663. */
  43664. defaultType?: number;
  43665. }
  43666. /**
  43667. * A multi render target, like a render target provides the ability to render to a texture.
  43668. * Unlike the render target, it can render to several draw buffers in one draw.
  43669. * This is specially interesting in deferred rendering or for any effects requiring more than
  43670. * just one color from a single pass.
  43671. */
  43672. export class MultiRenderTarget extends RenderTargetTexture {
  43673. private _internalTextures;
  43674. private _textures;
  43675. private _multiRenderTargetOptions;
  43676. /**
  43677. * Get if draw buffers are currently supported by the used hardware and browser.
  43678. */
  43679. readonly isSupported: boolean;
  43680. /**
  43681. * Get the list of textures generated by the multi render target.
  43682. */
  43683. readonly textures: Texture[];
  43684. /**
  43685. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43686. */
  43687. readonly depthTexture: Texture;
  43688. /**
  43689. * Set the wrapping mode on U of all the textures we are rendering to.
  43690. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43691. */
  43692. wrapU: number;
  43693. /**
  43694. * Set the wrapping mode on V of all the textures we are rendering to.
  43695. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43696. */
  43697. wrapV: number;
  43698. /**
  43699. * Instantiate a new multi render target texture.
  43700. * A multi render target, like a render target provides the ability to render to a texture.
  43701. * Unlike the render target, it can render to several draw buffers in one draw.
  43702. * This is specially interesting in deferred rendering or for any effects requiring more than
  43703. * just one color from a single pass.
  43704. * @param name Define the name of the texture
  43705. * @param size Define the size of the buffers to render to
  43706. * @param count Define the number of target we are rendering into
  43707. * @param scene Define the scene the texture belongs to
  43708. * @param options Define the options used to create the multi render target
  43709. */
  43710. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43711. /** @hidden */
  43712. _rebuild(): void;
  43713. private _createInternalTextures;
  43714. private _createTextures;
  43715. /**
  43716. * Define the number of samples used if MSAA is enabled.
  43717. */
  43718. samples: number;
  43719. /**
  43720. * Resize all the textures in the multi render target.
  43721. * Be carrefull as it will recreate all the data in the new texture.
  43722. * @param size Define the new size
  43723. */
  43724. resize(size: any): void;
  43725. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43726. /**
  43727. * Dispose the render targets and their associated resources
  43728. */
  43729. dispose(): void;
  43730. /**
  43731. * Release all the underlying texture used as draw buffers.
  43732. */
  43733. releaseInternalTextures(): void;
  43734. }
  43735. }
  43736. declare module BABYLON {
  43737. interface Engine {
  43738. /**
  43739. * Unbind a list of render target textures from the webGL context
  43740. * This is used only when drawBuffer extension or webGL2 are active
  43741. * @param textures defines the render target textures to unbind
  43742. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43743. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43744. */
  43745. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43746. /**
  43747. * Create a multi render target texture
  43748. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43749. * @param size defines the size of the texture
  43750. * @param options defines the creation options
  43751. * @returns the cube texture as an InternalTexture
  43752. */
  43753. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43754. /**
  43755. * Update the sample count for a given multiple render target texture
  43756. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43757. * @param textures defines the textures to update
  43758. * @param samples defines the sample count to set
  43759. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43760. */
  43761. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43762. }
  43763. }
  43764. declare module BABYLON {
  43765. /**
  43766. * Gather the list of clipboard event types as constants.
  43767. */
  43768. export class ClipboardEventTypes {
  43769. /**
  43770. * The clipboard event is fired when a copy command is active (pressed).
  43771. */
  43772. static readonly COPY: number;
  43773. /**
  43774. * The clipboard event is fired when a cut command is active (pressed).
  43775. */
  43776. static readonly CUT: number;
  43777. /**
  43778. * The clipboard event is fired when a paste command is active (pressed).
  43779. */
  43780. static readonly PASTE: number;
  43781. }
  43782. /**
  43783. * This class is used to store clipboard related info for the onClipboardObservable event.
  43784. */
  43785. export class ClipboardInfo {
  43786. /**
  43787. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43788. */
  43789. type: number;
  43790. /**
  43791. * Defines the related dom event
  43792. */
  43793. event: ClipboardEvent;
  43794. /**
  43795. *Creates an instance of ClipboardInfo.
  43796. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43797. * @param event Defines the related dom event
  43798. */
  43799. constructor(
  43800. /**
  43801. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43802. */
  43803. type: number,
  43804. /**
  43805. * Defines the related dom event
  43806. */
  43807. event: ClipboardEvent);
  43808. /**
  43809. * Get the clipboard event's type from the keycode.
  43810. * @param keyCode Defines the keyCode for the current keyboard event.
  43811. * @return {number}
  43812. */
  43813. static GetTypeFromCharacter(keyCode: number): number;
  43814. }
  43815. }
  43816. declare module BABYLON {
  43817. /**
  43818. * Google Daydream controller
  43819. */
  43820. export class DaydreamController extends WebVRController {
  43821. /**
  43822. * Base Url for the controller model.
  43823. */
  43824. static MODEL_BASE_URL: string;
  43825. /**
  43826. * File name for the controller model.
  43827. */
  43828. static MODEL_FILENAME: string;
  43829. /**
  43830. * Gamepad Id prefix used to identify Daydream Controller.
  43831. */
  43832. static readonly GAMEPAD_ID_PREFIX: string;
  43833. /**
  43834. * Creates a new DaydreamController from a gamepad
  43835. * @param vrGamepad the gamepad that the controller should be created from
  43836. */
  43837. constructor(vrGamepad: any);
  43838. /**
  43839. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43840. * @param scene scene in which to add meshes
  43841. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43842. */
  43843. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43844. /**
  43845. * Called once for each button that changed state since the last frame
  43846. * @param buttonIdx Which button index changed
  43847. * @param state New state of the button
  43848. * @param changes Which properties on the state changed since last frame
  43849. */
  43850. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43851. }
  43852. }
  43853. declare module BABYLON {
  43854. /**
  43855. * Gear VR Controller
  43856. */
  43857. export class GearVRController extends WebVRController {
  43858. /**
  43859. * Base Url for the controller model.
  43860. */
  43861. static MODEL_BASE_URL: string;
  43862. /**
  43863. * File name for the controller model.
  43864. */
  43865. static MODEL_FILENAME: string;
  43866. /**
  43867. * Gamepad Id prefix used to identify this controller.
  43868. */
  43869. static readonly GAMEPAD_ID_PREFIX: string;
  43870. private readonly _buttonIndexToObservableNameMap;
  43871. /**
  43872. * Creates a new GearVRController from a gamepad
  43873. * @param vrGamepad the gamepad that the controller should be created from
  43874. */
  43875. constructor(vrGamepad: any);
  43876. /**
  43877. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43878. * @param scene scene in which to add meshes
  43879. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43880. */
  43881. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43882. /**
  43883. * Called once for each button that changed state since the last frame
  43884. * @param buttonIdx Which button index changed
  43885. * @param state New state of the button
  43886. * @param changes Which properties on the state changed since last frame
  43887. */
  43888. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43889. }
  43890. }
  43891. declare module BABYLON {
  43892. /**
  43893. * Class containing static functions to help procedurally build meshes
  43894. */
  43895. export class PolyhedronBuilder {
  43896. /**
  43897. * Creates a polyhedron mesh
  43898. * * 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
  43899. * * The parameter `size` (positive float, default 1) sets the polygon size
  43900. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43901. * * 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`
  43902. * * 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
  43903. * * 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)`)
  43904. * * 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
  43905. * * 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
  43906. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43907. * * 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
  43908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43909. * @param name defines the name of the mesh
  43910. * @param options defines the options used to create the mesh
  43911. * @param scene defines the hosting scene
  43912. * @returns the polyhedron mesh
  43913. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43914. */
  43915. static CreatePolyhedron(name: string, options: {
  43916. type?: number;
  43917. size?: number;
  43918. sizeX?: number;
  43919. sizeY?: number;
  43920. sizeZ?: number;
  43921. custom?: any;
  43922. faceUV?: Vector4[];
  43923. faceColors?: Color4[];
  43924. flat?: boolean;
  43925. updatable?: boolean;
  43926. sideOrientation?: number;
  43927. frontUVs?: Vector4;
  43928. backUVs?: Vector4;
  43929. }, scene?: Nullable<Scene>): Mesh;
  43930. }
  43931. }
  43932. declare module BABYLON {
  43933. /**
  43934. * Gizmo that enables scaling a mesh along 3 axis
  43935. */
  43936. export class ScaleGizmo extends Gizmo {
  43937. /**
  43938. * Internal gizmo used for interactions on the x axis
  43939. */
  43940. xGizmo: AxisScaleGizmo;
  43941. /**
  43942. * Internal gizmo used for interactions on the y axis
  43943. */
  43944. yGizmo: AxisScaleGizmo;
  43945. /**
  43946. * Internal gizmo used for interactions on the z axis
  43947. */
  43948. zGizmo: AxisScaleGizmo;
  43949. /**
  43950. * Internal gizmo used to scale all axis equally
  43951. */
  43952. uniformScaleGizmo: AxisScaleGizmo;
  43953. private _meshAttached;
  43954. private _updateGizmoRotationToMatchAttachedMesh;
  43955. private _snapDistance;
  43956. private _scaleRatio;
  43957. private _uniformScalingMesh;
  43958. private _octahedron;
  43959. /** Fires an event when any of it's sub gizmos are dragged */
  43960. onDragStartObservable: Observable<unknown>;
  43961. /** Fires an event when any of it's sub gizmos are released from dragging */
  43962. onDragEndObservable: Observable<unknown>;
  43963. attachedMesh: Nullable<AbstractMesh>;
  43964. /**
  43965. * Creates a ScaleGizmo
  43966. * @param gizmoLayer The utility layer the gizmo will be added to
  43967. */
  43968. constructor(gizmoLayer?: UtilityLayerRenderer);
  43969. updateGizmoRotationToMatchAttachedMesh: boolean;
  43970. /**
  43971. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43972. */
  43973. snapDistance: number;
  43974. /**
  43975. * Ratio for the scale of the gizmo (Default: 1)
  43976. */
  43977. scaleRatio: number;
  43978. /**
  43979. * Disposes of the gizmo
  43980. */
  43981. dispose(): void;
  43982. }
  43983. }
  43984. declare module BABYLON {
  43985. /**
  43986. * Single axis scale gizmo
  43987. */
  43988. export class AxisScaleGizmo extends Gizmo {
  43989. /**
  43990. * Drag behavior responsible for the gizmos dragging interactions
  43991. */
  43992. dragBehavior: PointerDragBehavior;
  43993. private _pointerObserver;
  43994. /**
  43995. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43996. */
  43997. snapDistance: number;
  43998. /**
  43999. * Event that fires each time the gizmo snaps to a new location.
  44000. * * snapDistance is the the change in distance
  44001. */
  44002. onSnapObservable: Observable<{
  44003. snapDistance: number;
  44004. }>;
  44005. /**
  44006. * If the scaling operation should be done on all axis (default: false)
  44007. */
  44008. uniformScaling: boolean;
  44009. private _isEnabled;
  44010. private _parent;
  44011. private _arrow;
  44012. private _coloredMaterial;
  44013. private _hoverMaterial;
  44014. /**
  44015. * Creates an AxisScaleGizmo
  44016. * @param gizmoLayer The utility layer the gizmo will be added to
  44017. * @param dragAxis The axis which the gizmo will be able to scale on
  44018. * @param color The color of the gizmo
  44019. */
  44020. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44021. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44022. /**
  44023. * If the gizmo is enabled
  44024. */
  44025. isEnabled: boolean;
  44026. /**
  44027. * Disposes of the gizmo
  44028. */
  44029. dispose(): void;
  44030. /**
  44031. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44032. * @param mesh The mesh to replace the default mesh of the gizmo
  44033. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44034. */
  44035. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44036. }
  44037. }
  44038. declare module BABYLON {
  44039. /**
  44040. * Bounding box gizmo
  44041. */
  44042. export class BoundingBoxGizmo extends Gizmo {
  44043. private _lineBoundingBox;
  44044. private _rotateSpheresParent;
  44045. private _scaleBoxesParent;
  44046. private _boundingDimensions;
  44047. private _renderObserver;
  44048. private _pointerObserver;
  44049. private _scaleDragSpeed;
  44050. private _tmpQuaternion;
  44051. private _tmpVector;
  44052. private _tmpRotationMatrix;
  44053. /**
  44054. * 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)
  44055. */
  44056. ignoreChildren: boolean;
  44057. /**
  44058. * 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)
  44059. */
  44060. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44061. /**
  44062. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44063. */
  44064. rotationSphereSize: number;
  44065. /**
  44066. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44067. */
  44068. scaleBoxSize: number;
  44069. /**
  44070. * 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)
  44071. */
  44072. fixedDragMeshScreenSize: boolean;
  44073. /**
  44074. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44075. */
  44076. fixedDragMeshScreenSizeDistanceFactor: number;
  44077. /**
  44078. * Fired when a rotation sphere or scale box is dragged
  44079. */
  44080. onDragStartObservable: Observable<{}>;
  44081. /**
  44082. * Fired when a scale box is dragged
  44083. */
  44084. onScaleBoxDragObservable: Observable<{}>;
  44085. /**
  44086. * Fired when a scale box drag is ended
  44087. */
  44088. onScaleBoxDragEndObservable: Observable<{}>;
  44089. /**
  44090. * Fired when a rotation sphere is dragged
  44091. */
  44092. onRotationSphereDragObservable: Observable<{}>;
  44093. /**
  44094. * Fired when a rotation sphere drag is ended
  44095. */
  44096. onRotationSphereDragEndObservable: Observable<{}>;
  44097. /**
  44098. * 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)
  44099. */
  44100. scalePivot: Nullable<Vector3>;
  44101. /**
  44102. * Mesh used as a pivot to rotate the attached mesh
  44103. */
  44104. private _anchorMesh;
  44105. private _existingMeshScale;
  44106. private _dragMesh;
  44107. private pointerDragBehavior;
  44108. private coloredMaterial;
  44109. private hoverColoredMaterial;
  44110. /**
  44111. * Sets the color of the bounding box gizmo
  44112. * @param color the color to set
  44113. */
  44114. setColor(color: Color3): void;
  44115. /**
  44116. * Creates an BoundingBoxGizmo
  44117. * @param gizmoLayer The utility layer the gizmo will be added to
  44118. * @param color The color of the gizmo
  44119. */
  44120. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44121. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44122. private _selectNode;
  44123. /**
  44124. * Updates the bounding box information for the Gizmo
  44125. */
  44126. updateBoundingBox(): void;
  44127. private _updateRotationSpheres;
  44128. private _updateScaleBoxes;
  44129. /**
  44130. * Enables rotation on the specified axis and disables rotation on the others
  44131. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44132. */
  44133. setEnabledRotationAxis(axis: string): void;
  44134. /**
  44135. * Enables/disables scaling
  44136. * @param enable if scaling should be enabled
  44137. */
  44138. setEnabledScaling(enable: boolean): void;
  44139. private _updateDummy;
  44140. /**
  44141. * Enables a pointer drag behavior on the bounding box of the gizmo
  44142. */
  44143. enableDragBehavior(): void;
  44144. /**
  44145. * Disposes of the gizmo
  44146. */
  44147. dispose(): void;
  44148. /**
  44149. * 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)
  44150. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44151. * @returns the bounding box mesh with the passed in mesh as a child
  44152. */
  44153. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44154. /**
  44155. * CustomMeshes are not supported by this gizmo
  44156. * @param mesh The mesh to replace the default mesh of the gizmo
  44157. */
  44158. setCustomMesh(mesh: Mesh): void;
  44159. }
  44160. }
  44161. declare module BABYLON {
  44162. /**
  44163. * Single plane rotation gizmo
  44164. */
  44165. export class PlaneRotationGizmo extends Gizmo {
  44166. /**
  44167. * Drag behavior responsible for the gizmos dragging interactions
  44168. */
  44169. dragBehavior: PointerDragBehavior;
  44170. private _pointerObserver;
  44171. /**
  44172. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44173. */
  44174. snapDistance: number;
  44175. /**
  44176. * Event that fires each time the gizmo snaps to a new location.
  44177. * * snapDistance is the the change in distance
  44178. */
  44179. onSnapObservable: Observable<{
  44180. snapDistance: number;
  44181. }>;
  44182. private _isEnabled;
  44183. private _parent;
  44184. /**
  44185. * Creates a PlaneRotationGizmo
  44186. * @param gizmoLayer The utility layer the gizmo will be added to
  44187. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44188. * @param color The color of the gizmo
  44189. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44190. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44191. */
  44192. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  44193. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44194. /**
  44195. * If the gizmo is enabled
  44196. */
  44197. isEnabled: boolean;
  44198. /**
  44199. * Disposes of the gizmo
  44200. */
  44201. dispose(): void;
  44202. }
  44203. }
  44204. declare module BABYLON {
  44205. /**
  44206. * Gizmo that enables rotating a mesh along 3 axis
  44207. */
  44208. export class RotationGizmo extends Gizmo {
  44209. /**
  44210. * Internal gizmo used for interactions on the x axis
  44211. */
  44212. xGizmo: PlaneRotationGizmo;
  44213. /**
  44214. * Internal gizmo used for interactions on the y axis
  44215. */
  44216. yGizmo: PlaneRotationGizmo;
  44217. /**
  44218. * Internal gizmo used for interactions on the z axis
  44219. */
  44220. zGizmo: PlaneRotationGizmo;
  44221. /** Fires an event when any of it's sub gizmos are dragged */
  44222. onDragStartObservable: Observable<unknown>;
  44223. /** Fires an event when any of it's sub gizmos are released from dragging */
  44224. onDragEndObservable: Observable<unknown>;
  44225. private _meshAttached;
  44226. attachedMesh: Nullable<AbstractMesh>;
  44227. /**
  44228. * Creates a RotationGizmo
  44229. * @param gizmoLayer The utility layer the gizmo will be added to
  44230. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44231. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44232. */
  44233. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  44234. updateGizmoRotationToMatchAttachedMesh: boolean;
  44235. /**
  44236. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44237. */
  44238. snapDistance: number;
  44239. /**
  44240. * Ratio for the scale of the gizmo (Default: 1)
  44241. */
  44242. scaleRatio: number;
  44243. /**
  44244. * Disposes of the gizmo
  44245. */
  44246. dispose(): void;
  44247. /**
  44248. * CustomMeshes are not supported by this gizmo
  44249. * @param mesh The mesh to replace the default mesh of the gizmo
  44250. */
  44251. setCustomMesh(mesh: Mesh): void;
  44252. }
  44253. }
  44254. declare module BABYLON {
  44255. /**
  44256. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44257. */
  44258. export class GizmoManager implements IDisposable {
  44259. private scene;
  44260. /**
  44261. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44262. */
  44263. gizmos: {
  44264. positionGizmo: Nullable<PositionGizmo>;
  44265. rotationGizmo: Nullable<RotationGizmo>;
  44266. scaleGizmo: Nullable<ScaleGizmo>;
  44267. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44268. };
  44269. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44270. clearGizmoOnEmptyPointerEvent: boolean;
  44271. /** Fires an event when the manager is attached to a mesh */
  44272. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44273. private _gizmosEnabled;
  44274. private _pointerObserver;
  44275. private _attachedMesh;
  44276. private _boundingBoxColor;
  44277. private _defaultUtilityLayer;
  44278. private _defaultKeepDepthUtilityLayer;
  44279. /**
  44280. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44281. */
  44282. boundingBoxDragBehavior: SixDofDragBehavior;
  44283. /**
  44284. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44285. */
  44286. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44287. /**
  44288. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44289. */
  44290. usePointerToAttachGizmos: boolean;
  44291. /**
  44292. * Utility layer that the bounding box gizmo belongs to
  44293. */
  44294. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  44295. /**
  44296. * Utility layer that all gizmos besides bounding box belong to
  44297. */
  44298. readonly utilityLayer: UtilityLayerRenderer;
  44299. /**
  44300. * Instatiates a gizmo manager
  44301. * @param scene the scene to overlay the gizmos on top of
  44302. */
  44303. constructor(scene: Scene);
  44304. /**
  44305. * Attaches a set of gizmos to the specified mesh
  44306. * @param mesh The mesh the gizmo's should be attached to
  44307. */
  44308. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44309. /**
  44310. * If the position gizmo is enabled
  44311. */
  44312. positionGizmoEnabled: boolean;
  44313. /**
  44314. * If the rotation gizmo is enabled
  44315. */
  44316. rotationGizmoEnabled: boolean;
  44317. /**
  44318. * If the scale gizmo is enabled
  44319. */
  44320. scaleGizmoEnabled: boolean;
  44321. /**
  44322. * If the boundingBox gizmo is enabled
  44323. */
  44324. boundingBoxGizmoEnabled: boolean;
  44325. /**
  44326. * Disposes of the gizmo manager
  44327. */
  44328. dispose(): void;
  44329. }
  44330. }
  44331. declare module BABYLON {
  44332. /**
  44333. * A directional light is defined by a direction (what a surprise!).
  44334. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44335. * 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.
  44336. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44337. */
  44338. export class DirectionalLight extends ShadowLight {
  44339. private _shadowFrustumSize;
  44340. /**
  44341. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44342. */
  44343. /**
  44344. * Specifies a fix frustum size for the shadow generation.
  44345. */
  44346. shadowFrustumSize: number;
  44347. private _shadowOrthoScale;
  44348. /**
  44349. * Gets the shadow projection scale against the optimal computed one.
  44350. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44351. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44352. */
  44353. /**
  44354. * Sets the shadow projection scale against the optimal computed one.
  44355. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44356. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44357. */
  44358. shadowOrthoScale: number;
  44359. /**
  44360. * Automatically compute the projection matrix to best fit (including all the casters)
  44361. * on each frame.
  44362. */
  44363. autoUpdateExtends: boolean;
  44364. private _orthoLeft;
  44365. private _orthoRight;
  44366. private _orthoTop;
  44367. private _orthoBottom;
  44368. /**
  44369. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44370. * The directional light is emitted from everywhere in the given direction.
  44371. * It can cast shadows.
  44372. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44373. * @param name The friendly name of the light
  44374. * @param direction The direction of the light
  44375. * @param scene The scene the light belongs to
  44376. */
  44377. constructor(name: string, direction: Vector3, scene: Scene);
  44378. /**
  44379. * Returns the string "DirectionalLight".
  44380. * @return The class name
  44381. */
  44382. getClassName(): string;
  44383. /**
  44384. * Returns the integer 1.
  44385. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44386. */
  44387. getTypeID(): number;
  44388. /**
  44389. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44390. * Returns the DirectionalLight Shadow projection matrix.
  44391. */
  44392. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44393. /**
  44394. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44395. * Returns the DirectionalLight Shadow projection matrix.
  44396. */
  44397. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44398. /**
  44399. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44400. * Returns the DirectionalLight Shadow projection matrix.
  44401. */
  44402. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44403. protected _buildUniformLayout(): void;
  44404. /**
  44405. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44406. * @param effect The effect to update
  44407. * @param lightIndex The index of the light in the effect to update
  44408. * @returns The directional light
  44409. */
  44410. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44411. /**
  44412. * Gets the minZ used for shadow according to both the scene and the light.
  44413. *
  44414. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44415. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44416. * @param activeCamera The camera we are returning the min for
  44417. * @returns the depth min z
  44418. */
  44419. getDepthMinZ(activeCamera: Camera): number;
  44420. /**
  44421. * Gets the maxZ used for shadow according to both the scene and the light.
  44422. *
  44423. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44424. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44425. * @param activeCamera The camera we are returning the max for
  44426. * @returns the depth max z
  44427. */
  44428. getDepthMaxZ(activeCamera: Camera): number;
  44429. /**
  44430. * Prepares the list of defines specific to the light type.
  44431. * @param defines the list of defines
  44432. * @param lightIndex defines the index of the light for the effect
  44433. */
  44434. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44435. }
  44436. }
  44437. declare module BABYLON {
  44438. /**
  44439. * Class containing static functions to help procedurally build meshes
  44440. */
  44441. export class HemisphereBuilder {
  44442. /**
  44443. * Creates a hemisphere mesh
  44444. * @param name defines the name of the mesh
  44445. * @param options defines the options used to create the mesh
  44446. * @param scene defines the hosting scene
  44447. * @returns the hemisphere mesh
  44448. */
  44449. static CreateHemisphere(name: string, options: {
  44450. segments?: number;
  44451. diameter?: number;
  44452. sideOrientation?: number;
  44453. }, scene: any): Mesh;
  44454. }
  44455. }
  44456. declare module BABYLON {
  44457. /**
  44458. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44459. * These values define a cone of light starting from the position, emitting toward the direction.
  44460. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44461. * and the exponent defines the speed of the decay of the light with distance (reach).
  44462. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44463. */
  44464. export class SpotLight extends ShadowLight {
  44465. private _angle;
  44466. private _innerAngle;
  44467. private _cosHalfAngle;
  44468. private _lightAngleScale;
  44469. private _lightAngleOffset;
  44470. /**
  44471. * Gets the cone angle of the spot light in Radians.
  44472. */
  44473. /**
  44474. * Sets the cone angle of the spot light in Radians.
  44475. */
  44476. angle: number;
  44477. /**
  44478. * Only used in gltf falloff mode, this defines the angle where
  44479. * the directional falloff will start before cutting at angle which could be seen
  44480. * as outer angle.
  44481. */
  44482. /**
  44483. * Only used in gltf falloff mode, this defines the angle where
  44484. * the directional falloff will start before cutting at angle which could be seen
  44485. * as outer angle.
  44486. */
  44487. innerAngle: number;
  44488. private _shadowAngleScale;
  44489. /**
  44490. * Allows scaling the angle of the light for shadow generation only.
  44491. */
  44492. /**
  44493. * Allows scaling the angle of the light for shadow generation only.
  44494. */
  44495. shadowAngleScale: number;
  44496. /**
  44497. * The light decay speed with the distance from the emission spot.
  44498. */
  44499. exponent: number;
  44500. private _projectionTextureMatrix;
  44501. /**
  44502. * Allows reading the projecton texture
  44503. */
  44504. readonly projectionTextureMatrix: Matrix;
  44505. protected _projectionTextureLightNear: number;
  44506. /**
  44507. * Gets the near clip of the Spotlight for texture projection.
  44508. */
  44509. /**
  44510. * Sets the near clip of the Spotlight for texture projection.
  44511. */
  44512. projectionTextureLightNear: number;
  44513. protected _projectionTextureLightFar: number;
  44514. /**
  44515. * Gets the far clip of the Spotlight for texture projection.
  44516. */
  44517. /**
  44518. * Sets the far clip of the Spotlight for texture projection.
  44519. */
  44520. projectionTextureLightFar: number;
  44521. protected _projectionTextureUpDirection: Vector3;
  44522. /**
  44523. * Gets the Up vector of the Spotlight for texture projection.
  44524. */
  44525. /**
  44526. * Sets the Up vector of the Spotlight for texture projection.
  44527. */
  44528. projectionTextureUpDirection: Vector3;
  44529. private _projectionTexture;
  44530. /**
  44531. * Gets the projection texture of the light.
  44532. */
  44533. /**
  44534. * Sets the projection texture of the light.
  44535. */
  44536. projectionTexture: Nullable<BaseTexture>;
  44537. private _projectionTextureViewLightDirty;
  44538. private _projectionTextureProjectionLightDirty;
  44539. private _projectionTextureDirty;
  44540. private _projectionTextureViewTargetVector;
  44541. private _projectionTextureViewLightMatrix;
  44542. private _projectionTextureProjectionLightMatrix;
  44543. private _projectionTextureScalingMatrix;
  44544. /**
  44545. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44546. * It can cast shadows.
  44547. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44548. * @param name The light friendly name
  44549. * @param position The position of the spot light in the scene
  44550. * @param direction The direction of the light in the scene
  44551. * @param angle The cone angle of the light in Radians
  44552. * @param exponent The light decay speed with the distance from the emission spot
  44553. * @param scene The scene the lights belongs to
  44554. */
  44555. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44556. /**
  44557. * Returns the string "SpotLight".
  44558. * @returns the class name
  44559. */
  44560. getClassName(): string;
  44561. /**
  44562. * Returns the integer 2.
  44563. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44564. */
  44565. getTypeID(): number;
  44566. /**
  44567. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44568. */
  44569. protected _setDirection(value: Vector3): void;
  44570. /**
  44571. * Overrides the position setter to recompute the projection texture view light Matrix.
  44572. */
  44573. protected _setPosition(value: Vector3): void;
  44574. /**
  44575. * 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.
  44576. * Returns the SpotLight.
  44577. */
  44578. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44579. protected _computeProjectionTextureViewLightMatrix(): void;
  44580. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44581. /**
  44582. * Main function for light texture projection matrix computing.
  44583. */
  44584. protected _computeProjectionTextureMatrix(): void;
  44585. protected _buildUniformLayout(): void;
  44586. private _computeAngleValues;
  44587. /**
  44588. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44589. * @param effect The effect to update
  44590. * @param lightIndex The index of the light in the effect to update
  44591. * @returns The spot light
  44592. */
  44593. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44594. /**
  44595. * Disposes the light and the associated resources.
  44596. */
  44597. dispose(): void;
  44598. /**
  44599. * Prepares the list of defines specific to the light type.
  44600. * @param defines the list of defines
  44601. * @param lightIndex defines the index of the light for the effect
  44602. */
  44603. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44604. }
  44605. }
  44606. declare module BABYLON {
  44607. /**
  44608. * Gizmo that enables viewing a light
  44609. */
  44610. export class LightGizmo extends Gizmo {
  44611. private _lightMesh;
  44612. private _material;
  44613. private cachedPosition;
  44614. private cachedForward;
  44615. /**
  44616. * Creates a LightGizmo
  44617. * @param gizmoLayer The utility layer the gizmo will be added to
  44618. */
  44619. constructor(gizmoLayer?: UtilityLayerRenderer);
  44620. private _light;
  44621. /**
  44622. * The light that the gizmo is attached to
  44623. */
  44624. light: Nullable<Light>;
  44625. /**
  44626. * Gets the material used to render the light gizmo
  44627. */
  44628. readonly material: StandardMaterial;
  44629. /**
  44630. * @hidden
  44631. * Updates the gizmo to match the attached mesh's position/rotation
  44632. */
  44633. protected _update(): void;
  44634. private static _Scale;
  44635. /**
  44636. * Creates the lines for a light mesh
  44637. */
  44638. private static _createLightLines;
  44639. /**
  44640. * Disposes of the light gizmo
  44641. */
  44642. dispose(): void;
  44643. private static _CreateHemisphericLightMesh;
  44644. private static _CreatePointLightMesh;
  44645. private static _CreateSpotLightMesh;
  44646. private static _CreateDirectionalLightMesh;
  44647. }
  44648. }
  44649. declare module BABYLON {
  44650. /** @hidden */
  44651. export var backgroundFragmentDeclaration: {
  44652. name: string;
  44653. shader: string;
  44654. };
  44655. }
  44656. declare module BABYLON {
  44657. /** @hidden */
  44658. export var backgroundUboDeclaration: {
  44659. name: string;
  44660. shader: string;
  44661. };
  44662. }
  44663. declare module BABYLON {
  44664. /** @hidden */
  44665. export var backgroundPixelShader: {
  44666. name: string;
  44667. shader: string;
  44668. };
  44669. }
  44670. declare module BABYLON {
  44671. /** @hidden */
  44672. export var backgroundVertexDeclaration: {
  44673. name: string;
  44674. shader: string;
  44675. };
  44676. }
  44677. declare module BABYLON {
  44678. /** @hidden */
  44679. export var backgroundVertexShader: {
  44680. name: string;
  44681. shader: string;
  44682. };
  44683. }
  44684. declare module BABYLON {
  44685. /**
  44686. * Background material used to create an efficient environement around your scene.
  44687. */
  44688. export class BackgroundMaterial extends PushMaterial {
  44689. /**
  44690. * Standard reflectance value at parallel view angle.
  44691. */
  44692. static StandardReflectance0: number;
  44693. /**
  44694. * Standard reflectance value at grazing angle.
  44695. */
  44696. static StandardReflectance90: number;
  44697. protected _primaryColor: Color3;
  44698. /**
  44699. * Key light Color (multiply against the environement texture)
  44700. */
  44701. primaryColor: Color3;
  44702. protected __perceptualColor: Nullable<Color3>;
  44703. /**
  44704. * Experimental Internal Use Only.
  44705. *
  44706. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44707. * This acts as a helper to set the primary color to a more "human friendly" value.
  44708. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44709. * output color as close as possible from the chosen value.
  44710. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44711. * part of lighting setup.)
  44712. */
  44713. _perceptualColor: Nullable<Color3>;
  44714. protected _primaryColorShadowLevel: float;
  44715. /**
  44716. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44717. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44718. */
  44719. primaryColorShadowLevel: float;
  44720. protected _primaryColorHighlightLevel: float;
  44721. /**
  44722. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44723. * The primary color is used at the level chosen to define what the white area would look.
  44724. */
  44725. primaryColorHighlightLevel: float;
  44726. protected _reflectionTexture: Nullable<BaseTexture>;
  44727. /**
  44728. * Reflection Texture used in the material.
  44729. * Should be author in a specific way for the best result (refer to the documentation).
  44730. */
  44731. reflectionTexture: Nullable<BaseTexture>;
  44732. protected _reflectionBlur: float;
  44733. /**
  44734. * Reflection Texture level of blur.
  44735. *
  44736. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44737. * texture twice.
  44738. */
  44739. reflectionBlur: float;
  44740. protected _diffuseTexture: Nullable<BaseTexture>;
  44741. /**
  44742. * Diffuse Texture used in the material.
  44743. * Should be author in a specific way for the best result (refer to the documentation).
  44744. */
  44745. diffuseTexture: Nullable<BaseTexture>;
  44746. protected _shadowLights: Nullable<IShadowLight[]>;
  44747. /**
  44748. * Specify the list of lights casting shadow on the material.
  44749. * All scene shadow lights will be included if null.
  44750. */
  44751. shadowLights: Nullable<IShadowLight[]>;
  44752. protected _shadowLevel: float;
  44753. /**
  44754. * Helps adjusting the shadow to a softer level if required.
  44755. * 0 means black shadows and 1 means no shadows.
  44756. */
  44757. shadowLevel: float;
  44758. protected _sceneCenter: Vector3;
  44759. /**
  44760. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44761. * It is usually zero but might be interesting to modify according to your setup.
  44762. */
  44763. sceneCenter: Vector3;
  44764. protected _opacityFresnel: boolean;
  44765. /**
  44766. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44767. * This helps ensuring a nice transition when the camera goes under the ground.
  44768. */
  44769. opacityFresnel: boolean;
  44770. protected _reflectionFresnel: boolean;
  44771. /**
  44772. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44773. * This helps adding a mirror texture on the ground.
  44774. */
  44775. reflectionFresnel: boolean;
  44776. protected _reflectionFalloffDistance: number;
  44777. /**
  44778. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44779. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44780. */
  44781. reflectionFalloffDistance: number;
  44782. protected _reflectionAmount: number;
  44783. /**
  44784. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44785. */
  44786. reflectionAmount: number;
  44787. protected _reflectionReflectance0: number;
  44788. /**
  44789. * This specifies the weight of the reflection at grazing angle.
  44790. */
  44791. reflectionReflectance0: number;
  44792. protected _reflectionReflectance90: number;
  44793. /**
  44794. * This specifies the weight of the reflection at a perpendicular point of view.
  44795. */
  44796. reflectionReflectance90: number;
  44797. /**
  44798. * Sets the reflection reflectance fresnel values according to the default standard
  44799. * empirically know to work well :-)
  44800. */
  44801. reflectionStandardFresnelWeight: number;
  44802. protected _useRGBColor: boolean;
  44803. /**
  44804. * Helps to directly use the maps channels instead of their level.
  44805. */
  44806. useRGBColor: boolean;
  44807. protected _enableNoise: boolean;
  44808. /**
  44809. * This helps reducing the banding effect that could occur on the background.
  44810. */
  44811. enableNoise: boolean;
  44812. /**
  44813. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44814. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44815. * Recommended to be keep at 1.0 except for special cases.
  44816. */
  44817. fovMultiplier: number;
  44818. private _fovMultiplier;
  44819. /**
  44820. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44821. */
  44822. useEquirectangularFOV: boolean;
  44823. private _maxSimultaneousLights;
  44824. /**
  44825. * Number of Simultaneous lights allowed on the material.
  44826. */
  44827. maxSimultaneousLights: int;
  44828. /**
  44829. * Default configuration related to image processing available in the Background Material.
  44830. */
  44831. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44832. /**
  44833. * Keep track of the image processing observer to allow dispose and replace.
  44834. */
  44835. private _imageProcessingObserver;
  44836. /**
  44837. * Attaches a new image processing configuration to the PBR Material.
  44838. * @param configuration (if null the scene configuration will be use)
  44839. */
  44840. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44841. /**
  44842. * Gets the image processing configuration used either in this material.
  44843. */
  44844. /**
  44845. * Sets the Default image processing configuration used either in the this material.
  44846. *
  44847. * If sets to null, the scene one is in use.
  44848. */
  44849. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44850. /**
  44851. * Gets wether the color curves effect is enabled.
  44852. */
  44853. /**
  44854. * Sets wether the color curves effect is enabled.
  44855. */
  44856. cameraColorCurvesEnabled: boolean;
  44857. /**
  44858. * Gets wether the color grading effect is enabled.
  44859. */
  44860. /**
  44861. * Gets wether the color grading effect is enabled.
  44862. */
  44863. cameraColorGradingEnabled: boolean;
  44864. /**
  44865. * Gets wether tonemapping is enabled or not.
  44866. */
  44867. /**
  44868. * Sets wether tonemapping is enabled or not
  44869. */
  44870. cameraToneMappingEnabled: boolean;
  44871. /**
  44872. * The camera exposure used on this material.
  44873. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44874. * This corresponds to a photographic exposure.
  44875. */
  44876. /**
  44877. * The camera exposure used on this material.
  44878. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44879. * This corresponds to a photographic exposure.
  44880. */
  44881. cameraExposure: float;
  44882. /**
  44883. * Gets The camera contrast used on this material.
  44884. */
  44885. /**
  44886. * Sets The camera contrast used on this material.
  44887. */
  44888. cameraContrast: float;
  44889. /**
  44890. * Gets the Color Grading 2D Lookup Texture.
  44891. */
  44892. /**
  44893. * Sets the Color Grading 2D Lookup Texture.
  44894. */
  44895. cameraColorGradingTexture: Nullable<BaseTexture>;
  44896. /**
  44897. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44898. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44899. * 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;
  44900. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44901. */
  44902. /**
  44903. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44904. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44905. * 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;
  44906. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44907. */
  44908. cameraColorCurves: Nullable<ColorCurves>;
  44909. /**
  44910. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44911. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44912. */
  44913. switchToBGR: boolean;
  44914. private _renderTargets;
  44915. private _reflectionControls;
  44916. private _white;
  44917. private _primaryShadowColor;
  44918. private _primaryHighlightColor;
  44919. /**
  44920. * Instantiates a Background Material in the given scene
  44921. * @param name The friendly name of the material
  44922. * @param scene The scene to add the material to
  44923. */
  44924. constructor(name: string, scene: Scene);
  44925. /**
  44926. * Gets a boolean indicating that current material needs to register RTT
  44927. */
  44928. readonly hasRenderTargetTextures: boolean;
  44929. /**
  44930. * The entire material has been created in order to prevent overdraw.
  44931. * @returns false
  44932. */
  44933. needAlphaTesting(): boolean;
  44934. /**
  44935. * The entire material has been created in order to prevent overdraw.
  44936. * @returns true if blending is enable
  44937. */
  44938. needAlphaBlending(): boolean;
  44939. /**
  44940. * Checks wether the material is ready to be rendered for a given mesh.
  44941. * @param mesh The mesh to render
  44942. * @param subMesh The submesh to check against
  44943. * @param useInstances Specify wether or not the material is used with instances
  44944. * @returns true if all the dependencies are ready (Textures, Effects...)
  44945. */
  44946. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44947. /**
  44948. * Compute the primary color according to the chosen perceptual color.
  44949. */
  44950. private _computePrimaryColorFromPerceptualColor;
  44951. /**
  44952. * Compute the highlights and shadow colors according to their chosen levels.
  44953. */
  44954. private _computePrimaryColors;
  44955. /**
  44956. * Build the uniform buffer used in the material.
  44957. */
  44958. buildUniformLayout(): void;
  44959. /**
  44960. * Unbind the material.
  44961. */
  44962. unbind(): void;
  44963. /**
  44964. * Bind only the world matrix to the material.
  44965. * @param world The world matrix to bind.
  44966. */
  44967. bindOnlyWorldMatrix(world: Matrix): void;
  44968. /**
  44969. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44970. * @param world The world matrix to bind.
  44971. * @param subMesh The submesh to bind for.
  44972. */
  44973. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44974. /**
  44975. * Dispose the material.
  44976. * @param forceDisposeEffect Force disposal of the associated effect.
  44977. * @param forceDisposeTextures Force disposal of the associated textures.
  44978. */
  44979. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44980. /**
  44981. * Clones the material.
  44982. * @param name The cloned name.
  44983. * @returns The cloned material.
  44984. */
  44985. clone(name: string): BackgroundMaterial;
  44986. /**
  44987. * Serializes the current material to its JSON representation.
  44988. * @returns The JSON representation.
  44989. */
  44990. serialize(): any;
  44991. /**
  44992. * Gets the class name of the material
  44993. * @returns "BackgroundMaterial"
  44994. */
  44995. getClassName(): string;
  44996. /**
  44997. * Parse a JSON input to create back a background material.
  44998. * @param source The JSON data to parse
  44999. * @param scene The scene to create the parsed material in
  45000. * @param rootUrl The root url of the assets the material depends upon
  45001. * @returns the instantiated BackgroundMaterial.
  45002. */
  45003. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45004. }
  45005. }
  45006. declare module BABYLON {
  45007. /**
  45008. * Represents the different options available during the creation of
  45009. * a Environment helper.
  45010. *
  45011. * This can control the default ground, skybox and image processing setup of your scene.
  45012. */
  45013. export interface IEnvironmentHelperOptions {
  45014. /**
  45015. * Specifies wether or not to create a ground.
  45016. * True by default.
  45017. */
  45018. createGround: boolean;
  45019. /**
  45020. * Specifies the ground size.
  45021. * 15 by default.
  45022. */
  45023. groundSize: number;
  45024. /**
  45025. * The texture used on the ground for the main color.
  45026. * Comes from the BabylonJS CDN by default.
  45027. *
  45028. * Remarks: Can be either a texture or a url.
  45029. */
  45030. groundTexture: string | BaseTexture;
  45031. /**
  45032. * The color mixed in the ground texture by default.
  45033. * BabylonJS clearColor by default.
  45034. */
  45035. groundColor: Color3;
  45036. /**
  45037. * Specifies the ground opacity.
  45038. * 1 by default.
  45039. */
  45040. groundOpacity: number;
  45041. /**
  45042. * Enables the ground to receive shadows.
  45043. * True by default.
  45044. */
  45045. enableGroundShadow: boolean;
  45046. /**
  45047. * Helps preventing the shadow to be fully black on the ground.
  45048. * 0.5 by default.
  45049. */
  45050. groundShadowLevel: number;
  45051. /**
  45052. * Creates a mirror texture attach to the ground.
  45053. * false by default.
  45054. */
  45055. enableGroundMirror: boolean;
  45056. /**
  45057. * Specifies the ground mirror size ratio.
  45058. * 0.3 by default as the default kernel is 64.
  45059. */
  45060. groundMirrorSizeRatio: number;
  45061. /**
  45062. * Specifies the ground mirror blur kernel size.
  45063. * 64 by default.
  45064. */
  45065. groundMirrorBlurKernel: number;
  45066. /**
  45067. * Specifies the ground mirror visibility amount.
  45068. * 1 by default
  45069. */
  45070. groundMirrorAmount: number;
  45071. /**
  45072. * Specifies the ground mirror reflectance weight.
  45073. * This uses the standard weight of the background material to setup the fresnel effect
  45074. * of the mirror.
  45075. * 1 by default.
  45076. */
  45077. groundMirrorFresnelWeight: number;
  45078. /**
  45079. * Specifies the ground mirror Falloff distance.
  45080. * This can helps reducing the size of the reflection.
  45081. * 0 by Default.
  45082. */
  45083. groundMirrorFallOffDistance: number;
  45084. /**
  45085. * Specifies the ground mirror texture type.
  45086. * Unsigned Int by Default.
  45087. */
  45088. groundMirrorTextureType: number;
  45089. /**
  45090. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45091. * the shown objects.
  45092. */
  45093. groundYBias: number;
  45094. /**
  45095. * Specifies wether or not to create a skybox.
  45096. * True by default.
  45097. */
  45098. createSkybox: boolean;
  45099. /**
  45100. * Specifies the skybox size.
  45101. * 20 by default.
  45102. */
  45103. skyboxSize: number;
  45104. /**
  45105. * The texture used on the skybox for the main color.
  45106. * Comes from the BabylonJS CDN by default.
  45107. *
  45108. * Remarks: Can be either a texture or a url.
  45109. */
  45110. skyboxTexture: string | BaseTexture;
  45111. /**
  45112. * The color mixed in the skybox texture by default.
  45113. * BabylonJS clearColor by default.
  45114. */
  45115. skyboxColor: Color3;
  45116. /**
  45117. * The background rotation around the Y axis of the scene.
  45118. * This helps aligning the key lights of your scene with the background.
  45119. * 0 by default.
  45120. */
  45121. backgroundYRotation: number;
  45122. /**
  45123. * Compute automatically the size of the elements to best fit with the scene.
  45124. */
  45125. sizeAuto: boolean;
  45126. /**
  45127. * Default position of the rootMesh if autoSize is not true.
  45128. */
  45129. rootPosition: Vector3;
  45130. /**
  45131. * Sets up the image processing in the scene.
  45132. * true by default.
  45133. */
  45134. setupImageProcessing: boolean;
  45135. /**
  45136. * The texture used as your environment texture in the scene.
  45137. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45138. *
  45139. * Remarks: Can be either a texture or a url.
  45140. */
  45141. environmentTexture: string | BaseTexture;
  45142. /**
  45143. * The value of the exposure to apply to the scene.
  45144. * 0.6 by default if setupImageProcessing is true.
  45145. */
  45146. cameraExposure: number;
  45147. /**
  45148. * The value of the contrast to apply to the scene.
  45149. * 1.6 by default if setupImageProcessing is true.
  45150. */
  45151. cameraContrast: number;
  45152. /**
  45153. * Specifies wether or not tonemapping should be enabled in the scene.
  45154. * true by default if setupImageProcessing is true.
  45155. */
  45156. toneMappingEnabled: boolean;
  45157. }
  45158. /**
  45159. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45160. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45161. * It also helps with the default setup of your imageProcessing configuration.
  45162. */
  45163. export class EnvironmentHelper {
  45164. /**
  45165. * Default ground texture URL.
  45166. */
  45167. private static _groundTextureCDNUrl;
  45168. /**
  45169. * Default skybox texture URL.
  45170. */
  45171. private static _skyboxTextureCDNUrl;
  45172. /**
  45173. * Default environment texture URL.
  45174. */
  45175. private static _environmentTextureCDNUrl;
  45176. /**
  45177. * Creates the default options for the helper.
  45178. */
  45179. private static _getDefaultOptions;
  45180. private _rootMesh;
  45181. /**
  45182. * Gets the root mesh created by the helper.
  45183. */
  45184. readonly rootMesh: Mesh;
  45185. private _skybox;
  45186. /**
  45187. * Gets the skybox created by the helper.
  45188. */
  45189. readonly skybox: Nullable<Mesh>;
  45190. private _skyboxTexture;
  45191. /**
  45192. * Gets the skybox texture created by the helper.
  45193. */
  45194. readonly skyboxTexture: Nullable<BaseTexture>;
  45195. private _skyboxMaterial;
  45196. /**
  45197. * Gets the skybox material created by the helper.
  45198. */
  45199. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45200. private _ground;
  45201. /**
  45202. * Gets the ground mesh created by the helper.
  45203. */
  45204. readonly ground: Nullable<Mesh>;
  45205. private _groundTexture;
  45206. /**
  45207. * Gets the ground texture created by the helper.
  45208. */
  45209. readonly groundTexture: Nullable<BaseTexture>;
  45210. private _groundMirror;
  45211. /**
  45212. * Gets the ground mirror created by the helper.
  45213. */
  45214. readonly groundMirror: Nullable<MirrorTexture>;
  45215. /**
  45216. * Gets the ground mirror render list to helps pushing the meshes
  45217. * you wish in the ground reflection.
  45218. */
  45219. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45220. private _groundMaterial;
  45221. /**
  45222. * Gets the ground material created by the helper.
  45223. */
  45224. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45225. /**
  45226. * Stores the creation options.
  45227. */
  45228. private readonly _scene;
  45229. private _options;
  45230. /**
  45231. * This observable will be notified with any error during the creation of the environment,
  45232. * mainly texture creation errors.
  45233. */
  45234. onErrorObservable: Observable<{
  45235. message?: string;
  45236. exception?: any;
  45237. }>;
  45238. /**
  45239. * constructor
  45240. * @param options Defines the options we want to customize the helper
  45241. * @param scene The scene to add the material to
  45242. */
  45243. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45244. /**
  45245. * Updates the background according to the new options
  45246. * @param options
  45247. */
  45248. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45249. /**
  45250. * Sets the primary color of all the available elements.
  45251. * @param color the main color to affect to the ground and the background
  45252. */
  45253. setMainColor(color: Color3): void;
  45254. /**
  45255. * Setup the image processing according to the specified options.
  45256. */
  45257. private _setupImageProcessing;
  45258. /**
  45259. * Setup the environment texture according to the specified options.
  45260. */
  45261. private _setupEnvironmentTexture;
  45262. /**
  45263. * Setup the background according to the specified options.
  45264. */
  45265. private _setupBackground;
  45266. /**
  45267. * Get the scene sizes according to the setup.
  45268. */
  45269. private _getSceneSize;
  45270. /**
  45271. * Setup the ground according to the specified options.
  45272. */
  45273. private _setupGround;
  45274. /**
  45275. * Setup the ground material according to the specified options.
  45276. */
  45277. private _setupGroundMaterial;
  45278. /**
  45279. * Setup the ground diffuse texture according to the specified options.
  45280. */
  45281. private _setupGroundDiffuseTexture;
  45282. /**
  45283. * Setup the ground mirror texture according to the specified options.
  45284. */
  45285. private _setupGroundMirrorTexture;
  45286. /**
  45287. * Setup the ground to receive the mirror texture.
  45288. */
  45289. private _setupMirrorInGroundMaterial;
  45290. /**
  45291. * Setup the skybox according to the specified options.
  45292. */
  45293. private _setupSkybox;
  45294. /**
  45295. * Setup the skybox material according to the specified options.
  45296. */
  45297. private _setupSkyboxMaterial;
  45298. /**
  45299. * Setup the skybox reflection texture according to the specified options.
  45300. */
  45301. private _setupSkyboxReflectionTexture;
  45302. private _errorHandler;
  45303. /**
  45304. * Dispose all the elements created by the Helper.
  45305. */
  45306. dispose(): void;
  45307. }
  45308. }
  45309. declare module BABYLON {
  45310. /**
  45311. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45312. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45313. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45314. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45315. */
  45316. export class PhotoDome extends TransformNode {
  45317. /**
  45318. * Define the image as a Monoscopic panoramic 360 image.
  45319. */
  45320. static readonly MODE_MONOSCOPIC: number;
  45321. /**
  45322. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45323. */
  45324. static readonly MODE_TOPBOTTOM: number;
  45325. /**
  45326. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45327. */
  45328. static readonly MODE_SIDEBYSIDE: number;
  45329. private _useDirectMapping;
  45330. /**
  45331. * The texture being displayed on the sphere
  45332. */
  45333. protected _photoTexture: Texture;
  45334. /**
  45335. * Gets or sets the texture being displayed on the sphere
  45336. */
  45337. photoTexture: Texture;
  45338. /**
  45339. * Observable raised when an error occured while loading the 360 image
  45340. */
  45341. onLoadErrorObservable: Observable<string>;
  45342. /**
  45343. * The skybox material
  45344. */
  45345. protected _material: BackgroundMaterial;
  45346. /**
  45347. * The surface used for the skybox
  45348. */
  45349. protected _mesh: Mesh;
  45350. /**
  45351. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45352. * Also see the options.resolution property.
  45353. */
  45354. fovMultiplier: number;
  45355. private _imageMode;
  45356. /**
  45357. * Gets or set the current video mode for the video. It can be:
  45358. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  45359. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45360. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45361. */
  45362. imageMode: number;
  45363. /**
  45364. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45365. * @param name Element's name, child elements will append suffixes for their own names.
  45366. * @param urlsOfPhoto defines the url of the photo to display
  45367. * @param options defines an object containing optional or exposed sub element properties
  45368. * @param onError defines a callback called when an error occured while loading the texture
  45369. */
  45370. constructor(name: string, urlOfPhoto: string, options: {
  45371. resolution?: number;
  45372. size?: number;
  45373. useDirectMapping?: boolean;
  45374. faceForward?: boolean;
  45375. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45376. private _onBeforeCameraRenderObserver;
  45377. private _changeImageMode;
  45378. /**
  45379. * Releases resources associated with this node.
  45380. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45381. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45382. */
  45383. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45384. }
  45385. }
  45386. declare module BABYLON {
  45387. /** @hidden */
  45388. export var rgbdDecodePixelShader: {
  45389. name: string;
  45390. shader: string;
  45391. };
  45392. }
  45393. declare module BABYLON {
  45394. /**
  45395. * Class used to host texture specific utilities
  45396. */
  45397. export class BRDFTextureTools {
  45398. /**
  45399. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45400. * @param texture the texture to expand.
  45401. */
  45402. private static _ExpandDefaultBRDFTexture;
  45403. /**
  45404. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45405. * @param scene defines the hosting scene
  45406. * @returns the environment BRDF texture
  45407. */
  45408. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45409. private static _environmentBRDFBase64Texture;
  45410. }
  45411. }
  45412. declare module BABYLON {
  45413. /**
  45414. * @hidden
  45415. */
  45416. export interface IMaterialClearCoatDefines {
  45417. CLEARCOAT: boolean;
  45418. CLEARCOAT_DEFAULTIOR: boolean;
  45419. CLEARCOAT_TEXTURE: boolean;
  45420. CLEARCOAT_TEXTUREDIRECTUV: number;
  45421. CLEARCOAT_BUMP: boolean;
  45422. CLEARCOAT_BUMPDIRECTUV: number;
  45423. CLEARCOAT_TINT: boolean;
  45424. CLEARCOAT_TINT_TEXTURE: boolean;
  45425. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45426. /** @hidden */
  45427. _areTexturesDirty: boolean;
  45428. }
  45429. /**
  45430. * Define the code related to the clear coat parameters of the pbr material.
  45431. */
  45432. export class PBRClearCoatConfiguration {
  45433. /**
  45434. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45435. * The default fits with a polyurethane material.
  45436. */
  45437. private static readonly _DefaultIndexOfRefraction;
  45438. private _isEnabled;
  45439. /**
  45440. * Defines if the clear coat is enabled in the material.
  45441. */
  45442. isEnabled: boolean;
  45443. /**
  45444. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45445. */
  45446. intensity: number;
  45447. /**
  45448. * Defines the clear coat layer roughness.
  45449. */
  45450. roughness: number;
  45451. private _indexOfRefraction;
  45452. /**
  45453. * Defines the index of refraction of the clear coat.
  45454. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45455. * The default fits with a polyurethane material.
  45456. * Changing the default value is more performance intensive.
  45457. */
  45458. indexOfRefraction: number;
  45459. private _texture;
  45460. /**
  45461. * Stores the clear coat values in a texture.
  45462. */
  45463. texture: Nullable<BaseTexture>;
  45464. private _bumpTexture;
  45465. /**
  45466. * Define the clear coat specific bump texture.
  45467. */
  45468. bumpTexture: Nullable<BaseTexture>;
  45469. private _isTintEnabled;
  45470. /**
  45471. * Defines if the clear coat tint is enabled in the material.
  45472. */
  45473. isTintEnabled: boolean;
  45474. /**
  45475. * Defines the clear coat tint of the material.
  45476. * This is only use if tint is enabled
  45477. */
  45478. tintColor: Color3;
  45479. /**
  45480. * Defines the distance at which the tint color should be found in the
  45481. * clear coat media.
  45482. * This is only use if tint is enabled
  45483. */
  45484. tintColorAtDistance: number;
  45485. /**
  45486. * Defines the clear coat layer thickness.
  45487. * This is only use if tint is enabled
  45488. */
  45489. tintThickness: number;
  45490. private _tintTexture;
  45491. /**
  45492. * Stores the clear tint values in a texture.
  45493. * rgb is tint
  45494. * a is a thickness factor
  45495. */
  45496. tintTexture: Nullable<BaseTexture>;
  45497. /** @hidden */
  45498. private _internalMarkAllSubMeshesAsTexturesDirty;
  45499. /** @hidden */
  45500. _markAllSubMeshesAsTexturesDirty(): void;
  45501. /**
  45502. * Instantiate a new istance of clear coat configuration.
  45503. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45504. */
  45505. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45506. /**
  45507. * Gets wehter the submesh is ready to be used or not.
  45508. * @param defines the list of "defines" to update.
  45509. * @param scene defines the scene the material belongs to.
  45510. * @param engine defines the engine the material belongs to.
  45511. * @param disableBumpMap defines wether the material disables bump or not.
  45512. * @returns - boolean indicating that the submesh is ready or not.
  45513. */
  45514. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45515. /**
  45516. * Checks to see if a texture is used in the material.
  45517. * @param defines the list of "defines" to update.
  45518. * @param scene defines the scene to the material belongs to.
  45519. */
  45520. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45521. /**
  45522. * Binds the material data.
  45523. * @param uniformBuffer defines the Uniform buffer to fill in.
  45524. * @param scene defines the scene the material belongs to.
  45525. * @param engine defines the engine the material belongs to.
  45526. * @param disableBumpMap defines wether the material disables bump or not.
  45527. * @param isFrozen defines wether the material is frozen or not.
  45528. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45529. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45530. */
  45531. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45532. /**
  45533. * Checks to see if a texture is used in the material.
  45534. * @param texture - Base texture to use.
  45535. * @returns - Boolean specifying if a texture is used in the material.
  45536. */
  45537. hasTexture(texture: BaseTexture): boolean;
  45538. /**
  45539. * Returns an array of the actively used textures.
  45540. * @param activeTextures Array of BaseTextures
  45541. */
  45542. getActiveTextures(activeTextures: BaseTexture[]): void;
  45543. /**
  45544. * Returns the animatable textures.
  45545. * @param animatables Array of animatable textures.
  45546. */
  45547. getAnimatables(animatables: IAnimatable[]): void;
  45548. /**
  45549. * Disposes the resources of the material.
  45550. * @param forceDisposeTextures - Forces the disposal of all textures.
  45551. */
  45552. dispose(forceDisposeTextures?: boolean): void;
  45553. /**
  45554. * Get the current class name of the texture useful for serialization or dynamic coding.
  45555. * @returns "PBRClearCoatConfiguration"
  45556. */
  45557. getClassName(): string;
  45558. /**
  45559. * Add fallbacks to the effect fallbacks list.
  45560. * @param defines defines the Base texture to use.
  45561. * @param fallbacks defines the current fallback list.
  45562. * @param currentRank defines the current fallback rank.
  45563. * @returns the new fallback rank.
  45564. */
  45565. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45566. /**
  45567. * Add the required uniforms to the current list.
  45568. * @param uniforms defines the current uniform list.
  45569. */
  45570. static AddUniforms(uniforms: string[]): void;
  45571. /**
  45572. * Add the required samplers to the current list.
  45573. * @param samplers defines the current sampler list.
  45574. */
  45575. static AddSamplers(samplers: string[]): void;
  45576. /**
  45577. * Add the required uniforms to the current buffer.
  45578. * @param uniformBuffer defines the current uniform buffer.
  45579. */
  45580. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45581. /**
  45582. * Makes a duplicate of the current configuration into another one.
  45583. * @param clearCoatConfiguration define the config where to copy the info
  45584. */
  45585. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45586. /**
  45587. * Serializes this clear coat configuration.
  45588. * @returns - An object with the serialized config.
  45589. */
  45590. serialize(): any;
  45591. /**
  45592. * Parses a anisotropy Configuration from a serialized object.
  45593. * @param source - Serialized object.
  45594. * @param scene Defines the scene we are parsing for
  45595. * @param rootUrl Defines the rootUrl to load from
  45596. */
  45597. parse(source: any, scene: Scene, rootUrl: string): void;
  45598. }
  45599. }
  45600. declare module BABYLON {
  45601. /**
  45602. * @hidden
  45603. */
  45604. export interface IMaterialAnisotropicDefines {
  45605. ANISOTROPIC: boolean;
  45606. ANISOTROPIC_TEXTURE: boolean;
  45607. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45608. MAINUV1: boolean;
  45609. _areTexturesDirty: boolean;
  45610. _needUVs: boolean;
  45611. }
  45612. /**
  45613. * Define the code related to the anisotropic parameters of the pbr material.
  45614. */
  45615. export class PBRAnisotropicConfiguration {
  45616. private _isEnabled;
  45617. /**
  45618. * Defines if the anisotropy is enabled in the material.
  45619. */
  45620. isEnabled: boolean;
  45621. /**
  45622. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45623. */
  45624. intensity: number;
  45625. /**
  45626. * Defines if the effect is along the tangents, bitangents or in between.
  45627. * By default, the effect is "strectching" the highlights along the tangents.
  45628. */
  45629. direction: Vector2;
  45630. private _texture;
  45631. /**
  45632. * Stores the anisotropy values in a texture.
  45633. * rg is direction (like normal from -1 to 1)
  45634. * b is a intensity
  45635. */
  45636. texture: Nullable<BaseTexture>;
  45637. /** @hidden */
  45638. private _internalMarkAllSubMeshesAsTexturesDirty;
  45639. /** @hidden */
  45640. _markAllSubMeshesAsTexturesDirty(): void;
  45641. /**
  45642. * Instantiate a new istance of anisotropy configuration.
  45643. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45644. */
  45645. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45646. /**
  45647. * Specifies that the submesh is ready to be used.
  45648. * @param defines the list of "defines" to update.
  45649. * @param scene defines the scene the material belongs to.
  45650. * @returns - boolean indicating that the submesh is ready or not.
  45651. */
  45652. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45653. /**
  45654. * Checks to see if a texture is used in the material.
  45655. * @param defines the list of "defines" to update.
  45656. * @param mesh the mesh we are preparing the defines for.
  45657. * @param scene defines the scene the material belongs to.
  45658. */
  45659. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45660. /**
  45661. * Binds the material data.
  45662. * @param uniformBuffer defines the Uniform buffer to fill in.
  45663. * @param scene defines the scene the material belongs to.
  45664. * @param isFrozen defines wether the material is frozen or not.
  45665. */
  45666. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45667. /**
  45668. * Checks to see if a texture is used in the material.
  45669. * @param texture - Base texture to use.
  45670. * @returns - Boolean specifying if a texture is used in the material.
  45671. */
  45672. hasTexture(texture: BaseTexture): boolean;
  45673. /**
  45674. * Returns an array of the actively used textures.
  45675. * @param activeTextures Array of BaseTextures
  45676. */
  45677. getActiveTextures(activeTextures: BaseTexture[]): void;
  45678. /**
  45679. * Returns the animatable textures.
  45680. * @param animatables Array of animatable textures.
  45681. */
  45682. getAnimatables(animatables: IAnimatable[]): void;
  45683. /**
  45684. * Disposes the resources of the material.
  45685. * @param forceDisposeTextures - Forces the disposal of all textures.
  45686. */
  45687. dispose(forceDisposeTextures?: boolean): void;
  45688. /**
  45689. * Get the current class name of the texture useful for serialization or dynamic coding.
  45690. * @returns "PBRAnisotropicConfiguration"
  45691. */
  45692. getClassName(): string;
  45693. /**
  45694. * Add fallbacks to the effect fallbacks list.
  45695. * @param defines defines the Base texture to use.
  45696. * @param fallbacks defines the current fallback list.
  45697. * @param currentRank defines the current fallback rank.
  45698. * @returns the new fallback rank.
  45699. */
  45700. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45701. /**
  45702. * Add the required uniforms to the current list.
  45703. * @param uniforms defines the current uniform list.
  45704. */
  45705. static AddUniforms(uniforms: string[]): void;
  45706. /**
  45707. * Add the required uniforms to the current buffer.
  45708. * @param uniformBuffer defines the current uniform buffer.
  45709. */
  45710. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45711. /**
  45712. * Add the required samplers to the current list.
  45713. * @param samplers defines the current sampler list.
  45714. */
  45715. static AddSamplers(samplers: string[]): void;
  45716. /**
  45717. * Makes a duplicate of the current configuration into another one.
  45718. * @param anisotropicConfiguration define the config where to copy the info
  45719. */
  45720. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45721. /**
  45722. * Serializes this anisotropy configuration.
  45723. * @returns - An object with the serialized config.
  45724. */
  45725. serialize(): any;
  45726. /**
  45727. * Parses a anisotropy Configuration from a serialized object.
  45728. * @param source - Serialized object.
  45729. * @param scene Defines the scene we are parsing for
  45730. * @param rootUrl Defines the rootUrl to load from
  45731. */
  45732. parse(source: any, scene: Scene, rootUrl: string): void;
  45733. }
  45734. }
  45735. declare module BABYLON {
  45736. /**
  45737. * @hidden
  45738. */
  45739. export interface IMaterialBRDFDefines {
  45740. BRDF_V_HEIGHT_CORRELATED: boolean;
  45741. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45742. SPHERICAL_HARMONICS: boolean;
  45743. /** @hidden */
  45744. _areMiscDirty: boolean;
  45745. }
  45746. /**
  45747. * Define the code related to the BRDF parameters of the pbr material.
  45748. */
  45749. export class PBRBRDFConfiguration {
  45750. /**
  45751. * Default value used for the energy conservation.
  45752. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45753. */
  45754. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  45755. /**
  45756. * Default value used for the Smith Visibility Height Correlated mode.
  45757. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45758. */
  45759. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45760. /**
  45761. * Default value used for the IBL diffuse part.
  45762. * This can help switching back to the polynomials mode globally which is a tiny bit
  45763. * less GPU intensive at the drawback of a lower quality.
  45764. */
  45765. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  45766. private _useEnergyConservation;
  45767. /**
  45768. * Defines if the material uses energy conservation.
  45769. */
  45770. useEnergyConservation: boolean;
  45771. private _useSmithVisibilityHeightCorrelated;
  45772. /**
  45773. * LEGACY Mode set to false
  45774. * Defines if the material uses height smith correlated visibility term.
  45775. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45776. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45777. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45778. * Not relying on height correlated will also disable energy conservation.
  45779. */
  45780. useSmithVisibilityHeightCorrelated: boolean;
  45781. private _useSphericalHarmonics;
  45782. /**
  45783. * LEGACY Mode set to false
  45784. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  45785. * diffuse part of the IBL.
  45786. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  45787. * to the ground truth.
  45788. */
  45789. useSphericalHarmonics: boolean;
  45790. /** @hidden */
  45791. private _internalMarkAllSubMeshesAsMiscDirty;
  45792. /** @hidden */
  45793. _markAllSubMeshesAsMiscDirty(): void;
  45794. /**
  45795. * Instantiate a new istance of clear coat configuration.
  45796. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45797. */
  45798. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45799. /**
  45800. * Checks to see if a texture is used in the material.
  45801. * @param defines the list of "defines" to update.
  45802. */
  45803. prepareDefines(defines: IMaterialBRDFDefines): void;
  45804. /**
  45805. * Get the current class name of the texture useful for serialization or dynamic coding.
  45806. * @returns "PBRClearCoatConfiguration"
  45807. */
  45808. getClassName(): string;
  45809. /**
  45810. * Makes a duplicate of the current configuration into another one.
  45811. * @param brdfConfiguration define the config where to copy the info
  45812. */
  45813. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45814. /**
  45815. * Serializes this BRDF configuration.
  45816. * @returns - An object with the serialized config.
  45817. */
  45818. serialize(): any;
  45819. /**
  45820. * Parses a anisotropy Configuration from a serialized object.
  45821. * @param source - Serialized object.
  45822. * @param scene Defines the scene we are parsing for
  45823. * @param rootUrl Defines the rootUrl to load from
  45824. */
  45825. parse(source: any, scene: Scene, rootUrl: string): void;
  45826. }
  45827. }
  45828. declare module BABYLON {
  45829. /**
  45830. * @hidden
  45831. */
  45832. export interface IMaterialSheenDefines {
  45833. SHEEN: boolean;
  45834. SHEEN_TEXTURE: boolean;
  45835. SHEEN_TEXTUREDIRECTUV: number;
  45836. SHEEN_LINKWITHALBEDO: boolean;
  45837. /** @hidden */
  45838. _areTexturesDirty: boolean;
  45839. }
  45840. /**
  45841. * Define the code related to the Sheen parameters of the pbr material.
  45842. */
  45843. export class PBRSheenConfiguration {
  45844. private _isEnabled;
  45845. /**
  45846. * Defines if the material uses sheen.
  45847. */
  45848. isEnabled: boolean;
  45849. private _linkSheenWithAlbedo;
  45850. /**
  45851. * Defines if the sheen is linked to the sheen color.
  45852. */
  45853. linkSheenWithAlbedo: boolean;
  45854. /**
  45855. * Defines the sheen intensity.
  45856. */
  45857. intensity: number;
  45858. /**
  45859. * Defines the sheen color.
  45860. */
  45861. color: Color3;
  45862. private _texture;
  45863. /**
  45864. * Stores the sheen tint values in a texture.
  45865. * rgb is tint
  45866. * a is a intensity
  45867. */
  45868. texture: Nullable<BaseTexture>;
  45869. /** @hidden */
  45870. private _internalMarkAllSubMeshesAsTexturesDirty;
  45871. /** @hidden */
  45872. _markAllSubMeshesAsTexturesDirty(): void;
  45873. /**
  45874. * Instantiate a new istance of clear coat configuration.
  45875. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45876. */
  45877. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45878. /**
  45879. * Specifies that the submesh is ready to be used.
  45880. * @param defines the list of "defines" to update.
  45881. * @param scene defines the scene the material belongs to.
  45882. * @returns - boolean indicating that the submesh is ready or not.
  45883. */
  45884. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45885. /**
  45886. * Checks to see if a texture is used in the material.
  45887. * @param defines the list of "defines" to update.
  45888. * @param scene defines the scene the material belongs to.
  45889. */
  45890. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45891. /**
  45892. * Binds the material data.
  45893. * @param uniformBuffer defines the Uniform buffer to fill in.
  45894. * @param scene defines the scene the material belongs to.
  45895. * @param isFrozen defines wether the material is frozen or not.
  45896. */
  45897. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45898. /**
  45899. * Checks to see if a texture is used in the material.
  45900. * @param texture - Base texture to use.
  45901. * @returns - Boolean specifying if a texture is used in the material.
  45902. */
  45903. hasTexture(texture: BaseTexture): boolean;
  45904. /**
  45905. * Returns an array of the actively used textures.
  45906. * @param activeTextures Array of BaseTextures
  45907. */
  45908. getActiveTextures(activeTextures: BaseTexture[]): void;
  45909. /**
  45910. * Returns the animatable textures.
  45911. * @param animatables Array of animatable textures.
  45912. */
  45913. getAnimatables(animatables: IAnimatable[]): void;
  45914. /**
  45915. * Disposes the resources of the material.
  45916. * @param forceDisposeTextures - Forces the disposal of all textures.
  45917. */
  45918. dispose(forceDisposeTextures?: boolean): void;
  45919. /**
  45920. * Get the current class name of the texture useful for serialization or dynamic coding.
  45921. * @returns "PBRSheenConfiguration"
  45922. */
  45923. getClassName(): string;
  45924. /**
  45925. * Add fallbacks to the effect fallbacks list.
  45926. * @param defines defines the Base texture to use.
  45927. * @param fallbacks defines the current fallback list.
  45928. * @param currentRank defines the current fallback rank.
  45929. * @returns the new fallback rank.
  45930. */
  45931. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45932. /**
  45933. * Add the required uniforms to the current list.
  45934. * @param uniforms defines the current uniform list.
  45935. */
  45936. static AddUniforms(uniforms: string[]): void;
  45937. /**
  45938. * Add the required uniforms to the current buffer.
  45939. * @param uniformBuffer defines the current uniform buffer.
  45940. */
  45941. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45942. /**
  45943. * Add the required samplers to the current list.
  45944. * @param samplers defines the current sampler list.
  45945. */
  45946. static AddSamplers(samplers: string[]): void;
  45947. /**
  45948. * Makes a duplicate of the current configuration into another one.
  45949. * @param sheenConfiguration define the config where to copy the info
  45950. */
  45951. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45952. /**
  45953. * Serializes this BRDF configuration.
  45954. * @returns - An object with the serialized config.
  45955. */
  45956. serialize(): any;
  45957. /**
  45958. * Parses a anisotropy Configuration from a serialized object.
  45959. * @param source - Serialized object.
  45960. * @param scene Defines the scene we are parsing for
  45961. * @param rootUrl Defines the rootUrl to load from
  45962. */
  45963. parse(source: any, scene: Scene, rootUrl: string): void;
  45964. }
  45965. }
  45966. declare module BABYLON {
  45967. /**
  45968. * @hidden
  45969. */
  45970. export interface IMaterialSubSurfaceDefines {
  45971. SUBSURFACE: boolean;
  45972. SS_REFRACTION: boolean;
  45973. SS_TRANSLUCENCY: boolean;
  45974. SS_SCATERRING: boolean;
  45975. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45976. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45977. SS_REFRACTIONMAP_3D: boolean;
  45978. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45979. SS_LODINREFRACTIONALPHA: boolean;
  45980. SS_GAMMAREFRACTION: boolean;
  45981. SS_RGBDREFRACTION: boolean;
  45982. SS_LINEARSPECULARREFRACTION: boolean;
  45983. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45984. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45985. /** @hidden */
  45986. _areTexturesDirty: boolean;
  45987. }
  45988. /**
  45989. * Define the code related to the sub surface parameters of the pbr material.
  45990. */
  45991. export class PBRSubSurfaceConfiguration {
  45992. private _isRefractionEnabled;
  45993. /**
  45994. * Defines if the refraction is enabled in the material.
  45995. */
  45996. isRefractionEnabled: boolean;
  45997. private _isTranslucencyEnabled;
  45998. /**
  45999. * Defines if the translucency is enabled in the material.
  46000. */
  46001. isTranslucencyEnabled: boolean;
  46002. private _isScatteringEnabled;
  46003. /**
  46004. * Defines the refraction intensity of the material.
  46005. * The refraction when enabled replaces the Diffuse part of the material.
  46006. * The intensity helps transitionning between diffuse and refraction.
  46007. */
  46008. refractionIntensity: number;
  46009. /**
  46010. * Defines the translucency intensity of the material.
  46011. * When translucency has been enabled, this defines how much of the "translucency"
  46012. * is addded to the diffuse part of the material.
  46013. */
  46014. translucencyIntensity: number;
  46015. /**
  46016. * Defines the scattering intensity of the material.
  46017. * When scattering has been enabled, this defines how much of the "scattered light"
  46018. * is addded to the diffuse part of the material.
  46019. */
  46020. scatteringIntensity: number;
  46021. private _thicknessTexture;
  46022. /**
  46023. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46024. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46025. * 0 would mean minimumThickness
  46026. * 1 would mean maximumThickness
  46027. * The other channels might be use as a mask to vary the different effects intensity.
  46028. */
  46029. thicknessTexture: Nullable<BaseTexture>;
  46030. private _refractionTexture;
  46031. /**
  46032. * Defines the texture to use for refraction.
  46033. */
  46034. refractionTexture: Nullable<BaseTexture>;
  46035. private _indexOfRefraction;
  46036. /**
  46037. * Defines the index of refraction used in the material.
  46038. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46039. */
  46040. indexOfRefraction: number;
  46041. private _invertRefractionY;
  46042. /**
  46043. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46044. */
  46045. invertRefractionY: boolean;
  46046. private _linkRefractionWithTransparency;
  46047. /**
  46048. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46049. * Materials half opaque for instance using refraction could benefit from this control.
  46050. */
  46051. linkRefractionWithTransparency: boolean;
  46052. /**
  46053. * Defines the minimum thickness stored in the thickness map.
  46054. * If no thickness map is defined, this value will be used to simulate thickness.
  46055. */
  46056. minimumThickness: number;
  46057. /**
  46058. * Defines the maximum thickness stored in the thickness map.
  46059. */
  46060. maximumThickness: number;
  46061. /**
  46062. * Defines the volume tint of the material.
  46063. * This is used for both translucency and scattering.
  46064. */
  46065. tintColor: Color3;
  46066. /**
  46067. * Defines the distance at which the tint color should be found in the media.
  46068. * This is used for refraction only.
  46069. */
  46070. tintColorAtDistance: number;
  46071. /**
  46072. * Defines how far each channel transmit through the media.
  46073. * It is defined as a color to simplify it selection.
  46074. */
  46075. diffusionDistance: Color3;
  46076. private _useMaskFromThicknessTexture;
  46077. /**
  46078. * Stores the intensity of the different subsurface effects in the thickness texture.
  46079. * * the green channel is the translucency intensity.
  46080. * * the blue channel is the scattering intensity.
  46081. * * the alpha channel is the refraction intensity.
  46082. */
  46083. useMaskFromThicknessTexture: boolean;
  46084. /** @hidden */
  46085. private _internalMarkAllSubMeshesAsTexturesDirty;
  46086. /** @hidden */
  46087. _markAllSubMeshesAsTexturesDirty(): void;
  46088. /**
  46089. * Instantiate a new istance of sub surface configuration.
  46090. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46091. */
  46092. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46093. /**
  46094. * Gets wehter the submesh is ready to be used or not.
  46095. * @param defines the list of "defines" to update.
  46096. * @param scene defines the scene the material belongs to.
  46097. * @returns - boolean indicating that the submesh is ready or not.
  46098. */
  46099. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46100. /**
  46101. * Checks to see if a texture is used in the material.
  46102. * @param defines the list of "defines" to update.
  46103. * @param scene defines the scene to the material belongs to.
  46104. */
  46105. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46106. /**
  46107. * Binds the material data.
  46108. * @param uniformBuffer defines the Uniform buffer to fill in.
  46109. * @param scene defines the scene the material belongs to.
  46110. * @param engine defines the engine the material belongs to.
  46111. * @param isFrozen defines wether the material is frozen or not.
  46112. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46113. */
  46114. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46115. /**
  46116. * Unbinds the material from the mesh.
  46117. * @param activeEffect defines the effect that should be unbound from.
  46118. * @returns true if unbound, otherwise false
  46119. */
  46120. unbind(activeEffect: Effect): boolean;
  46121. /**
  46122. * Returns the texture used for refraction or null if none is used.
  46123. * @param scene defines the scene the material belongs to.
  46124. * @returns - Refraction texture if present. If no refraction texture and refraction
  46125. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46126. */
  46127. private _getRefractionTexture;
  46128. /**
  46129. * Returns true if alpha blending should be disabled.
  46130. */
  46131. readonly disableAlphaBlending: boolean;
  46132. /**
  46133. * Fills the list of render target textures.
  46134. * @param renderTargets the list of render targets to update
  46135. */
  46136. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46137. /**
  46138. * Checks to see if a texture is used in the material.
  46139. * @param texture - Base texture to use.
  46140. * @returns - Boolean specifying if a texture is used in the material.
  46141. */
  46142. hasTexture(texture: BaseTexture): boolean;
  46143. /**
  46144. * Gets a boolean indicating that current material needs to register RTT
  46145. * @returns true if this uses a render target otherwise false.
  46146. */
  46147. hasRenderTargetTextures(): boolean;
  46148. /**
  46149. * Returns an array of the actively used textures.
  46150. * @param activeTextures Array of BaseTextures
  46151. */
  46152. getActiveTextures(activeTextures: BaseTexture[]): void;
  46153. /**
  46154. * Returns the animatable textures.
  46155. * @param animatables Array of animatable textures.
  46156. */
  46157. getAnimatables(animatables: IAnimatable[]): void;
  46158. /**
  46159. * Disposes the resources of the material.
  46160. * @param forceDisposeTextures - Forces the disposal of all textures.
  46161. */
  46162. dispose(forceDisposeTextures?: boolean): void;
  46163. /**
  46164. * Get the current class name of the texture useful for serialization or dynamic coding.
  46165. * @returns "PBRSubSurfaceConfiguration"
  46166. */
  46167. getClassName(): string;
  46168. /**
  46169. * Add fallbacks to the effect fallbacks list.
  46170. * @param defines defines the Base texture to use.
  46171. * @param fallbacks defines the current fallback list.
  46172. * @param currentRank defines the current fallback rank.
  46173. * @returns the new fallback rank.
  46174. */
  46175. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46176. /**
  46177. * Add the required uniforms to the current list.
  46178. * @param uniforms defines the current uniform list.
  46179. */
  46180. static AddUniforms(uniforms: string[]): void;
  46181. /**
  46182. * Add the required samplers to the current list.
  46183. * @param samplers defines the current sampler list.
  46184. */
  46185. static AddSamplers(samplers: string[]): void;
  46186. /**
  46187. * Add the required uniforms to the current buffer.
  46188. * @param uniformBuffer defines the current uniform buffer.
  46189. */
  46190. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46191. /**
  46192. * Makes a duplicate of the current configuration into another one.
  46193. * @param configuration define the config where to copy the info
  46194. */
  46195. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46196. /**
  46197. * Serializes this Sub Surface configuration.
  46198. * @returns - An object with the serialized config.
  46199. */
  46200. serialize(): any;
  46201. /**
  46202. * Parses a anisotropy Configuration from a serialized object.
  46203. * @param source - Serialized object.
  46204. * @param scene Defines the scene we are parsing for
  46205. * @param rootUrl Defines the rootUrl to load from
  46206. */
  46207. parse(source: any, scene: Scene, rootUrl: string): void;
  46208. }
  46209. }
  46210. declare module BABYLON {
  46211. /** @hidden */
  46212. export var pbrFragmentDeclaration: {
  46213. name: string;
  46214. shader: string;
  46215. };
  46216. }
  46217. declare module BABYLON {
  46218. /** @hidden */
  46219. export var pbrUboDeclaration: {
  46220. name: string;
  46221. shader: string;
  46222. };
  46223. }
  46224. declare module BABYLON {
  46225. /** @hidden */
  46226. export var pbrFragmentExtraDeclaration: {
  46227. name: string;
  46228. shader: string;
  46229. };
  46230. }
  46231. declare module BABYLON {
  46232. /** @hidden */
  46233. export var pbrFragmentSamplersDeclaration: {
  46234. name: string;
  46235. shader: string;
  46236. };
  46237. }
  46238. declare module BABYLON {
  46239. /** @hidden */
  46240. export var pbrHelperFunctions: {
  46241. name: string;
  46242. shader: string;
  46243. };
  46244. }
  46245. declare module BABYLON {
  46246. /** @hidden */
  46247. export var harmonicsFunctions: {
  46248. name: string;
  46249. shader: string;
  46250. };
  46251. }
  46252. declare module BABYLON {
  46253. /** @hidden */
  46254. export var pbrDirectLightingSetupFunctions: {
  46255. name: string;
  46256. shader: string;
  46257. };
  46258. }
  46259. declare module BABYLON {
  46260. /** @hidden */
  46261. export var pbrDirectLightingFalloffFunctions: {
  46262. name: string;
  46263. shader: string;
  46264. };
  46265. }
  46266. declare module BABYLON {
  46267. /** @hidden */
  46268. export var pbrBRDFFunctions: {
  46269. name: string;
  46270. shader: string;
  46271. };
  46272. }
  46273. declare module BABYLON {
  46274. /** @hidden */
  46275. export var pbrDirectLightingFunctions: {
  46276. name: string;
  46277. shader: string;
  46278. };
  46279. }
  46280. declare module BABYLON {
  46281. /** @hidden */
  46282. export var pbrIBLFunctions: {
  46283. name: string;
  46284. shader: string;
  46285. };
  46286. }
  46287. declare module BABYLON {
  46288. /** @hidden */
  46289. export var pbrDebug: {
  46290. name: string;
  46291. shader: string;
  46292. };
  46293. }
  46294. declare module BABYLON {
  46295. /** @hidden */
  46296. export var pbrPixelShader: {
  46297. name: string;
  46298. shader: string;
  46299. };
  46300. }
  46301. declare module BABYLON {
  46302. /** @hidden */
  46303. export var pbrVertexDeclaration: {
  46304. name: string;
  46305. shader: string;
  46306. };
  46307. }
  46308. declare module BABYLON {
  46309. /** @hidden */
  46310. export var pbrVertexShader: {
  46311. name: string;
  46312. shader: string;
  46313. };
  46314. }
  46315. declare module BABYLON {
  46316. /**
  46317. * Manages the defines for the PBR Material.
  46318. * @hidden
  46319. */
  46320. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46321. PBR: boolean;
  46322. MAINUV1: boolean;
  46323. MAINUV2: boolean;
  46324. UV1: boolean;
  46325. UV2: boolean;
  46326. ALBEDO: boolean;
  46327. ALBEDODIRECTUV: number;
  46328. VERTEXCOLOR: boolean;
  46329. AMBIENT: boolean;
  46330. AMBIENTDIRECTUV: number;
  46331. AMBIENTINGRAYSCALE: boolean;
  46332. OPACITY: boolean;
  46333. VERTEXALPHA: boolean;
  46334. OPACITYDIRECTUV: number;
  46335. OPACITYRGB: boolean;
  46336. ALPHATEST: boolean;
  46337. DEPTHPREPASS: boolean;
  46338. ALPHABLEND: boolean;
  46339. ALPHAFROMALBEDO: boolean;
  46340. ALPHATESTVALUE: string;
  46341. SPECULAROVERALPHA: boolean;
  46342. RADIANCEOVERALPHA: boolean;
  46343. ALPHAFRESNEL: boolean;
  46344. LINEARALPHAFRESNEL: boolean;
  46345. PREMULTIPLYALPHA: boolean;
  46346. EMISSIVE: boolean;
  46347. EMISSIVEDIRECTUV: number;
  46348. REFLECTIVITY: boolean;
  46349. REFLECTIVITYDIRECTUV: number;
  46350. SPECULARTERM: boolean;
  46351. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46352. MICROSURFACEAUTOMATIC: boolean;
  46353. LODBASEDMICROSFURACE: boolean;
  46354. MICROSURFACEMAP: boolean;
  46355. MICROSURFACEMAPDIRECTUV: number;
  46356. METALLICWORKFLOW: boolean;
  46357. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46358. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46359. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46360. AOSTOREINMETALMAPRED: boolean;
  46361. ENVIRONMENTBRDF: boolean;
  46362. ENVIRONMENTBRDF_RGBD: boolean;
  46363. NORMAL: boolean;
  46364. TANGENT: boolean;
  46365. BUMP: boolean;
  46366. BUMPDIRECTUV: number;
  46367. OBJECTSPACE_NORMALMAP: boolean;
  46368. PARALLAX: boolean;
  46369. PARALLAXOCCLUSION: boolean;
  46370. NORMALXYSCALE: boolean;
  46371. LIGHTMAP: boolean;
  46372. LIGHTMAPDIRECTUV: number;
  46373. USELIGHTMAPASSHADOWMAP: boolean;
  46374. GAMMALIGHTMAP: boolean;
  46375. REFLECTION: boolean;
  46376. REFLECTIONMAP_3D: boolean;
  46377. REFLECTIONMAP_SPHERICAL: boolean;
  46378. REFLECTIONMAP_PLANAR: boolean;
  46379. REFLECTIONMAP_CUBIC: boolean;
  46380. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46381. REFLECTIONMAP_PROJECTION: boolean;
  46382. REFLECTIONMAP_SKYBOX: boolean;
  46383. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46384. REFLECTIONMAP_EXPLICIT: boolean;
  46385. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46386. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46387. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46388. INVERTCUBICMAP: boolean;
  46389. USESPHERICALFROMREFLECTIONMAP: boolean;
  46390. USEIRRADIANCEMAP: boolean;
  46391. SPHERICAL_HARMONICS: boolean;
  46392. USESPHERICALINVERTEX: boolean;
  46393. REFLECTIONMAP_OPPOSITEZ: boolean;
  46394. LODINREFLECTIONALPHA: boolean;
  46395. GAMMAREFLECTION: boolean;
  46396. RGBDREFLECTION: boolean;
  46397. LINEARSPECULARREFLECTION: boolean;
  46398. RADIANCEOCCLUSION: boolean;
  46399. HORIZONOCCLUSION: boolean;
  46400. INSTANCES: boolean;
  46401. NUM_BONE_INFLUENCERS: number;
  46402. BonesPerMesh: number;
  46403. BONETEXTURE: boolean;
  46404. NONUNIFORMSCALING: boolean;
  46405. MORPHTARGETS: boolean;
  46406. MORPHTARGETS_NORMAL: boolean;
  46407. MORPHTARGETS_TANGENT: boolean;
  46408. MORPHTARGETS_UV: boolean;
  46409. NUM_MORPH_INFLUENCERS: number;
  46410. IMAGEPROCESSING: boolean;
  46411. VIGNETTE: boolean;
  46412. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46413. VIGNETTEBLENDMODEOPAQUE: boolean;
  46414. TONEMAPPING: boolean;
  46415. TONEMAPPING_ACES: boolean;
  46416. CONTRAST: boolean;
  46417. COLORCURVES: boolean;
  46418. COLORGRADING: boolean;
  46419. COLORGRADING3D: boolean;
  46420. SAMPLER3DGREENDEPTH: boolean;
  46421. SAMPLER3DBGRMAP: boolean;
  46422. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46423. EXPOSURE: boolean;
  46424. MULTIVIEW: boolean;
  46425. USEPHYSICALLIGHTFALLOFF: boolean;
  46426. USEGLTFLIGHTFALLOFF: boolean;
  46427. TWOSIDEDLIGHTING: boolean;
  46428. SHADOWFLOAT: boolean;
  46429. CLIPPLANE: boolean;
  46430. CLIPPLANE2: boolean;
  46431. CLIPPLANE3: boolean;
  46432. CLIPPLANE4: boolean;
  46433. POINTSIZE: boolean;
  46434. FOG: boolean;
  46435. LOGARITHMICDEPTH: boolean;
  46436. FORCENORMALFORWARD: boolean;
  46437. SPECULARAA: boolean;
  46438. CLEARCOAT: boolean;
  46439. CLEARCOAT_DEFAULTIOR: boolean;
  46440. CLEARCOAT_TEXTURE: boolean;
  46441. CLEARCOAT_TEXTUREDIRECTUV: number;
  46442. CLEARCOAT_BUMP: boolean;
  46443. CLEARCOAT_BUMPDIRECTUV: number;
  46444. CLEARCOAT_TINT: boolean;
  46445. CLEARCOAT_TINT_TEXTURE: boolean;
  46446. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46447. ANISOTROPIC: boolean;
  46448. ANISOTROPIC_TEXTURE: boolean;
  46449. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46450. BRDF_V_HEIGHT_CORRELATED: boolean;
  46451. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46452. SHEEN: boolean;
  46453. SHEEN_TEXTURE: boolean;
  46454. SHEEN_TEXTUREDIRECTUV: number;
  46455. SHEEN_LINKWITHALBEDO: boolean;
  46456. SUBSURFACE: boolean;
  46457. SS_REFRACTION: boolean;
  46458. SS_TRANSLUCENCY: boolean;
  46459. SS_SCATERRING: boolean;
  46460. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46461. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46462. SS_REFRACTIONMAP_3D: boolean;
  46463. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46464. SS_LODINREFRACTIONALPHA: boolean;
  46465. SS_GAMMAREFRACTION: boolean;
  46466. SS_RGBDREFRACTION: boolean;
  46467. SS_LINEARSPECULARREFRACTION: boolean;
  46468. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46469. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46470. UNLIT: boolean;
  46471. DEBUGMODE: number;
  46472. /**
  46473. * Initializes the PBR Material defines.
  46474. */
  46475. constructor();
  46476. /**
  46477. * Resets the PBR Material defines.
  46478. */
  46479. reset(): void;
  46480. }
  46481. /**
  46482. * The Physically based material base class of BJS.
  46483. *
  46484. * This offers the main features of a standard PBR material.
  46485. * For more information, please refer to the documentation :
  46486. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46487. */
  46488. export abstract class PBRBaseMaterial extends PushMaterial {
  46489. /**
  46490. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46491. */
  46492. static readonly PBRMATERIAL_OPAQUE: number;
  46493. /**
  46494. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46495. */
  46496. static readonly PBRMATERIAL_ALPHATEST: number;
  46497. /**
  46498. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46499. */
  46500. static readonly PBRMATERIAL_ALPHABLEND: number;
  46501. /**
  46502. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46503. * They are also discarded below the alpha cutoff threshold to improve performances.
  46504. */
  46505. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46506. /**
  46507. * Defines the default value of how much AO map is occluding the analytical lights
  46508. * (point spot...).
  46509. */
  46510. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46511. /**
  46512. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46513. */
  46514. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46515. /**
  46516. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46517. * to enhance interoperability with other engines.
  46518. */
  46519. static readonly LIGHTFALLOFF_GLTF: number;
  46520. /**
  46521. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46522. * to enhance interoperability with other materials.
  46523. */
  46524. static readonly LIGHTFALLOFF_STANDARD: number;
  46525. /**
  46526. * Intensity of the direct lights e.g. the four lights available in your scene.
  46527. * This impacts both the direct diffuse and specular highlights.
  46528. */
  46529. protected _directIntensity: number;
  46530. /**
  46531. * Intensity of the emissive part of the material.
  46532. * This helps controlling the emissive effect without modifying the emissive color.
  46533. */
  46534. protected _emissiveIntensity: number;
  46535. /**
  46536. * Intensity of the environment e.g. how much the environment will light the object
  46537. * either through harmonics for rough material or through the refelction for shiny ones.
  46538. */
  46539. protected _environmentIntensity: number;
  46540. /**
  46541. * This is a special control allowing the reduction of the specular highlights coming from the
  46542. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46543. */
  46544. protected _specularIntensity: number;
  46545. /**
  46546. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46547. */
  46548. private _lightingInfos;
  46549. /**
  46550. * Debug Control allowing disabling the bump map on this material.
  46551. */
  46552. protected _disableBumpMap: boolean;
  46553. /**
  46554. * AKA Diffuse Texture in standard nomenclature.
  46555. */
  46556. protected _albedoTexture: Nullable<BaseTexture>;
  46557. /**
  46558. * AKA Occlusion Texture in other nomenclature.
  46559. */
  46560. protected _ambientTexture: Nullable<BaseTexture>;
  46561. /**
  46562. * AKA Occlusion Texture Intensity in other nomenclature.
  46563. */
  46564. protected _ambientTextureStrength: number;
  46565. /**
  46566. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46567. * 1 means it completely occludes it
  46568. * 0 mean it has no impact
  46569. */
  46570. protected _ambientTextureImpactOnAnalyticalLights: number;
  46571. /**
  46572. * Stores the alpha values in a texture.
  46573. */
  46574. protected _opacityTexture: Nullable<BaseTexture>;
  46575. /**
  46576. * Stores the reflection values in a texture.
  46577. */
  46578. protected _reflectionTexture: Nullable<BaseTexture>;
  46579. /**
  46580. * Stores the emissive values in a texture.
  46581. */
  46582. protected _emissiveTexture: Nullable<BaseTexture>;
  46583. /**
  46584. * AKA Specular texture in other nomenclature.
  46585. */
  46586. protected _reflectivityTexture: Nullable<BaseTexture>;
  46587. /**
  46588. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46589. */
  46590. protected _metallicTexture: Nullable<BaseTexture>;
  46591. /**
  46592. * Specifies the metallic scalar of the metallic/roughness workflow.
  46593. * Can also be used to scale the metalness values of the metallic texture.
  46594. */
  46595. protected _metallic: Nullable<number>;
  46596. /**
  46597. * Specifies the roughness scalar of the metallic/roughness workflow.
  46598. * Can also be used to scale the roughness values of the metallic texture.
  46599. */
  46600. protected _roughness: Nullable<number>;
  46601. /**
  46602. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46603. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46604. */
  46605. protected _microSurfaceTexture: Nullable<BaseTexture>;
  46606. /**
  46607. * Stores surface normal data used to displace a mesh in a texture.
  46608. */
  46609. protected _bumpTexture: Nullable<BaseTexture>;
  46610. /**
  46611. * Stores the pre-calculated light information of a mesh in a texture.
  46612. */
  46613. protected _lightmapTexture: Nullable<BaseTexture>;
  46614. /**
  46615. * The color of a material in ambient lighting.
  46616. */
  46617. protected _ambientColor: Color3;
  46618. /**
  46619. * AKA Diffuse Color in other nomenclature.
  46620. */
  46621. protected _albedoColor: Color3;
  46622. /**
  46623. * AKA Specular Color in other nomenclature.
  46624. */
  46625. protected _reflectivityColor: Color3;
  46626. /**
  46627. * The color applied when light is reflected from a material.
  46628. */
  46629. protected _reflectionColor: Color3;
  46630. /**
  46631. * The color applied when light is emitted from a material.
  46632. */
  46633. protected _emissiveColor: Color3;
  46634. /**
  46635. * AKA Glossiness in other nomenclature.
  46636. */
  46637. protected _microSurface: number;
  46638. /**
  46639. * Specifies that the material will use the light map as a show map.
  46640. */
  46641. protected _useLightmapAsShadowmap: boolean;
  46642. /**
  46643. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46644. * makes the reflect vector face the model (under horizon).
  46645. */
  46646. protected _useHorizonOcclusion: boolean;
  46647. /**
  46648. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46649. * too much the area relying on ambient texture to define their ambient occlusion.
  46650. */
  46651. protected _useRadianceOcclusion: boolean;
  46652. /**
  46653. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46654. */
  46655. protected _useAlphaFromAlbedoTexture: boolean;
  46656. /**
  46657. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  46658. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46659. */
  46660. protected _useSpecularOverAlpha: boolean;
  46661. /**
  46662. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46663. */
  46664. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46665. /**
  46666. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46667. */
  46668. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  46669. /**
  46670. * Specifies if the metallic texture contains the roughness information in its green channel.
  46671. */
  46672. protected _useRoughnessFromMetallicTextureGreen: boolean;
  46673. /**
  46674. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46675. */
  46676. protected _useMetallnessFromMetallicTextureBlue: boolean;
  46677. /**
  46678. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46679. */
  46680. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  46681. /**
  46682. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46683. */
  46684. protected _useAmbientInGrayScale: boolean;
  46685. /**
  46686. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46687. * The material will try to infer what glossiness each pixel should be.
  46688. */
  46689. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  46690. /**
  46691. * Defines the falloff type used in this material.
  46692. * It by default is Physical.
  46693. */
  46694. protected _lightFalloff: number;
  46695. /**
  46696. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46697. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46698. */
  46699. protected _useRadianceOverAlpha: boolean;
  46700. /**
  46701. * Allows using an object space normal map (instead of tangent space).
  46702. */
  46703. protected _useObjectSpaceNormalMap: boolean;
  46704. /**
  46705. * Allows using the bump map in parallax mode.
  46706. */
  46707. protected _useParallax: boolean;
  46708. /**
  46709. * Allows using the bump map in parallax occlusion mode.
  46710. */
  46711. protected _useParallaxOcclusion: boolean;
  46712. /**
  46713. * Controls the scale bias of the parallax mode.
  46714. */
  46715. protected _parallaxScaleBias: number;
  46716. /**
  46717. * If sets to true, disables all the lights affecting the material.
  46718. */
  46719. protected _disableLighting: boolean;
  46720. /**
  46721. * Number of Simultaneous lights allowed on the material.
  46722. */
  46723. protected _maxSimultaneousLights: number;
  46724. /**
  46725. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46726. */
  46727. protected _invertNormalMapX: boolean;
  46728. /**
  46729. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46730. */
  46731. protected _invertNormalMapY: boolean;
  46732. /**
  46733. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46734. */
  46735. protected _twoSidedLighting: boolean;
  46736. /**
  46737. * Defines the alpha limits in alpha test mode.
  46738. */
  46739. protected _alphaCutOff: number;
  46740. /**
  46741. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46742. */
  46743. protected _forceAlphaTest: boolean;
  46744. /**
  46745. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46746. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46747. */
  46748. protected _useAlphaFresnel: boolean;
  46749. /**
  46750. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46751. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46752. */
  46753. protected _useLinearAlphaFresnel: boolean;
  46754. /**
  46755. * The transparency mode of the material.
  46756. */
  46757. protected _transparencyMode: Nullable<number>;
  46758. /**
  46759. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  46760. * from cos thetav and roughness:
  46761. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  46762. */
  46763. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  46764. /**
  46765. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46766. */
  46767. protected _forceIrradianceInFragment: boolean;
  46768. /**
  46769. * Force normal to face away from face.
  46770. */
  46771. protected _forceNormalForward: boolean;
  46772. /**
  46773. * Enables specular anti aliasing in the PBR shader.
  46774. * It will both interacts on the Geometry for analytical and IBL lighting.
  46775. * It also prefilter the roughness map based on the bump values.
  46776. */
  46777. protected _enableSpecularAntiAliasing: boolean;
  46778. /**
  46779. * Default configuration related to image processing available in the PBR Material.
  46780. */
  46781. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46782. /**
  46783. * Keep track of the image processing observer to allow dispose and replace.
  46784. */
  46785. private _imageProcessingObserver;
  46786. /**
  46787. * Attaches a new image processing configuration to the PBR Material.
  46788. * @param configuration
  46789. */
  46790. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46791. /**
  46792. * Stores the available render targets.
  46793. */
  46794. private _renderTargets;
  46795. /**
  46796. * Sets the global ambient color for the material used in lighting calculations.
  46797. */
  46798. private _globalAmbientColor;
  46799. /**
  46800. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46801. */
  46802. private _useLogarithmicDepth;
  46803. /**
  46804. * If set to true, no lighting calculations will be applied.
  46805. */
  46806. private _unlit;
  46807. private _debugMode;
  46808. /**
  46809. * @hidden
  46810. * This is reserved for the inspector.
  46811. * Defines the material debug mode.
  46812. * It helps seeing only some components of the material while troubleshooting.
  46813. */
  46814. debugMode: number;
  46815. /**
  46816. * @hidden
  46817. * This is reserved for the inspector.
  46818. * Specify from where on screen the debug mode should start.
  46819. * The value goes from -1 (full screen) to 1 (not visible)
  46820. * It helps with side by side comparison against the final render
  46821. * This defaults to -1
  46822. */
  46823. private debugLimit;
  46824. /**
  46825. * @hidden
  46826. * This is reserved for the inspector.
  46827. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46828. * You can use the factor to better multiply the final value.
  46829. */
  46830. private debugFactor;
  46831. /**
  46832. * Defines the clear coat layer parameters for the material.
  46833. */
  46834. readonly clearCoat: PBRClearCoatConfiguration;
  46835. /**
  46836. * Defines the anisotropic parameters for the material.
  46837. */
  46838. readonly anisotropy: PBRAnisotropicConfiguration;
  46839. /**
  46840. * Defines the BRDF parameters for the material.
  46841. */
  46842. readonly brdf: PBRBRDFConfiguration;
  46843. /**
  46844. * Defines the Sheen parameters for the material.
  46845. */
  46846. readonly sheen: PBRSheenConfiguration;
  46847. /**
  46848. * Defines the SubSurface parameters for the material.
  46849. */
  46850. readonly subSurface: PBRSubSurfaceConfiguration;
  46851. /**
  46852. * Custom callback helping to override the default shader used in the material.
  46853. */
  46854. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46855. /**
  46856. * Instantiates a new PBRMaterial instance.
  46857. *
  46858. * @param name The material name
  46859. * @param scene The scene the material will be use in.
  46860. */
  46861. constructor(name: string, scene: Scene);
  46862. /**
  46863. * Gets a boolean indicating that current material needs to register RTT
  46864. */
  46865. readonly hasRenderTargetTextures: boolean;
  46866. /**
  46867. * Gets the name of the material class.
  46868. */
  46869. getClassName(): string;
  46870. /**
  46871. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46872. */
  46873. /**
  46874. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46875. */
  46876. useLogarithmicDepth: boolean;
  46877. /**
  46878. * Gets the current transparency mode.
  46879. */
  46880. /**
  46881. * Sets the transparency mode of the material.
  46882. *
  46883. * | Value | Type | Description |
  46884. * | ----- | ----------------------------------- | ----------- |
  46885. * | 0 | OPAQUE | |
  46886. * | 1 | ALPHATEST | |
  46887. * | 2 | ALPHABLEND | |
  46888. * | 3 | ALPHATESTANDBLEND | |
  46889. *
  46890. */
  46891. transparencyMode: Nullable<number>;
  46892. /**
  46893. * Returns true if alpha blending should be disabled.
  46894. */
  46895. private readonly _disableAlphaBlending;
  46896. /**
  46897. * Specifies whether or not this material should be rendered in alpha blend mode.
  46898. */
  46899. needAlphaBlending(): boolean;
  46900. /**
  46901. * Specifies if the mesh will require alpha blending.
  46902. * @param mesh - BJS mesh.
  46903. */
  46904. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46905. /**
  46906. * Specifies whether or not this material should be rendered in alpha test mode.
  46907. */
  46908. needAlphaTesting(): boolean;
  46909. /**
  46910. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46911. */
  46912. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46913. /**
  46914. * Gets the texture used for the alpha test.
  46915. */
  46916. getAlphaTestTexture(): Nullable<BaseTexture>;
  46917. /**
  46918. * Specifies that the submesh is ready to be used.
  46919. * @param mesh - BJS mesh.
  46920. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46921. * @param useInstances - Specifies that instances should be used.
  46922. * @returns - boolean indicating that the submesh is ready or not.
  46923. */
  46924. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46925. /**
  46926. * Specifies if the material uses metallic roughness workflow.
  46927. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46928. */
  46929. isMetallicWorkflow(): boolean;
  46930. private _prepareEffect;
  46931. private _prepareDefines;
  46932. /**
  46933. * Force shader compilation
  46934. */
  46935. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46936. clipPlane: boolean;
  46937. }>): void;
  46938. /**
  46939. * Initializes the uniform buffer layout for the shader.
  46940. */
  46941. buildUniformLayout(): void;
  46942. /**
  46943. * Unbinds the material from the mesh
  46944. */
  46945. unbind(): void;
  46946. /**
  46947. * Binds the submesh data.
  46948. * @param world - The world matrix.
  46949. * @param mesh - The BJS mesh.
  46950. * @param subMesh - A submesh of the BJS mesh.
  46951. */
  46952. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46953. /**
  46954. * Returns the animatable textures.
  46955. * @returns - Array of animatable textures.
  46956. */
  46957. getAnimatables(): IAnimatable[];
  46958. /**
  46959. * Returns the texture used for reflections.
  46960. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46961. */
  46962. private _getReflectionTexture;
  46963. /**
  46964. * Returns an array of the actively used textures.
  46965. * @returns - Array of BaseTextures
  46966. */
  46967. getActiveTextures(): BaseTexture[];
  46968. /**
  46969. * Checks to see if a texture is used in the material.
  46970. * @param texture - Base texture to use.
  46971. * @returns - Boolean specifying if a texture is used in the material.
  46972. */
  46973. hasTexture(texture: BaseTexture): boolean;
  46974. /**
  46975. * Disposes the resources of the material.
  46976. * @param forceDisposeEffect - Forces the disposal of effects.
  46977. * @param forceDisposeTextures - Forces the disposal of all textures.
  46978. */
  46979. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46980. }
  46981. }
  46982. declare module BABYLON {
  46983. /**
  46984. * The Physically based material of BJS.
  46985. *
  46986. * This offers the main features of a standard PBR material.
  46987. * For more information, please refer to the documentation :
  46988. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46989. */
  46990. export class PBRMaterial extends PBRBaseMaterial {
  46991. /**
  46992. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46993. */
  46994. static readonly PBRMATERIAL_OPAQUE: number;
  46995. /**
  46996. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46997. */
  46998. static readonly PBRMATERIAL_ALPHATEST: number;
  46999. /**
  47000. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47001. */
  47002. static readonly PBRMATERIAL_ALPHABLEND: number;
  47003. /**
  47004. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47005. * They are also discarded below the alpha cutoff threshold to improve performances.
  47006. */
  47007. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47008. /**
  47009. * Defines the default value of how much AO map is occluding the analytical lights
  47010. * (point spot...).
  47011. */
  47012. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47013. /**
  47014. * Intensity of the direct lights e.g. the four lights available in your scene.
  47015. * This impacts both the direct diffuse and specular highlights.
  47016. */
  47017. directIntensity: number;
  47018. /**
  47019. * Intensity of the emissive part of the material.
  47020. * This helps controlling the emissive effect without modifying the emissive color.
  47021. */
  47022. emissiveIntensity: number;
  47023. /**
  47024. * Intensity of the environment e.g. how much the environment will light the object
  47025. * either through harmonics for rough material or through the refelction for shiny ones.
  47026. */
  47027. environmentIntensity: number;
  47028. /**
  47029. * This is a special control allowing the reduction of the specular highlights coming from the
  47030. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47031. */
  47032. specularIntensity: number;
  47033. /**
  47034. * Debug Control allowing disabling the bump map on this material.
  47035. */
  47036. disableBumpMap: boolean;
  47037. /**
  47038. * AKA Diffuse Texture in standard nomenclature.
  47039. */
  47040. albedoTexture: BaseTexture;
  47041. /**
  47042. * AKA Occlusion Texture in other nomenclature.
  47043. */
  47044. ambientTexture: BaseTexture;
  47045. /**
  47046. * AKA Occlusion Texture Intensity in other nomenclature.
  47047. */
  47048. ambientTextureStrength: number;
  47049. /**
  47050. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47051. * 1 means it completely occludes it
  47052. * 0 mean it has no impact
  47053. */
  47054. ambientTextureImpactOnAnalyticalLights: number;
  47055. /**
  47056. * Stores the alpha values in a texture.
  47057. */
  47058. opacityTexture: BaseTexture;
  47059. /**
  47060. * Stores the reflection values in a texture.
  47061. */
  47062. reflectionTexture: Nullable<BaseTexture>;
  47063. /**
  47064. * Stores the emissive values in a texture.
  47065. */
  47066. emissiveTexture: BaseTexture;
  47067. /**
  47068. * AKA Specular texture in other nomenclature.
  47069. */
  47070. reflectivityTexture: BaseTexture;
  47071. /**
  47072. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47073. */
  47074. metallicTexture: BaseTexture;
  47075. /**
  47076. * Specifies the metallic scalar of the metallic/roughness workflow.
  47077. * Can also be used to scale the metalness values of the metallic texture.
  47078. */
  47079. metallic: Nullable<number>;
  47080. /**
  47081. * Specifies the roughness scalar of the metallic/roughness workflow.
  47082. * Can also be used to scale the roughness values of the metallic texture.
  47083. */
  47084. roughness: Nullable<number>;
  47085. /**
  47086. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47087. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47088. */
  47089. microSurfaceTexture: BaseTexture;
  47090. /**
  47091. * Stores surface normal data used to displace a mesh in a texture.
  47092. */
  47093. bumpTexture: BaseTexture;
  47094. /**
  47095. * Stores the pre-calculated light information of a mesh in a texture.
  47096. */
  47097. lightmapTexture: BaseTexture;
  47098. /**
  47099. * Stores the refracted light information in a texture.
  47100. */
  47101. refractionTexture: Nullable<BaseTexture>;
  47102. /**
  47103. * The color of a material in ambient lighting.
  47104. */
  47105. ambientColor: Color3;
  47106. /**
  47107. * AKA Diffuse Color in other nomenclature.
  47108. */
  47109. albedoColor: Color3;
  47110. /**
  47111. * AKA Specular Color in other nomenclature.
  47112. */
  47113. reflectivityColor: Color3;
  47114. /**
  47115. * The color reflected from the material.
  47116. */
  47117. reflectionColor: Color3;
  47118. /**
  47119. * The color emitted from the material.
  47120. */
  47121. emissiveColor: Color3;
  47122. /**
  47123. * AKA Glossiness in other nomenclature.
  47124. */
  47125. microSurface: number;
  47126. /**
  47127. * source material index of refraction (IOR)' / 'destination material IOR.
  47128. */
  47129. indexOfRefraction: number;
  47130. /**
  47131. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47132. */
  47133. invertRefractionY: boolean;
  47134. /**
  47135. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47136. * Materials half opaque for instance using refraction could benefit from this control.
  47137. */
  47138. linkRefractionWithTransparency: boolean;
  47139. /**
  47140. * If true, the light map contains occlusion information instead of lighting info.
  47141. */
  47142. useLightmapAsShadowmap: boolean;
  47143. /**
  47144. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47145. */
  47146. useAlphaFromAlbedoTexture: boolean;
  47147. /**
  47148. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47149. */
  47150. forceAlphaTest: boolean;
  47151. /**
  47152. * Defines the alpha limits in alpha test mode.
  47153. */
  47154. alphaCutOff: number;
  47155. /**
  47156. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47157. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47158. */
  47159. useSpecularOverAlpha: boolean;
  47160. /**
  47161. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47162. */
  47163. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47164. /**
  47165. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47166. */
  47167. useRoughnessFromMetallicTextureAlpha: boolean;
  47168. /**
  47169. * Specifies if the metallic texture contains the roughness information in its green channel.
  47170. */
  47171. useRoughnessFromMetallicTextureGreen: boolean;
  47172. /**
  47173. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47174. */
  47175. useMetallnessFromMetallicTextureBlue: boolean;
  47176. /**
  47177. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47178. */
  47179. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47180. /**
  47181. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47182. */
  47183. useAmbientInGrayScale: boolean;
  47184. /**
  47185. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47186. * The material will try to infer what glossiness each pixel should be.
  47187. */
  47188. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47189. /**
  47190. * BJS is using an harcoded light falloff based on a manually sets up range.
  47191. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47192. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47193. */
  47194. /**
  47195. * BJS is using an harcoded light falloff based on a manually sets up range.
  47196. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47197. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47198. */
  47199. usePhysicalLightFalloff: boolean;
  47200. /**
  47201. * In order to support the falloff compatibility with gltf, a special mode has been added
  47202. * to reproduce the gltf light falloff.
  47203. */
  47204. /**
  47205. * In order to support the falloff compatibility with gltf, a special mode has been added
  47206. * to reproduce the gltf light falloff.
  47207. */
  47208. useGLTFLightFalloff: boolean;
  47209. /**
  47210. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47211. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47212. */
  47213. useRadianceOverAlpha: boolean;
  47214. /**
  47215. * Allows using an object space normal map (instead of tangent space).
  47216. */
  47217. useObjectSpaceNormalMap: boolean;
  47218. /**
  47219. * Allows using the bump map in parallax mode.
  47220. */
  47221. useParallax: boolean;
  47222. /**
  47223. * Allows using the bump map in parallax occlusion mode.
  47224. */
  47225. useParallaxOcclusion: boolean;
  47226. /**
  47227. * Controls the scale bias of the parallax mode.
  47228. */
  47229. parallaxScaleBias: number;
  47230. /**
  47231. * If sets to true, disables all the lights affecting the material.
  47232. */
  47233. disableLighting: boolean;
  47234. /**
  47235. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47236. */
  47237. forceIrradianceInFragment: boolean;
  47238. /**
  47239. * Number of Simultaneous lights allowed on the material.
  47240. */
  47241. maxSimultaneousLights: number;
  47242. /**
  47243. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47244. */
  47245. invertNormalMapX: boolean;
  47246. /**
  47247. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47248. */
  47249. invertNormalMapY: boolean;
  47250. /**
  47251. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47252. */
  47253. twoSidedLighting: boolean;
  47254. /**
  47255. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47256. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47257. */
  47258. useAlphaFresnel: boolean;
  47259. /**
  47260. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47261. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47262. */
  47263. useLinearAlphaFresnel: boolean;
  47264. /**
  47265. * Let user defines the brdf lookup texture used for IBL.
  47266. * A default 8bit version is embedded but you could point at :
  47267. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  47268. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47269. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  47270. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47271. */
  47272. environmentBRDFTexture: Nullable<BaseTexture>;
  47273. /**
  47274. * Force normal to face away from face.
  47275. */
  47276. forceNormalForward: boolean;
  47277. /**
  47278. * Enables specular anti aliasing in the PBR shader.
  47279. * It will both interacts on the Geometry for analytical and IBL lighting.
  47280. * It also prefilter the roughness map based on the bump values.
  47281. */
  47282. enableSpecularAntiAliasing: boolean;
  47283. /**
  47284. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47285. * makes the reflect vector face the model (under horizon).
  47286. */
  47287. useHorizonOcclusion: boolean;
  47288. /**
  47289. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47290. * too much the area relying on ambient texture to define their ambient occlusion.
  47291. */
  47292. useRadianceOcclusion: boolean;
  47293. /**
  47294. * If set to true, no lighting calculations will be applied.
  47295. */
  47296. unlit: boolean;
  47297. /**
  47298. * Gets the image processing configuration used either in this material.
  47299. */
  47300. /**
  47301. * Sets the Default image processing configuration used either in the this material.
  47302. *
  47303. * If sets to null, the scene one is in use.
  47304. */
  47305. imageProcessingConfiguration: ImageProcessingConfiguration;
  47306. /**
  47307. * Gets wether the color curves effect is enabled.
  47308. */
  47309. /**
  47310. * Sets wether the color curves effect is enabled.
  47311. */
  47312. cameraColorCurvesEnabled: boolean;
  47313. /**
  47314. * Gets wether the color grading effect is enabled.
  47315. */
  47316. /**
  47317. * Gets wether the color grading effect is enabled.
  47318. */
  47319. cameraColorGradingEnabled: boolean;
  47320. /**
  47321. * Gets wether tonemapping is enabled or not.
  47322. */
  47323. /**
  47324. * Sets wether tonemapping is enabled or not
  47325. */
  47326. cameraToneMappingEnabled: boolean;
  47327. /**
  47328. * The camera exposure used on this material.
  47329. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47330. * This corresponds to a photographic exposure.
  47331. */
  47332. /**
  47333. * The camera exposure used on this material.
  47334. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47335. * This corresponds to a photographic exposure.
  47336. */
  47337. cameraExposure: number;
  47338. /**
  47339. * Gets The camera contrast used on this material.
  47340. */
  47341. /**
  47342. * Sets The camera contrast used on this material.
  47343. */
  47344. cameraContrast: number;
  47345. /**
  47346. * Gets the Color Grading 2D Lookup Texture.
  47347. */
  47348. /**
  47349. * Sets the Color Grading 2D Lookup Texture.
  47350. */
  47351. cameraColorGradingTexture: Nullable<BaseTexture>;
  47352. /**
  47353. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47354. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47355. * 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;
  47356. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47357. */
  47358. /**
  47359. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47360. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47361. * 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;
  47362. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47363. */
  47364. cameraColorCurves: Nullable<ColorCurves>;
  47365. /**
  47366. * Instantiates a new PBRMaterial instance.
  47367. *
  47368. * @param name The material name
  47369. * @param scene The scene the material will be use in.
  47370. */
  47371. constructor(name: string, scene: Scene);
  47372. /**
  47373. * Returns the name of this material class.
  47374. */
  47375. getClassName(): string;
  47376. /**
  47377. * Makes a duplicate of the current material.
  47378. * @param name - name to use for the new material.
  47379. */
  47380. clone(name: string): PBRMaterial;
  47381. /**
  47382. * Serializes this PBR Material.
  47383. * @returns - An object with the serialized material.
  47384. */
  47385. serialize(): any;
  47386. /**
  47387. * Parses a PBR Material from a serialized object.
  47388. * @param source - Serialized object.
  47389. * @param scene - BJS scene instance.
  47390. * @param rootUrl - url for the scene object
  47391. * @returns - PBRMaterial
  47392. */
  47393. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47394. }
  47395. }
  47396. declare module BABYLON {
  47397. /**
  47398. * Direct draw surface info
  47399. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47400. */
  47401. export interface DDSInfo {
  47402. /**
  47403. * Width of the texture
  47404. */
  47405. width: number;
  47406. /**
  47407. * Width of the texture
  47408. */
  47409. height: number;
  47410. /**
  47411. * Number of Mipmaps for the texture
  47412. * @see https://en.wikipedia.org/wiki/Mipmap
  47413. */
  47414. mipmapCount: number;
  47415. /**
  47416. * If the textures format is a known fourCC format
  47417. * @see https://www.fourcc.org/
  47418. */
  47419. isFourCC: boolean;
  47420. /**
  47421. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47422. */
  47423. isRGB: boolean;
  47424. /**
  47425. * If the texture is a lumincance format
  47426. */
  47427. isLuminance: boolean;
  47428. /**
  47429. * If this is a cube texture
  47430. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47431. */
  47432. isCube: boolean;
  47433. /**
  47434. * If the texture is a compressed format eg. FOURCC_DXT1
  47435. */
  47436. isCompressed: boolean;
  47437. /**
  47438. * The dxgiFormat of the texture
  47439. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47440. */
  47441. dxgiFormat: number;
  47442. /**
  47443. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47444. */
  47445. textureType: number;
  47446. /**
  47447. * Sphericle polynomial created for the dds texture
  47448. */
  47449. sphericalPolynomial?: SphericalPolynomial;
  47450. }
  47451. /**
  47452. * Class used to provide DDS decompression tools
  47453. */
  47454. export class DDSTools {
  47455. /**
  47456. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47457. */
  47458. static StoreLODInAlphaChannel: boolean;
  47459. /**
  47460. * Gets DDS information from an array buffer
  47461. * @param arrayBuffer defines the array buffer to read data from
  47462. * @returns the DDS information
  47463. */
  47464. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47465. private static _FloatView;
  47466. private static _Int32View;
  47467. private static _ToHalfFloat;
  47468. private static _FromHalfFloat;
  47469. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47470. private static _GetHalfFloatRGBAArrayBuffer;
  47471. private static _GetFloatRGBAArrayBuffer;
  47472. private static _GetFloatAsUIntRGBAArrayBuffer;
  47473. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47474. private static _GetRGBAArrayBuffer;
  47475. private static _ExtractLongWordOrder;
  47476. private static _GetRGBArrayBuffer;
  47477. private static _GetLuminanceArrayBuffer;
  47478. /**
  47479. * Uploads DDS Levels to a Babylon Texture
  47480. * @hidden
  47481. */
  47482. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47483. }
  47484. interface Engine {
  47485. /**
  47486. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47487. * @param rootUrl defines the url where the file to load is located
  47488. * @param scene defines the current scene
  47489. * @param lodScale defines scale to apply to the mip map selection
  47490. * @param lodOffset defines offset to apply to the mip map selection
  47491. * @param onLoad defines an optional callback raised when the texture is loaded
  47492. * @param onError defines an optional callback raised if there is an issue to load the texture
  47493. * @param format defines the format of the data
  47494. * @param forcedExtension defines the extension to use to pick the right loader
  47495. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47496. * @returns the cube texture as an InternalTexture
  47497. */
  47498. 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;
  47499. }
  47500. }
  47501. declare module BABYLON {
  47502. /**
  47503. * Implementation of the DDS Texture Loader.
  47504. * @hidden
  47505. */
  47506. export class _DDSTextureLoader implements IInternalTextureLoader {
  47507. /**
  47508. * Defines wether the loader supports cascade loading the different faces.
  47509. */
  47510. readonly supportCascades: boolean;
  47511. /**
  47512. * This returns if the loader support the current file information.
  47513. * @param extension defines the file extension of the file being loaded
  47514. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47515. * @param fallback defines the fallback internal texture if any
  47516. * @param isBase64 defines whether the texture is encoded as a base64
  47517. * @param isBuffer defines whether the texture data are stored as a buffer
  47518. * @returns true if the loader can load the specified file
  47519. */
  47520. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47521. /**
  47522. * Transform the url before loading if required.
  47523. * @param rootUrl the url of the texture
  47524. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47525. * @returns the transformed texture
  47526. */
  47527. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47528. /**
  47529. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47530. * @param rootUrl the url of the texture
  47531. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47532. * @returns the fallback texture
  47533. */
  47534. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47535. /**
  47536. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47537. * @param data contains the texture data
  47538. * @param texture defines the BabylonJS internal texture
  47539. * @param createPolynomials will be true if polynomials have been requested
  47540. * @param onLoad defines the callback to trigger once the texture is ready
  47541. * @param onError defines the callback to trigger in case of error
  47542. */
  47543. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47544. /**
  47545. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47546. * @param data contains the texture data
  47547. * @param texture defines the BabylonJS internal texture
  47548. * @param callback defines the method to call once ready to upload
  47549. */
  47550. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47551. }
  47552. }
  47553. declare module BABYLON {
  47554. /** @hidden */
  47555. export var rgbdEncodePixelShader: {
  47556. name: string;
  47557. shader: string;
  47558. };
  47559. }
  47560. declare module BABYLON {
  47561. /**
  47562. * Raw texture data and descriptor sufficient for WebGL texture upload
  47563. */
  47564. export interface EnvironmentTextureInfo {
  47565. /**
  47566. * Version of the environment map
  47567. */
  47568. version: number;
  47569. /**
  47570. * Width of image
  47571. */
  47572. width: number;
  47573. /**
  47574. * Irradiance information stored in the file.
  47575. */
  47576. irradiance: any;
  47577. /**
  47578. * Specular information stored in the file.
  47579. */
  47580. specular: any;
  47581. }
  47582. /**
  47583. * Sets of helpers addressing the serialization and deserialization of environment texture
  47584. * stored in a BabylonJS env file.
  47585. * Those files are usually stored as .env files.
  47586. */
  47587. export class EnvironmentTextureTools {
  47588. /**
  47589. * Magic number identifying the env file.
  47590. */
  47591. private static _MagicBytes;
  47592. /**
  47593. * Gets the environment info from an env file.
  47594. * @param data The array buffer containing the .env bytes.
  47595. * @returns the environment file info (the json header) if successfully parsed.
  47596. */
  47597. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47598. /**
  47599. * Creates an environment texture from a loaded cube texture.
  47600. * @param texture defines the cube texture to convert in env file
  47601. * @return a promise containing the environment data if succesfull.
  47602. */
  47603. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47604. /**
  47605. * Creates a JSON representation of the spherical data.
  47606. * @param texture defines the texture containing the polynomials
  47607. * @return the JSON representation of the spherical info
  47608. */
  47609. private static _CreateEnvTextureIrradiance;
  47610. /**
  47611. * Uploads the texture info contained in the env file to the GPU.
  47612. * @param texture defines the internal texture to upload to
  47613. * @param arrayBuffer defines the buffer cotaining the data to load
  47614. * @param info defines the texture info retrieved through the GetEnvInfo method
  47615. * @returns a promise
  47616. */
  47617. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47618. /**
  47619. * Uploads the levels of image data to the GPU.
  47620. * @param texture defines the internal texture to upload to
  47621. * @param imageData defines the array buffer views of image data [mipmap][face]
  47622. * @returns a promise
  47623. */
  47624. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47625. /**
  47626. * Uploads spherical polynomials information to the texture.
  47627. * @param texture defines the texture we are trying to upload the information to
  47628. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47629. */
  47630. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47631. /** @hidden */
  47632. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47633. }
  47634. }
  47635. declare module BABYLON {
  47636. /**
  47637. * Implementation of the ENV Texture Loader.
  47638. * @hidden
  47639. */
  47640. export class _ENVTextureLoader implements IInternalTextureLoader {
  47641. /**
  47642. * Defines wether the loader supports cascade loading the different faces.
  47643. */
  47644. readonly supportCascades: boolean;
  47645. /**
  47646. * This returns if the loader support the current file information.
  47647. * @param extension defines the file extension of the file being loaded
  47648. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47649. * @param fallback defines the fallback internal texture if any
  47650. * @param isBase64 defines whether the texture is encoded as a base64
  47651. * @param isBuffer defines whether the texture data are stored as a buffer
  47652. * @returns true if the loader can load the specified file
  47653. */
  47654. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47655. /**
  47656. * Transform the url before loading if required.
  47657. * @param rootUrl the url of the texture
  47658. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47659. * @returns the transformed texture
  47660. */
  47661. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47662. /**
  47663. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47664. * @param rootUrl the url of the texture
  47665. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47666. * @returns the fallback texture
  47667. */
  47668. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47669. /**
  47670. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47671. * @param data contains the texture data
  47672. * @param texture defines the BabylonJS internal texture
  47673. * @param createPolynomials will be true if polynomials have been requested
  47674. * @param onLoad defines the callback to trigger once the texture is ready
  47675. * @param onError defines the callback to trigger in case of error
  47676. */
  47677. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47678. /**
  47679. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47680. * @param data contains the texture data
  47681. * @param texture defines the BabylonJS internal texture
  47682. * @param callback defines the method to call once ready to upload
  47683. */
  47684. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47685. }
  47686. }
  47687. declare module BABYLON {
  47688. /**
  47689. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47690. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47691. */
  47692. export class KhronosTextureContainer {
  47693. /** contents of the KTX container file */
  47694. arrayBuffer: any;
  47695. private static HEADER_LEN;
  47696. private static COMPRESSED_2D;
  47697. private static COMPRESSED_3D;
  47698. private static TEX_2D;
  47699. private static TEX_3D;
  47700. /**
  47701. * Gets the openGL type
  47702. */
  47703. glType: number;
  47704. /**
  47705. * Gets the openGL type size
  47706. */
  47707. glTypeSize: number;
  47708. /**
  47709. * Gets the openGL format
  47710. */
  47711. glFormat: number;
  47712. /**
  47713. * Gets the openGL internal format
  47714. */
  47715. glInternalFormat: number;
  47716. /**
  47717. * Gets the base internal format
  47718. */
  47719. glBaseInternalFormat: number;
  47720. /**
  47721. * Gets image width in pixel
  47722. */
  47723. pixelWidth: number;
  47724. /**
  47725. * Gets image height in pixel
  47726. */
  47727. pixelHeight: number;
  47728. /**
  47729. * Gets image depth in pixels
  47730. */
  47731. pixelDepth: number;
  47732. /**
  47733. * Gets the number of array elements
  47734. */
  47735. numberOfArrayElements: number;
  47736. /**
  47737. * Gets the number of faces
  47738. */
  47739. numberOfFaces: number;
  47740. /**
  47741. * Gets the number of mipmap levels
  47742. */
  47743. numberOfMipmapLevels: number;
  47744. /**
  47745. * Gets the bytes of key value data
  47746. */
  47747. bytesOfKeyValueData: number;
  47748. /**
  47749. * Gets the load type
  47750. */
  47751. loadType: number;
  47752. /**
  47753. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47754. */
  47755. isInvalid: boolean;
  47756. /**
  47757. * Creates a new KhronosTextureContainer
  47758. * @param arrayBuffer contents of the KTX container file
  47759. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47760. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47761. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47762. */
  47763. constructor(
  47764. /** contents of the KTX container file */
  47765. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47766. /**
  47767. * Uploads KTX content to a Babylon Texture.
  47768. * It is assumed that the texture has already been created & is currently bound
  47769. * @hidden
  47770. */
  47771. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47772. private _upload2DCompressedLevels;
  47773. }
  47774. }
  47775. declare module BABYLON {
  47776. /**
  47777. * Implementation of the KTX Texture Loader.
  47778. * @hidden
  47779. */
  47780. export class _KTXTextureLoader implements IInternalTextureLoader {
  47781. /**
  47782. * Defines wether the loader supports cascade loading the different faces.
  47783. */
  47784. readonly supportCascades: boolean;
  47785. /**
  47786. * This returns if the loader support the current file information.
  47787. * @param extension defines the file extension of the file being loaded
  47788. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47789. * @param fallback defines the fallback internal texture if any
  47790. * @param isBase64 defines whether the texture is encoded as a base64
  47791. * @param isBuffer defines whether the texture data are stored as a buffer
  47792. * @returns true if the loader can load the specified file
  47793. */
  47794. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47795. /**
  47796. * Transform the url before loading if required.
  47797. * @param rootUrl the url of the texture
  47798. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47799. * @returns the transformed texture
  47800. */
  47801. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47802. /**
  47803. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47804. * @param rootUrl the url of the texture
  47805. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47806. * @returns the fallback texture
  47807. */
  47808. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47809. /**
  47810. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47811. * @param data contains the texture data
  47812. * @param texture defines the BabylonJS internal texture
  47813. * @param createPolynomials will be true if polynomials have been requested
  47814. * @param onLoad defines the callback to trigger once the texture is ready
  47815. * @param onError defines the callback to trigger in case of error
  47816. */
  47817. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47818. /**
  47819. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47820. * @param data contains the texture data
  47821. * @param texture defines the BabylonJS internal texture
  47822. * @param callback defines the method to call once ready to upload
  47823. */
  47824. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47825. }
  47826. }
  47827. declare module BABYLON {
  47828. /**
  47829. * Options for the default xr helper
  47830. */
  47831. export class WebXRDefaultExperienceOptions {
  47832. /**
  47833. * Floor meshes that should be used for teleporting
  47834. */
  47835. floorMeshes: Array<AbstractMesh>;
  47836. }
  47837. /**
  47838. * Default experience which provides a similar setup to the previous webVRExperience
  47839. */
  47840. export class WebXRDefaultExperience {
  47841. /**
  47842. * Base experience
  47843. */
  47844. baseExperience: WebXRExperienceHelper;
  47845. /**
  47846. * Input experience extension
  47847. */
  47848. input: WebXRInput;
  47849. /**
  47850. * Loads the controller models
  47851. */
  47852. controllerModelLoader: WebXRControllerModelLoader;
  47853. /**
  47854. * Enables laser pointer and selection
  47855. */
  47856. pointerSelection: WebXRControllerPointerSelection;
  47857. /**
  47858. * Enables teleportation
  47859. */
  47860. teleportation: WebXRControllerTeleportation;
  47861. /**
  47862. * Enables ui for enetering/exiting xr
  47863. */
  47864. enterExitUI: WebXREnterExitUI;
  47865. /**
  47866. * Default output canvas xr should render to
  47867. */
  47868. outputCanvas: WebXRManagedOutputCanvas;
  47869. /**
  47870. * Creates the default xr experience
  47871. * @param scene scene
  47872. * @param options options for basic configuration
  47873. * @returns resulting WebXRDefaultExperience
  47874. */
  47875. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47876. private constructor();
  47877. /**
  47878. * DIsposes of the experience helper
  47879. */
  47880. dispose(): void;
  47881. }
  47882. }
  47883. declare module BABYLON {
  47884. /** @hidden */
  47885. export var _forceSceneHelpersToBundle: boolean;
  47886. interface Scene {
  47887. /**
  47888. * Creates a default light for the scene.
  47889. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47890. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47891. */
  47892. createDefaultLight(replace?: boolean): void;
  47893. /**
  47894. * Creates a default camera for the scene.
  47895. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47896. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47897. * @param replace has default false, when true replaces the active camera in the scene
  47898. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47899. */
  47900. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47901. /**
  47902. * Creates a default camera and a default light.
  47903. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47904. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47905. * @param replace has the default false, when true replaces the active camera/light in the scene
  47906. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47907. */
  47908. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47909. /**
  47910. * Creates a new sky box
  47911. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47912. * @param environmentTexture defines the texture to use as environment texture
  47913. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47914. * @param scale defines the overall scale of the skybox
  47915. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47916. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47917. * @returns a new mesh holding the sky box
  47918. */
  47919. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47920. /**
  47921. * Creates a new environment
  47922. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47923. * @param options defines the options you can use to configure the environment
  47924. * @returns the new EnvironmentHelper
  47925. */
  47926. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47927. /**
  47928. * Creates a new VREXperienceHelper
  47929. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47930. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47931. * @returns a new VREXperienceHelper
  47932. */
  47933. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47934. /**
  47935. * Creates a new WebXRDefaultExperience
  47936. * @see http://doc.babylonjs.com/how_to/webxr
  47937. * @param options experience options
  47938. * @returns a promise for a new WebXRDefaultExperience
  47939. */
  47940. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47941. }
  47942. }
  47943. declare module BABYLON {
  47944. /**
  47945. * Contains position and normal vectors for a vertex
  47946. */
  47947. export class PositionNormalVertex {
  47948. /** the position of the vertex (defaut: 0,0,0) */
  47949. position: Vector3;
  47950. /** the normal of the vertex (defaut: 0,1,0) */
  47951. normal: Vector3;
  47952. /**
  47953. * Creates a PositionNormalVertex
  47954. * @param position the position of the vertex (defaut: 0,0,0)
  47955. * @param normal the normal of the vertex (defaut: 0,1,0)
  47956. */
  47957. constructor(
  47958. /** the position of the vertex (defaut: 0,0,0) */
  47959. position?: Vector3,
  47960. /** the normal of the vertex (defaut: 0,1,0) */
  47961. normal?: Vector3);
  47962. /**
  47963. * Clones the PositionNormalVertex
  47964. * @returns the cloned PositionNormalVertex
  47965. */
  47966. clone(): PositionNormalVertex;
  47967. }
  47968. /**
  47969. * Contains position, normal and uv vectors for a vertex
  47970. */
  47971. export class PositionNormalTextureVertex {
  47972. /** the position of the vertex (defaut: 0,0,0) */
  47973. position: Vector3;
  47974. /** the normal of the vertex (defaut: 0,1,0) */
  47975. normal: Vector3;
  47976. /** the uv of the vertex (default: 0,0) */
  47977. uv: Vector2;
  47978. /**
  47979. * Creates a PositionNormalTextureVertex
  47980. * @param position the position of the vertex (defaut: 0,0,0)
  47981. * @param normal the normal of the vertex (defaut: 0,1,0)
  47982. * @param uv the uv of the vertex (default: 0,0)
  47983. */
  47984. constructor(
  47985. /** the position of the vertex (defaut: 0,0,0) */
  47986. position?: Vector3,
  47987. /** the normal of the vertex (defaut: 0,1,0) */
  47988. normal?: Vector3,
  47989. /** the uv of the vertex (default: 0,0) */
  47990. uv?: Vector2);
  47991. /**
  47992. * Clones the PositionNormalTextureVertex
  47993. * @returns the cloned PositionNormalTextureVertex
  47994. */
  47995. clone(): PositionNormalTextureVertex;
  47996. }
  47997. }
  47998. declare module BABYLON {
  47999. /**
  48000. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48001. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48002. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48003. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48004. */
  48005. export class VideoDome extends TransformNode {
  48006. /**
  48007. * Define the video source as a Monoscopic panoramic 360 video.
  48008. */
  48009. static readonly MODE_MONOSCOPIC: number;
  48010. /**
  48011. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48012. */
  48013. static readonly MODE_TOPBOTTOM: number;
  48014. /**
  48015. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48016. */
  48017. static readonly MODE_SIDEBYSIDE: number;
  48018. private _halfDome;
  48019. private _useDirectMapping;
  48020. /**
  48021. * The video texture being displayed on the sphere
  48022. */
  48023. protected _videoTexture: VideoTexture;
  48024. /**
  48025. * Gets the video texture being displayed on the sphere
  48026. */
  48027. readonly videoTexture: VideoTexture;
  48028. /**
  48029. * The skybox material
  48030. */
  48031. protected _material: BackgroundMaterial;
  48032. /**
  48033. * The surface used for the skybox
  48034. */
  48035. protected _mesh: Mesh;
  48036. /**
  48037. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  48038. */
  48039. private _halfDomeMask;
  48040. /**
  48041. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48042. * Also see the options.resolution property.
  48043. */
  48044. fovMultiplier: number;
  48045. private _videoMode;
  48046. /**
  48047. * Gets or set the current video mode for the video. It can be:
  48048. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48049. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48050. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48051. */
  48052. videoMode: number;
  48053. /**
  48054. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  48055. *
  48056. */
  48057. /**
  48058. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  48059. */
  48060. halfDome: boolean;
  48061. /**
  48062. * Oberserver used in Stereoscopic VR Mode.
  48063. */
  48064. private _onBeforeCameraRenderObserver;
  48065. /**
  48066. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48067. * @param name Element's name, child elements will append suffixes for their own names.
  48068. * @param urlsOrVideo defines the url(s) or the video element to use
  48069. * @param options An object containing optional or exposed sub element properties
  48070. */
  48071. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48072. resolution?: number;
  48073. clickToPlay?: boolean;
  48074. autoPlay?: boolean;
  48075. loop?: boolean;
  48076. size?: number;
  48077. poster?: string;
  48078. faceForward?: boolean;
  48079. useDirectMapping?: boolean;
  48080. halfDomeMode?: boolean;
  48081. }, scene: Scene);
  48082. private _changeVideoMode;
  48083. /**
  48084. * Releases resources associated with this node.
  48085. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48086. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48087. */
  48088. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48089. }
  48090. }
  48091. declare module BABYLON {
  48092. /**
  48093. * This class can be used to get instrumentation data from a Babylon engine
  48094. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48095. */
  48096. export class EngineInstrumentation implements IDisposable {
  48097. /**
  48098. * Define the instrumented engine.
  48099. */
  48100. engine: Engine;
  48101. private _captureGPUFrameTime;
  48102. private _gpuFrameTimeToken;
  48103. private _gpuFrameTime;
  48104. private _captureShaderCompilationTime;
  48105. private _shaderCompilationTime;
  48106. private _onBeginFrameObserver;
  48107. private _onEndFrameObserver;
  48108. private _onBeforeShaderCompilationObserver;
  48109. private _onAfterShaderCompilationObserver;
  48110. /**
  48111. * Gets the perf counter used for GPU frame time
  48112. */
  48113. readonly gpuFrameTimeCounter: PerfCounter;
  48114. /**
  48115. * Gets the GPU frame time capture status
  48116. */
  48117. /**
  48118. * Enable or disable the GPU frame time capture
  48119. */
  48120. captureGPUFrameTime: boolean;
  48121. /**
  48122. * Gets the perf counter used for shader compilation time
  48123. */
  48124. readonly shaderCompilationTimeCounter: PerfCounter;
  48125. /**
  48126. * Gets the shader compilation time capture status
  48127. */
  48128. /**
  48129. * Enable or disable the shader compilation time capture
  48130. */
  48131. captureShaderCompilationTime: boolean;
  48132. /**
  48133. * Instantiates a new engine instrumentation.
  48134. * This class can be used to get instrumentation data from a Babylon engine
  48135. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48136. * @param engine Defines the engine to instrument
  48137. */
  48138. constructor(
  48139. /**
  48140. * Define the instrumented engine.
  48141. */
  48142. engine: Engine);
  48143. /**
  48144. * Dispose and release associated resources.
  48145. */
  48146. dispose(): void;
  48147. }
  48148. }
  48149. declare module BABYLON {
  48150. /**
  48151. * This class can be used to get instrumentation data from a Babylon engine
  48152. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48153. */
  48154. export class SceneInstrumentation implements IDisposable {
  48155. /**
  48156. * Defines the scene to instrument
  48157. */
  48158. scene: Scene;
  48159. private _captureActiveMeshesEvaluationTime;
  48160. private _activeMeshesEvaluationTime;
  48161. private _captureRenderTargetsRenderTime;
  48162. private _renderTargetsRenderTime;
  48163. private _captureFrameTime;
  48164. private _frameTime;
  48165. private _captureRenderTime;
  48166. private _renderTime;
  48167. private _captureInterFrameTime;
  48168. private _interFrameTime;
  48169. private _captureParticlesRenderTime;
  48170. private _particlesRenderTime;
  48171. private _captureSpritesRenderTime;
  48172. private _spritesRenderTime;
  48173. private _capturePhysicsTime;
  48174. private _physicsTime;
  48175. private _captureAnimationsTime;
  48176. private _animationsTime;
  48177. private _captureCameraRenderTime;
  48178. private _cameraRenderTime;
  48179. private _onBeforeActiveMeshesEvaluationObserver;
  48180. private _onAfterActiveMeshesEvaluationObserver;
  48181. private _onBeforeRenderTargetsRenderObserver;
  48182. private _onAfterRenderTargetsRenderObserver;
  48183. private _onAfterRenderObserver;
  48184. private _onBeforeDrawPhaseObserver;
  48185. private _onAfterDrawPhaseObserver;
  48186. private _onBeforeAnimationsObserver;
  48187. private _onBeforeParticlesRenderingObserver;
  48188. private _onAfterParticlesRenderingObserver;
  48189. private _onBeforeSpritesRenderingObserver;
  48190. private _onAfterSpritesRenderingObserver;
  48191. private _onBeforePhysicsObserver;
  48192. private _onAfterPhysicsObserver;
  48193. private _onAfterAnimationsObserver;
  48194. private _onBeforeCameraRenderObserver;
  48195. private _onAfterCameraRenderObserver;
  48196. /**
  48197. * Gets the perf counter used for active meshes evaluation time
  48198. */
  48199. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48200. /**
  48201. * Gets the active meshes evaluation time capture status
  48202. */
  48203. /**
  48204. * Enable or disable the active meshes evaluation time capture
  48205. */
  48206. captureActiveMeshesEvaluationTime: boolean;
  48207. /**
  48208. * Gets the perf counter used for render targets render time
  48209. */
  48210. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48211. /**
  48212. * Gets the render targets render time capture status
  48213. */
  48214. /**
  48215. * Enable or disable the render targets render time capture
  48216. */
  48217. captureRenderTargetsRenderTime: boolean;
  48218. /**
  48219. * Gets the perf counter used for particles render time
  48220. */
  48221. readonly particlesRenderTimeCounter: PerfCounter;
  48222. /**
  48223. * Gets the particles render time capture status
  48224. */
  48225. /**
  48226. * Enable or disable the particles render time capture
  48227. */
  48228. captureParticlesRenderTime: boolean;
  48229. /**
  48230. * Gets the perf counter used for sprites render time
  48231. */
  48232. readonly spritesRenderTimeCounter: PerfCounter;
  48233. /**
  48234. * Gets the sprites render time capture status
  48235. */
  48236. /**
  48237. * Enable or disable the sprites render time capture
  48238. */
  48239. captureSpritesRenderTime: boolean;
  48240. /**
  48241. * Gets the perf counter used for physics time
  48242. */
  48243. readonly physicsTimeCounter: PerfCounter;
  48244. /**
  48245. * Gets the physics time capture status
  48246. */
  48247. /**
  48248. * Enable or disable the physics time capture
  48249. */
  48250. capturePhysicsTime: boolean;
  48251. /**
  48252. * Gets the perf counter used for animations time
  48253. */
  48254. readonly animationsTimeCounter: PerfCounter;
  48255. /**
  48256. * Gets the animations time capture status
  48257. */
  48258. /**
  48259. * Enable or disable the animations time capture
  48260. */
  48261. captureAnimationsTime: boolean;
  48262. /**
  48263. * Gets the perf counter used for frame time capture
  48264. */
  48265. readonly frameTimeCounter: PerfCounter;
  48266. /**
  48267. * Gets the frame time capture status
  48268. */
  48269. /**
  48270. * Enable or disable the frame time capture
  48271. */
  48272. captureFrameTime: boolean;
  48273. /**
  48274. * Gets the perf counter used for inter-frames time capture
  48275. */
  48276. readonly interFrameTimeCounter: PerfCounter;
  48277. /**
  48278. * Gets the inter-frames time capture status
  48279. */
  48280. /**
  48281. * Enable or disable the inter-frames time capture
  48282. */
  48283. captureInterFrameTime: boolean;
  48284. /**
  48285. * Gets the perf counter used for render time capture
  48286. */
  48287. readonly renderTimeCounter: PerfCounter;
  48288. /**
  48289. * Gets the render time capture status
  48290. */
  48291. /**
  48292. * Enable or disable the render time capture
  48293. */
  48294. captureRenderTime: boolean;
  48295. /**
  48296. * Gets the perf counter used for camera render time capture
  48297. */
  48298. readonly cameraRenderTimeCounter: PerfCounter;
  48299. /**
  48300. * Gets the camera render time capture status
  48301. */
  48302. /**
  48303. * Enable or disable the camera render time capture
  48304. */
  48305. captureCameraRenderTime: boolean;
  48306. /**
  48307. * Gets the perf counter used for draw calls
  48308. */
  48309. readonly drawCallsCounter: PerfCounter;
  48310. /**
  48311. * Instantiates a new scene instrumentation.
  48312. * This class can be used to get instrumentation data from a Babylon engine
  48313. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48314. * @param scene Defines the scene to instrument
  48315. */
  48316. constructor(
  48317. /**
  48318. * Defines the scene to instrument
  48319. */
  48320. scene: Scene);
  48321. /**
  48322. * Dispose and release associated resources.
  48323. */
  48324. dispose(): void;
  48325. }
  48326. }
  48327. declare module BABYLON {
  48328. /** @hidden */
  48329. export var glowMapGenerationPixelShader: {
  48330. name: string;
  48331. shader: string;
  48332. };
  48333. }
  48334. declare module BABYLON {
  48335. /** @hidden */
  48336. export var glowMapGenerationVertexShader: {
  48337. name: string;
  48338. shader: string;
  48339. };
  48340. }
  48341. declare module BABYLON {
  48342. /**
  48343. * Effect layer options. This helps customizing the behaviour
  48344. * of the effect layer.
  48345. */
  48346. export interface IEffectLayerOptions {
  48347. /**
  48348. * Multiplication factor apply to the canvas size to compute the render target size
  48349. * used to generated the objects (the smaller the faster).
  48350. */
  48351. mainTextureRatio: number;
  48352. /**
  48353. * Enforces a fixed size texture to ensure effect stability across devices.
  48354. */
  48355. mainTextureFixedSize?: number;
  48356. /**
  48357. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48358. */
  48359. alphaBlendingMode: number;
  48360. /**
  48361. * The camera attached to the layer.
  48362. */
  48363. camera: Nullable<Camera>;
  48364. /**
  48365. * The rendering group to draw the layer in.
  48366. */
  48367. renderingGroupId: number;
  48368. }
  48369. /**
  48370. * The effect layer Helps adding post process effect blended with the main pass.
  48371. *
  48372. * This can be for instance use to generate glow or higlight effects on the scene.
  48373. *
  48374. * The effect layer class can not be used directly and is intented to inherited from to be
  48375. * customized per effects.
  48376. */
  48377. export abstract class EffectLayer {
  48378. private _vertexBuffers;
  48379. private _indexBuffer;
  48380. private _cachedDefines;
  48381. private _effectLayerMapGenerationEffect;
  48382. private _effectLayerOptions;
  48383. private _mergeEffect;
  48384. protected _scene: Scene;
  48385. protected _engine: Engine;
  48386. protected _maxSize: number;
  48387. protected _mainTextureDesiredSize: ISize;
  48388. protected _mainTexture: RenderTargetTexture;
  48389. protected _shouldRender: boolean;
  48390. protected _postProcesses: PostProcess[];
  48391. protected _textures: BaseTexture[];
  48392. protected _emissiveTextureAndColor: {
  48393. texture: Nullable<BaseTexture>;
  48394. color: Color4;
  48395. };
  48396. /**
  48397. * The name of the layer
  48398. */
  48399. name: string;
  48400. /**
  48401. * The clear color of the texture used to generate the glow map.
  48402. */
  48403. neutralColor: Color4;
  48404. /**
  48405. * Specifies wether the highlight layer is enabled or not.
  48406. */
  48407. isEnabled: boolean;
  48408. /**
  48409. * Gets the camera attached to the layer.
  48410. */
  48411. readonly camera: Nullable<Camera>;
  48412. /**
  48413. * Gets the rendering group id the layer should render in.
  48414. */
  48415. renderingGroupId: number;
  48416. /**
  48417. * An event triggered when the effect layer has been disposed.
  48418. */
  48419. onDisposeObservable: Observable<EffectLayer>;
  48420. /**
  48421. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48422. */
  48423. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48424. /**
  48425. * An event triggered when the generated texture is being merged in the scene.
  48426. */
  48427. onBeforeComposeObservable: Observable<EffectLayer>;
  48428. /**
  48429. * An event triggered when the generated texture has been merged in the scene.
  48430. */
  48431. onAfterComposeObservable: Observable<EffectLayer>;
  48432. /**
  48433. * An event triggered when the efffect layer changes its size.
  48434. */
  48435. onSizeChangedObservable: Observable<EffectLayer>;
  48436. /** @hidden */
  48437. static _SceneComponentInitialization: (scene: Scene) => void;
  48438. /**
  48439. * Instantiates a new effect Layer and references it in the scene.
  48440. * @param name The name of the layer
  48441. * @param scene The scene to use the layer in
  48442. */
  48443. constructor(
  48444. /** The Friendly of the effect in the scene */
  48445. name: string, scene: Scene);
  48446. /**
  48447. * Get the effect name of the layer.
  48448. * @return The effect name
  48449. */
  48450. abstract getEffectName(): string;
  48451. /**
  48452. * Checks for the readiness of the element composing the layer.
  48453. * @param subMesh the mesh to check for
  48454. * @param useInstances specify wether or not to use instances to render the mesh
  48455. * @return true if ready otherwise, false
  48456. */
  48457. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48458. /**
  48459. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48460. * @returns true if the effect requires stencil during the main canvas render pass.
  48461. */
  48462. abstract needStencil(): boolean;
  48463. /**
  48464. * Create the merge effect. This is the shader use to blit the information back
  48465. * to the main canvas at the end of the scene rendering.
  48466. * @returns The effect containing the shader used to merge the effect on the main canvas
  48467. */
  48468. protected abstract _createMergeEffect(): Effect;
  48469. /**
  48470. * Creates the render target textures and post processes used in the effect layer.
  48471. */
  48472. protected abstract _createTextureAndPostProcesses(): void;
  48473. /**
  48474. * Implementation specific of rendering the generating effect on the main canvas.
  48475. * @param effect The effect used to render through
  48476. */
  48477. protected abstract _internalRender(effect: Effect): void;
  48478. /**
  48479. * Sets the required values for both the emissive texture and and the main color.
  48480. */
  48481. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48482. /**
  48483. * Free any resources and references associated to a mesh.
  48484. * Internal use
  48485. * @param mesh The mesh to free.
  48486. */
  48487. abstract _disposeMesh(mesh: Mesh): void;
  48488. /**
  48489. * Serializes this layer (Glow or Highlight for example)
  48490. * @returns a serialized layer object
  48491. */
  48492. abstract serialize?(): any;
  48493. /**
  48494. * Initializes the effect layer with the required options.
  48495. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48496. */
  48497. protected _init(options: Partial<IEffectLayerOptions>): void;
  48498. /**
  48499. * Generates the index buffer of the full screen quad blending to the main canvas.
  48500. */
  48501. private _generateIndexBuffer;
  48502. /**
  48503. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48504. */
  48505. private _generateVertexBuffer;
  48506. /**
  48507. * Sets the main texture desired size which is the closest power of two
  48508. * of the engine canvas size.
  48509. */
  48510. private _setMainTextureSize;
  48511. /**
  48512. * Creates the main texture for the effect layer.
  48513. */
  48514. protected _createMainTexture(): void;
  48515. /**
  48516. * Adds specific effects defines.
  48517. * @param defines The defines to add specifics to.
  48518. */
  48519. protected _addCustomEffectDefines(defines: string[]): void;
  48520. /**
  48521. * Checks for the readiness of the element composing the layer.
  48522. * @param subMesh the mesh to check for
  48523. * @param useInstances specify wether or not to use instances to render the mesh
  48524. * @param emissiveTexture the associated emissive texture used to generate the glow
  48525. * @return true if ready otherwise, false
  48526. */
  48527. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48528. /**
  48529. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48530. */
  48531. render(): void;
  48532. /**
  48533. * Determine if a given mesh will be used in the current effect.
  48534. * @param mesh mesh to test
  48535. * @returns true if the mesh will be used
  48536. */
  48537. hasMesh(mesh: AbstractMesh): boolean;
  48538. /**
  48539. * Returns true if the layer contains information to display, otherwise false.
  48540. * @returns true if the glow layer should be rendered
  48541. */
  48542. shouldRender(): boolean;
  48543. /**
  48544. * Returns true if the mesh should render, otherwise false.
  48545. * @param mesh The mesh to render
  48546. * @returns true if it should render otherwise false
  48547. */
  48548. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48549. /**
  48550. * Returns true if the mesh can be rendered, otherwise false.
  48551. * @param mesh The mesh to render
  48552. * @param material The material used on the mesh
  48553. * @returns true if it can be rendered otherwise false
  48554. */
  48555. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48556. /**
  48557. * Returns true if the mesh should render, otherwise false.
  48558. * @param mesh The mesh to render
  48559. * @returns true if it should render otherwise false
  48560. */
  48561. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48562. /**
  48563. * Renders the submesh passed in parameter to the generation map.
  48564. */
  48565. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  48566. /**
  48567. * Rebuild the required buffers.
  48568. * @hidden Internal use only.
  48569. */
  48570. _rebuild(): void;
  48571. /**
  48572. * Dispose only the render target textures and post process.
  48573. */
  48574. private _disposeTextureAndPostProcesses;
  48575. /**
  48576. * Dispose the highlight layer and free resources.
  48577. */
  48578. dispose(): void;
  48579. /**
  48580. * Gets the class name of the effect layer
  48581. * @returns the string with the class name of the effect layer
  48582. */
  48583. getClassName(): string;
  48584. /**
  48585. * Creates an effect layer from parsed effect layer data
  48586. * @param parsedEffectLayer defines effect layer data
  48587. * @param scene defines the current scene
  48588. * @param rootUrl defines the root URL containing the effect layer information
  48589. * @returns a parsed effect Layer
  48590. */
  48591. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48592. }
  48593. }
  48594. declare module BABYLON {
  48595. interface AbstractScene {
  48596. /**
  48597. * The list of effect layers (highlights/glow) added to the scene
  48598. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48599. * @see http://doc.babylonjs.com/how_to/glow_layer
  48600. */
  48601. effectLayers: Array<EffectLayer>;
  48602. /**
  48603. * Removes the given effect layer from this scene.
  48604. * @param toRemove defines the effect layer to remove
  48605. * @returns the index of the removed effect layer
  48606. */
  48607. removeEffectLayer(toRemove: EffectLayer): number;
  48608. /**
  48609. * Adds the given effect layer to this scene
  48610. * @param newEffectLayer defines the effect layer to add
  48611. */
  48612. addEffectLayer(newEffectLayer: EffectLayer): void;
  48613. }
  48614. /**
  48615. * Defines the layer scene component responsible to manage any effect layers
  48616. * in a given scene.
  48617. */
  48618. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48619. /**
  48620. * The component name helpfull to identify the component in the list of scene components.
  48621. */
  48622. readonly name: string;
  48623. /**
  48624. * The scene the component belongs to.
  48625. */
  48626. scene: Scene;
  48627. private _engine;
  48628. private _renderEffects;
  48629. private _needStencil;
  48630. private _previousStencilState;
  48631. /**
  48632. * Creates a new instance of the component for the given scene
  48633. * @param scene Defines the scene to register the component in
  48634. */
  48635. constructor(scene: Scene);
  48636. /**
  48637. * Registers the component in a given scene
  48638. */
  48639. register(): void;
  48640. /**
  48641. * Rebuilds the elements related to this component in case of
  48642. * context lost for instance.
  48643. */
  48644. rebuild(): void;
  48645. /**
  48646. * Serializes the component data to the specified json object
  48647. * @param serializationObject The object to serialize to
  48648. */
  48649. serialize(serializationObject: any): void;
  48650. /**
  48651. * Adds all the elements from the container to the scene
  48652. * @param container the container holding the elements
  48653. */
  48654. addFromContainer(container: AbstractScene): void;
  48655. /**
  48656. * Removes all the elements in the container from the scene
  48657. * @param container contains the elements to remove
  48658. * @param dispose if the removed element should be disposed (default: false)
  48659. */
  48660. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48661. /**
  48662. * Disposes the component and the associated ressources.
  48663. */
  48664. dispose(): void;
  48665. private _isReadyForMesh;
  48666. private _renderMainTexture;
  48667. private _setStencil;
  48668. private _setStencilBack;
  48669. private _draw;
  48670. private _drawCamera;
  48671. private _drawRenderingGroup;
  48672. }
  48673. }
  48674. declare module BABYLON {
  48675. /** @hidden */
  48676. export var glowMapMergePixelShader: {
  48677. name: string;
  48678. shader: string;
  48679. };
  48680. }
  48681. declare module BABYLON {
  48682. /** @hidden */
  48683. export var glowMapMergeVertexShader: {
  48684. name: string;
  48685. shader: string;
  48686. };
  48687. }
  48688. declare module BABYLON {
  48689. interface AbstractScene {
  48690. /**
  48691. * Return a the first highlight layer of the scene with a given name.
  48692. * @param name The name of the highlight layer to look for.
  48693. * @return The highlight layer if found otherwise null.
  48694. */
  48695. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  48696. }
  48697. /**
  48698. * Glow layer options. This helps customizing the behaviour
  48699. * of the glow layer.
  48700. */
  48701. export interface IGlowLayerOptions {
  48702. /**
  48703. * Multiplication factor apply to the canvas size to compute the render target size
  48704. * used to generated the glowing objects (the smaller the faster).
  48705. */
  48706. mainTextureRatio: number;
  48707. /**
  48708. * Enforces a fixed size texture to ensure resize independant blur.
  48709. */
  48710. mainTextureFixedSize?: number;
  48711. /**
  48712. * How big is the kernel of the blur texture.
  48713. */
  48714. blurKernelSize: number;
  48715. /**
  48716. * The camera attached to the layer.
  48717. */
  48718. camera: Nullable<Camera>;
  48719. /**
  48720. * Enable MSAA by chosing the number of samples.
  48721. */
  48722. mainTextureSamples?: number;
  48723. /**
  48724. * The rendering group to draw the layer in.
  48725. */
  48726. renderingGroupId: number;
  48727. }
  48728. /**
  48729. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  48730. *
  48731. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48732. * glowy meshes to your scene.
  48733. *
  48734. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  48735. */
  48736. export class GlowLayer extends EffectLayer {
  48737. /**
  48738. * Effect Name of the layer.
  48739. */
  48740. static readonly EffectName: string;
  48741. /**
  48742. * The default blur kernel size used for the glow.
  48743. */
  48744. static DefaultBlurKernelSize: number;
  48745. /**
  48746. * The default texture size ratio used for the glow.
  48747. */
  48748. static DefaultTextureRatio: number;
  48749. /**
  48750. * Sets the kernel size of the blur.
  48751. */
  48752. /**
  48753. * Gets the kernel size of the blur.
  48754. */
  48755. blurKernelSize: number;
  48756. /**
  48757. * Sets the glow intensity.
  48758. */
  48759. /**
  48760. * Gets the glow intensity.
  48761. */
  48762. intensity: number;
  48763. private _options;
  48764. private _intensity;
  48765. private _horizontalBlurPostprocess1;
  48766. private _verticalBlurPostprocess1;
  48767. private _horizontalBlurPostprocess2;
  48768. private _verticalBlurPostprocess2;
  48769. private _blurTexture1;
  48770. private _blurTexture2;
  48771. private _postProcesses1;
  48772. private _postProcesses2;
  48773. private _includedOnlyMeshes;
  48774. private _excludedMeshes;
  48775. /**
  48776. * Callback used to let the user override the color selection on a per mesh basis
  48777. */
  48778. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  48779. /**
  48780. * Callback used to let the user override the texture selection on a per mesh basis
  48781. */
  48782. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  48783. /**
  48784. * Instantiates a new glow Layer and references it to the scene.
  48785. * @param name The name of the layer
  48786. * @param scene The scene to use the layer in
  48787. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  48788. */
  48789. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  48790. /**
  48791. * Get the effect name of the layer.
  48792. * @return The effect name
  48793. */
  48794. getEffectName(): string;
  48795. /**
  48796. * Create the merge effect. This is the shader use to blit the information back
  48797. * to the main canvas at the end of the scene rendering.
  48798. */
  48799. protected _createMergeEffect(): Effect;
  48800. /**
  48801. * Creates the render target textures and post processes used in the glow layer.
  48802. */
  48803. protected _createTextureAndPostProcesses(): void;
  48804. /**
  48805. * Checks for the readiness of the element composing the layer.
  48806. * @param subMesh the mesh to check for
  48807. * @param useInstances specify wether or not to use instances to render the mesh
  48808. * @param emissiveTexture the associated emissive texture used to generate the glow
  48809. * @return true if ready otherwise, false
  48810. */
  48811. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48812. /**
  48813. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48814. */
  48815. needStencil(): boolean;
  48816. /**
  48817. * Returns true if the mesh can be rendered, otherwise false.
  48818. * @param mesh The mesh to render
  48819. * @param material The material used on the mesh
  48820. * @returns true if it can be rendered otherwise false
  48821. */
  48822. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48823. /**
  48824. * Implementation specific of rendering the generating effect on the main canvas.
  48825. * @param effect The effect used to render through
  48826. */
  48827. protected _internalRender(effect: Effect): void;
  48828. /**
  48829. * Sets the required values for both the emissive texture and and the main color.
  48830. */
  48831. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48832. /**
  48833. * Returns true if the mesh should render, otherwise false.
  48834. * @param mesh The mesh to render
  48835. * @returns true if it should render otherwise false
  48836. */
  48837. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48838. /**
  48839. * Adds specific effects defines.
  48840. * @param defines The defines to add specifics to.
  48841. */
  48842. protected _addCustomEffectDefines(defines: string[]): void;
  48843. /**
  48844. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  48845. * @param mesh The mesh to exclude from the glow layer
  48846. */
  48847. addExcludedMesh(mesh: Mesh): void;
  48848. /**
  48849. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  48850. * @param mesh The mesh to remove
  48851. */
  48852. removeExcludedMesh(mesh: Mesh): void;
  48853. /**
  48854. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  48855. * @param mesh The mesh to include in the glow layer
  48856. */
  48857. addIncludedOnlyMesh(mesh: Mesh): void;
  48858. /**
  48859. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  48860. * @param mesh The mesh to remove
  48861. */
  48862. removeIncludedOnlyMesh(mesh: Mesh): void;
  48863. /**
  48864. * Determine if a given mesh will be used in the glow layer
  48865. * @param mesh The mesh to test
  48866. * @returns true if the mesh will be highlighted by the current glow layer
  48867. */
  48868. hasMesh(mesh: AbstractMesh): boolean;
  48869. /**
  48870. * Free any resources and references associated to a mesh.
  48871. * Internal use
  48872. * @param mesh The mesh to free.
  48873. * @hidden
  48874. */
  48875. _disposeMesh(mesh: Mesh): void;
  48876. /**
  48877. * Gets the class name of the effect layer
  48878. * @returns the string with the class name of the effect layer
  48879. */
  48880. getClassName(): string;
  48881. /**
  48882. * Serializes this glow layer
  48883. * @returns a serialized glow layer object
  48884. */
  48885. serialize(): any;
  48886. /**
  48887. * Creates a Glow Layer from parsed glow layer data
  48888. * @param parsedGlowLayer defines glow layer data
  48889. * @param scene defines the current scene
  48890. * @param rootUrl defines the root URL containing the glow layer information
  48891. * @returns a parsed Glow Layer
  48892. */
  48893. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48894. }
  48895. }
  48896. declare module BABYLON {
  48897. /** @hidden */
  48898. export var glowBlurPostProcessPixelShader: {
  48899. name: string;
  48900. shader: string;
  48901. };
  48902. }
  48903. declare module BABYLON {
  48904. interface AbstractScene {
  48905. /**
  48906. * Return a the first highlight layer of the scene with a given name.
  48907. * @param name The name of the highlight layer to look for.
  48908. * @return The highlight layer if found otherwise null.
  48909. */
  48910. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48911. }
  48912. /**
  48913. * Highlight layer options. This helps customizing the behaviour
  48914. * of the highlight layer.
  48915. */
  48916. export interface IHighlightLayerOptions {
  48917. /**
  48918. * Multiplication factor apply to the canvas size to compute the render target size
  48919. * used to generated the glowing objects (the smaller the faster).
  48920. */
  48921. mainTextureRatio: number;
  48922. /**
  48923. * Enforces a fixed size texture to ensure resize independant blur.
  48924. */
  48925. mainTextureFixedSize?: number;
  48926. /**
  48927. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48928. * of the picture to blur (the smaller the faster).
  48929. */
  48930. blurTextureSizeRatio: number;
  48931. /**
  48932. * How big in texel of the blur texture is the vertical blur.
  48933. */
  48934. blurVerticalSize: number;
  48935. /**
  48936. * How big in texel of the blur texture is the horizontal blur.
  48937. */
  48938. blurHorizontalSize: number;
  48939. /**
  48940. * Alpha blending mode used to apply the blur. Default is combine.
  48941. */
  48942. alphaBlendingMode: number;
  48943. /**
  48944. * The camera attached to the layer.
  48945. */
  48946. camera: Nullable<Camera>;
  48947. /**
  48948. * Should we display highlight as a solid stroke?
  48949. */
  48950. isStroke?: boolean;
  48951. /**
  48952. * The rendering group to draw the layer in.
  48953. */
  48954. renderingGroupId: number;
  48955. }
  48956. /**
  48957. * The highlight layer Helps adding a glow effect around a mesh.
  48958. *
  48959. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48960. * glowy meshes to your scene.
  48961. *
  48962. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48963. */
  48964. export class HighlightLayer extends EffectLayer {
  48965. name: string;
  48966. /**
  48967. * Effect Name of the highlight layer.
  48968. */
  48969. static readonly EffectName: string;
  48970. /**
  48971. * The neutral color used during the preparation of the glow effect.
  48972. * This is black by default as the blend operation is a blend operation.
  48973. */
  48974. static NeutralColor: Color4;
  48975. /**
  48976. * Stencil value used for glowing meshes.
  48977. */
  48978. static GlowingMeshStencilReference: number;
  48979. /**
  48980. * Stencil value used for the other meshes in the scene.
  48981. */
  48982. static NormalMeshStencilReference: number;
  48983. /**
  48984. * Specifies whether or not the inner glow is ACTIVE in the layer.
  48985. */
  48986. innerGlow: boolean;
  48987. /**
  48988. * Specifies whether or not the outer glow is ACTIVE in the layer.
  48989. */
  48990. outerGlow: boolean;
  48991. /**
  48992. * Specifies the horizontal size of the blur.
  48993. */
  48994. /**
  48995. * Gets the horizontal size of the blur.
  48996. */
  48997. blurHorizontalSize: number;
  48998. /**
  48999. * Specifies the vertical size of the blur.
  49000. */
  49001. /**
  49002. * Gets the vertical size of the blur.
  49003. */
  49004. blurVerticalSize: number;
  49005. /**
  49006. * An event triggered when the highlight layer is being blurred.
  49007. */
  49008. onBeforeBlurObservable: Observable<HighlightLayer>;
  49009. /**
  49010. * An event triggered when the highlight layer has been blurred.
  49011. */
  49012. onAfterBlurObservable: Observable<HighlightLayer>;
  49013. private _instanceGlowingMeshStencilReference;
  49014. private _options;
  49015. private _downSamplePostprocess;
  49016. private _horizontalBlurPostprocess;
  49017. private _verticalBlurPostprocess;
  49018. private _blurTexture;
  49019. private _meshes;
  49020. private _excludedMeshes;
  49021. /**
  49022. * Instantiates a new highlight Layer and references it to the scene..
  49023. * @param name The name of the layer
  49024. * @param scene The scene to use the layer in
  49025. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49026. */
  49027. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49028. /**
  49029. * Get the effect name of the layer.
  49030. * @return The effect name
  49031. */
  49032. getEffectName(): string;
  49033. /**
  49034. * Create the merge effect. This is the shader use to blit the information back
  49035. * to the main canvas at the end of the scene rendering.
  49036. */
  49037. protected _createMergeEffect(): Effect;
  49038. /**
  49039. * Creates the render target textures and post processes used in the highlight layer.
  49040. */
  49041. protected _createTextureAndPostProcesses(): void;
  49042. /**
  49043. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49044. */
  49045. needStencil(): boolean;
  49046. /**
  49047. * Checks for the readiness of the element composing the layer.
  49048. * @param subMesh the mesh to check for
  49049. * @param useInstances specify wether or not to use instances to render the mesh
  49050. * @param emissiveTexture the associated emissive texture used to generate the glow
  49051. * @return true if ready otherwise, false
  49052. */
  49053. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49054. /**
  49055. * Implementation specific of rendering the generating effect on the main canvas.
  49056. * @param effect The effect used to render through
  49057. */
  49058. protected _internalRender(effect: Effect): void;
  49059. /**
  49060. * Returns true if the layer contains information to display, otherwise false.
  49061. */
  49062. shouldRender(): boolean;
  49063. /**
  49064. * Returns true if the mesh should render, otherwise false.
  49065. * @param mesh The mesh to render
  49066. * @returns true if it should render otherwise false
  49067. */
  49068. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49069. /**
  49070. * Sets the required values for both the emissive texture and and the main color.
  49071. */
  49072. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49073. /**
  49074. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49075. * @param mesh The mesh to exclude from the highlight layer
  49076. */
  49077. addExcludedMesh(mesh: Mesh): void;
  49078. /**
  49079. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49080. * @param mesh The mesh to highlight
  49081. */
  49082. removeExcludedMesh(mesh: Mesh): void;
  49083. /**
  49084. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49085. * @param mesh mesh to test
  49086. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49087. */
  49088. hasMesh(mesh: AbstractMesh): boolean;
  49089. /**
  49090. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49091. * @param mesh The mesh to highlight
  49092. * @param color The color of the highlight
  49093. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49094. */
  49095. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49096. /**
  49097. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49098. * @param mesh The mesh to highlight
  49099. */
  49100. removeMesh(mesh: Mesh): void;
  49101. /**
  49102. * Force the stencil to the normal expected value for none glowing parts
  49103. */
  49104. private _defaultStencilReference;
  49105. /**
  49106. * Free any resources and references associated to a mesh.
  49107. * Internal use
  49108. * @param mesh The mesh to free.
  49109. * @hidden
  49110. */
  49111. _disposeMesh(mesh: Mesh): void;
  49112. /**
  49113. * Dispose the highlight layer and free resources.
  49114. */
  49115. dispose(): void;
  49116. /**
  49117. * Gets the class name of the effect layer
  49118. * @returns the string with the class name of the effect layer
  49119. */
  49120. getClassName(): string;
  49121. /**
  49122. * Serializes this Highlight layer
  49123. * @returns a serialized Highlight layer object
  49124. */
  49125. serialize(): any;
  49126. /**
  49127. * Creates a Highlight layer from parsed Highlight layer data
  49128. * @param parsedHightlightLayer defines the Highlight layer data
  49129. * @param scene defines the current scene
  49130. * @param rootUrl defines the root URL containing the Highlight layer information
  49131. * @returns a parsed Highlight layer
  49132. */
  49133. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49134. }
  49135. }
  49136. declare module BABYLON {
  49137. interface AbstractScene {
  49138. /**
  49139. * The list of layers (background and foreground) of the scene
  49140. */
  49141. layers: Array<Layer>;
  49142. }
  49143. /**
  49144. * Defines the layer scene component responsible to manage any layers
  49145. * in a given scene.
  49146. */
  49147. export class LayerSceneComponent implements ISceneComponent {
  49148. /**
  49149. * The component name helpfull to identify the component in the list of scene components.
  49150. */
  49151. readonly name: string;
  49152. /**
  49153. * The scene the component belongs to.
  49154. */
  49155. scene: Scene;
  49156. private _engine;
  49157. /**
  49158. * Creates a new instance of the component for the given scene
  49159. * @param scene Defines the scene to register the component in
  49160. */
  49161. constructor(scene: Scene);
  49162. /**
  49163. * Registers the component in a given scene
  49164. */
  49165. register(): void;
  49166. /**
  49167. * Rebuilds the elements related to this component in case of
  49168. * context lost for instance.
  49169. */
  49170. rebuild(): void;
  49171. /**
  49172. * Disposes the component and the associated ressources.
  49173. */
  49174. dispose(): void;
  49175. private _draw;
  49176. private _drawCameraPredicate;
  49177. private _drawCameraBackground;
  49178. private _drawCameraForeground;
  49179. private _drawRenderTargetPredicate;
  49180. private _drawRenderTargetBackground;
  49181. private _drawRenderTargetForeground;
  49182. /**
  49183. * Adds all the elements from the container to the scene
  49184. * @param container the container holding the elements
  49185. */
  49186. addFromContainer(container: AbstractScene): void;
  49187. /**
  49188. * Removes all the elements in the container from the scene
  49189. * @param container contains the elements to remove
  49190. * @param dispose if the removed element should be disposed (default: false)
  49191. */
  49192. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49193. }
  49194. }
  49195. declare module BABYLON {
  49196. /** @hidden */
  49197. export var layerPixelShader: {
  49198. name: string;
  49199. shader: string;
  49200. };
  49201. }
  49202. declare module BABYLON {
  49203. /** @hidden */
  49204. export var layerVertexShader: {
  49205. name: string;
  49206. shader: string;
  49207. };
  49208. }
  49209. declare module BABYLON {
  49210. /**
  49211. * This represents a full screen 2d layer.
  49212. * This can be useful to display a picture in the background of your scene for instance.
  49213. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49214. */
  49215. export class Layer {
  49216. /**
  49217. * Define the name of the layer.
  49218. */
  49219. name: string;
  49220. /**
  49221. * Define the texture the layer should display.
  49222. */
  49223. texture: Nullable<Texture>;
  49224. /**
  49225. * Is the layer in background or foreground.
  49226. */
  49227. isBackground: boolean;
  49228. /**
  49229. * Define the color of the layer (instead of texture).
  49230. */
  49231. color: Color4;
  49232. /**
  49233. * Define the scale of the layer in order to zoom in out of the texture.
  49234. */
  49235. scale: Vector2;
  49236. /**
  49237. * Define an offset for the layer in order to shift the texture.
  49238. */
  49239. offset: Vector2;
  49240. /**
  49241. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  49242. */
  49243. alphaBlendingMode: number;
  49244. /**
  49245. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  49246. * Alpha test will not mix with the background color in case of transparency.
  49247. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  49248. */
  49249. alphaTest: boolean;
  49250. /**
  49251. * Define a mask to restrict the layer to only some of the scene cameras.
  49252. */
  49253. layerMask: number;
  49254. /**
  49255. * Define the list of render target the layer is visible into.
  49256. */
  49257. renderTargetTextures: RenderTargetTexture[];
  49258. /**
  49259. * Define if the layer is only used in renderTarget or if it also
  49260. * renders in the main frame buffer of the canvas.
  49261. */
  49262. renderOnlyInRenderTargetTextures: boolean;
  49263. private _scene;
  49264. private _vertexBuffers;
  49265. private _indexBuffer;
  49266. private _effect;
  49267. private _alphaTestEffect;
  49268. /**
  49269. * An event triggered when the layer is disposed.
  49270. */
  49271. onDisposeObservable: Observable<Layer>;
  49272. private _onDisposeObserver;
  49273. /**
  49274. * Back compatibility with callback before the onDisposeObservable existed.
  49275. * The set callback will be triggered when the layer has been disposed.
  49276. */
  49277. onDispose: () => void;
  49278. /**
  49279. * An event triggered before rendering the scene
  49280. */
  49281. onBeforeRenderObservable: Observable<Layer>;
  49282. private _onBeforeRenderObserver;
  49283. /**
  49284. * Back compatibility with callback before the onBeforeRenderObservable existed.
  49285. * The set callback will be triggered just before rendering the layer.
  49286. */
  49287. onBeforeRender: () => void;
  49288. /**
  49289. * An event triggered after rendering the scene
  49290. */
  49291. onAfterRenderObservable: Observable<Layer>;
  49292. private _onAfterRenderObserver;
  49293. /**
  49294. * Back compatibility with callback before the onAfterRenderObservable existed.
  49295. * The set callback will be triggered just after rendering the layer.
  49296. */
  49297. onAfterRender: () => void;
  49298. /**
  49299. * Instantiates a new layer.
  49300. * This represents a full screen 2d layer.
  49301. * This can be useful to display a picture in the background of your scene for instance.
  49302. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49303. * @param name Define the name of the layer in the scene
  49304. * @param imgUrl Define the url of the texture to display in the layer
  49305. * @param scene Define the scene the layer belongs to
  49306. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  49307. * @param color Defines a color for the layer
  49308. */
  49309. constructor(
  49310. /**
  49311. * Define the name of the layer.
  49312. */
  49313. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  49314. private _createIndexBuffer;
  49315. /** @hidden */
  49316. _rebuild(): void;
  49317. /**
  49318. * Renders the layer in the scene.
  49319. */
  49320. render(): void;
  49321. /**
  49322. * Disposes and releases the associated ressources.
  49323. */
  49324. dispose(): void;
  49325. }
  49326. }
  49327. declare module BABYLON {
  49328. /** @hidden */
  49329. export var lensFlarePixelShader: {
  49330. name: string;
  49331. shader: string;
  49332. };
  49333. }
  49334. declare module BABYLON {
  49335. /** @hidden */
  49336. export var lensFlareVertexShader: {
  49337. name: string;
  49338. shader: string;
  49339. };
  49340. }
  49341. declare module BABYLON {
  49342. /**
  49343. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49344. * It is usually composed of several `lensFlare`.
  49345. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49346. */
  49347. export class LensFlareSystem {
  49348. /**
  49349. * Define the name of the lens flare system
  49350. */
  49351. name: string;
  49352. /**
  49353. * List of lens flares used in this system.
  49354. */
  49355. lensFlares: LensFlare[];
  49356. /**
  49357. * Define a limit from the border the lens flare can be visible.
  49358. */
  49359. borderLimit: number;
  49360. /**
  49361. * Define a viewport border we do not want to see the lens flare in.
  49362. */
  49363. viewportBorder: number;
  49364. /**
  49365. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49366. */
  49367. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49368. /**
  49369. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49370. */
  49371. layerMask: number;
  49372. /**
  49373. * Define the id of the lens flare system in the scene.
  49374. * (equal to name by default)
  49375. */
  49376. id: string;
  49377. private _scene;
  49378. private _emitter;
  49379. private _vertexBuffers;
  49380. private _indexBuffer;
  49381. private _effect;
  49382. private _positionX;
  49383. private _positionY;
  49384. private _isEnabled;
  49385. /** @hidden */
  49386. static _SceneComponentInitialization: (scene: Scene) => void;
  49387. /**
  49388. * Instantiates a lens flare system.
  49389. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49390. * It is usually composed of several `lensFlare`.
  49391. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49392. * @param name Define the name of the lens flare system in the scene
  49393. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49394. * @param scene Define the scene the lens flare system belongs to
  49395. */
  49396. constructor(
  49397. /**
  49398. * Define the name of the lens flare system
  49399. */
  49400. name: string, emitter: any, scene: Scene);
  49401. /**
  49402. * Define if the lens flare system is enabled.
  49403. */
  49404. isEnabled: boolean;
  49405. /**
  49406. * Get the scene the effects belongs to.
  49407. * @returns the scene holding the lens flare system
  49408. */
  49409. getScene(): Scene;
  49410. /**
  49411. * Get the emitter of the lens flare system.
  49412. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49413. * @returns the emitter of the lens flare system
  49414. */
  49415. getEmitter(): any;
  49416. /**
  49417. * Set the emitter of the lens flare system.
  49418. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49419. * @param newEmitter Define the new emitter of the system
  49420. */
  49421. setEmitter(newEmitter: any): void;
  49422. /**
  49423. * Get the lens flare system emitter position.
  49424. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49425. * @returns the position
  49426. */
  49427. getEmitterPosition(): Vector3;
  49428. /**
  49429. * @hidden
  49430. */
  49431. computeEffectivePosition(globalViewport: Viewport): boolean;
  49432. /** @hidden */
  49433. _isVisible(): boolean;
  49434. /**
  49435. * @hidden
  49436. */
  49437. render(): boolean;
  49438. /**
  49439. * Dispose and release the lens flare with its associated resources.
  49440. */
  49441. dispose(): void;
  49442. /**
  49443. * Parse a lens flare system from a JSON repressentation
  49444. * @param parsedLensFlareSystem Define the JSON to parse
  49445. * @param scene Define the scene the parsed system should be instantiated in
  49446. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49447. * @returns the parsed system
  49448. */
  49449. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49450. /**
  49451. * Serialize the current Lens Flare System into a JSON representation.
  49452. * @returns the serialized JSON
  49453. */
  49454. serialize(): any;
  49455. }
  49456. }
  49457. declare module BABYLON {
  49458. /**
  49459. * This represents one of the lens effect in a `lensFlareSystem`.
  49460. * It controls one of the indiviual texture used in the effect.
  49461. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49462. */
  49463. export class LensFlare {
  49464. /**
  49465. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49466. */
  49467. size: number;
  49468. /**
  49469. * 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.
  49470. */
  49471. position: number;
  49472. /**
  49473. * Define the lens color.
  49474. */
  49475. color: Color3;
  49476. /**
  49477. * Define the lens texture.
  49478. */
  49479. texture: Nullable<Texture>;
  49480. /**
  49481. * Define the alpha mode to render this particular lens.
  49482. */
  49483. alphaMode: number;
  49484. private _system;
  49485. /**
  49486. * Creates a new Lens Flare.
  49487. * This represents one of the lens effect in a `lensFlareSystem`.
  49488. * It controls one of the indiviual texture used in the effect.
  49489. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49490. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49491. * @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.
  49492. * @param color Define the lens color
  49493. * @param imgUrl Define the lens texture url
  49494. * @param system Define the `lensFlareSystem` this flare is part of
  49495. * @returns The newly created Lens Flare
  49496. */
  49497. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49498. /**
  49499. * Instantiates a new Lens Flare.
  49500. * This represents one of the lens effect in a `lensFlareSystem`.
  49501. * It controls one of the indiviual texture used in the effect.
  49502. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49503. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49504. * @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.
  49505. * @param color Define the lens color
  49506. * @param imgUrl Define the lens texture url
  49507. * @param system Define the `lensFlareSystem` this flare is part of
  49508. */
  49509. constructor(
  49510. /**
  49511. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49512. */
  49513. size: number,
  49514. /**
  49515. * 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.
  49516. */
  49517. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49518. /**
  49519. * Dispose and release the lens flare with its associated resources.
  49520. */
  49521. dispose(): void;
  49522. }
  49523. }
  49524. declare module BABYLON {
  49525. interface AbstractScene {
  49526. /**
  49527. * The list of lens flare system added to the scene
  49528. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49529. */
  49530. lensFlareSystems: Array<LensFlareSystem>;
  49531. /**
  49532. * Removes the given lens flare system from this scene.
  49533. * @param toRemove The lens flare system to remove
  49534. * @returns The index of the removed lens flare system
  49535. */
  49536. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49537. /**
  49538. * Adds the given lens flare system to this scene
  49539. * @param newLensFlareSystem The lens flare system to add
  49540. */
  49541. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49542. /**
  49543. * Gets a lens flare system using its name
  49544. * @param name defines the name to look for
  49545. * @returns the lens flare system or null if not found
  49546. */
  49547. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49548. /**
  49549. * Gets a lens flare system using its id
  49550. * @param id defines the id to look for
  49551. * @returns the lens flare system or null if not found
  49552. */
  49553. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49554. }
  49555. /**
  49556. * Defines the lens flare scene component responsible to manage any lens flares
  49557. * in a given scene.
  49558. */
  49559. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49560. /**
  49561. * The component name helpfull to identify the component in the list of scene components.
  49562. */
  49563. readonly name: string;
  49564. /**
  49565. * The scene the component belongs to.
  49566. */
  49567. scene: Scene;
  49568. /**
  49569. * Creates a new instance of the component for the given scene
  49570. * @param scene Defines the scene to register the component in
  49571. */
  49572. constructor(scene: Scene);
  49573. /**
  49574. * Registers the component in a given scene
  49575. */
  49576. register(): void;
  49577. /**
  49578. * Rebuilds the elements related to this component in case of
  49579. * context lost for instance.
  49580. */
  49581. rebuild(): void;
  49582. /**
  49583. * Adds all the elements from the container to the scene
  49584. * @param container the container holding the elements
  49585. */
  49586. addFromContainer(container: AbstractScene): void;
  49587. /**
  49588. * Removes all the elements in the container from the scene
  49589. * @param container contains the elements to remove
  49590. * @param dispose if the removed element should be disposed (default: false)
  49591. */
  49592. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49593. /**
  49594. * Serializes the component data to the specified json object
  49595. * @param serializationObject The object to serialize to
  49596. */
  49597. serialize(serializationObject: any): void;
  49598. /**
  49599. * Disposes the component and the associated ressources.
  49600. */
  49601. dispose(): void;
  49602. private _draw;
  49603. }
  49604. }
  49605. declare module BABYLON {
  49606. /**
  49607. * Defines the shadow generator component responsible to manage any shadow generators
  49608. * in a given scene.
  49609. */
  49610. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49611. /**
  49612. * The component name helpfull to identify the component in the list of scene components.
  49613. */
  49614. readonly name: string;
  49615. /**
  49616. * The scene the component belongs to.
  49617. */
  49618. scene: Scene;
  49619. /**
  49620. * Creates a new instance of the component for the given scene
  49621. * @param scene Defines the scene to register the component in
  49622. */
  49623. constructor(scene: Scene);
  49624. /**
  49625. * Registers the component in a given scene
  49626. */
  49627. register(): void;
  49628. /**
  49629. * Rebuilds the elements related to this component in case of
  49630. * context lost for instance.
  49631. */
  49632. rebuild(): void;
  49633. /**
  49634. * Serializes the component data to the specified json object
  49635. * @param serializationObject The object to serialize to
  49636. */
  49637. serialize(serializationObject: any): void;
  49638. /**
  49639. * Adds all the elements from the container to the scene
  49640. * @param container the container holding the elements
  49641. */
  49642. addFromContainer(container: AbstractScene): void;
  49643. /**
  49644. * Removes all the elements in the container from the scene
  49645. * @param container contains the elements to remove
  49646. * @param dispose if the removed element should be disposed (default: false)
  49647. */
  49648. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49649. /**
  49650. * Rebuilds the elements related to this component in case of
  49651. * context lost for instance.
  49652. */
  49653. dispose(): void;
  49654. private _gatherRenderTargets;
  49655. }
  49656. }
  49657. declare module BABYLON {
  49658. /**
  49659. * A point light is a light defined by an unique point in world space.
  49660. * The light is emitted in every direction from this point.
  49661. * A good example of a point light is a standard light bulb.
  49662. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49663. */
  49664. export class PointLight extends ShadowLight {
  49665. private _shadowAngle;
  49666. /**
  49667. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49668. * This specifies what angle the shadow will use to be created.
  49669. *
  49670. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49671. */
  49672. /**
  49673. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49674. * This specifies what angle the shadow will use to be created.
  49675. *
  49676. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49677. */
  49678. shadowAngle: number;
  49679. /**
  49680. * Gets the direction if it has been set.
  49681. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49682. */
  49683. /**
  49684. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49685. */
  49686. direction: Vector3;
  49687. /**
  49688. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49689. * A PointLight emits the light in every direction.
  49690. * It can cast shadows.
  49691. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49692. * ```javascript
  49693. * var pointLight = new PointLight("pl", camera.position, scene);
  49694. * ```
  49695. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49696. * @param name The light friendly name
  49697. * @param position The position of the point light in the scene
  49698. * @param scene The scene the lights belongs to
  49699. */
  49700. constructor(name: string, position: Vector3, scene: Scene);
  49701. /**
  49702. * Returns the string "PointLight"
  49703. * @returns the class name
  49704. */
  49705. getClassName(): string;
  49706. /**
  49707. * Returns the integer 0.
  49708. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49709. */
  49710. getTypeID(): number;
  49711. /**
  49712. * Specifies wether or not the shadowmap should be a cube texture.
  49713. * @returns true if the shadowmap needs to be a cube texture.
  49714. */
  49715. needCube(): boolean;
  49716. /**
  49717. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49718. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49719. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49720. */
  49721. getShadowDirection(faceIndex?: number): Vector3;
  49722. /**
  49723. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49724. * - fov = PI / 2
  49725. * - aspect ratio : 1.0
  49726. * - z-near and far equal to the active camera minZ and maxZ.
  49727. * Returns the PointLight.
  49728. */
  49729. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49730. protected _buildUniformLayout(): void;
  49731. /**
  49732. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49733. * @param effect The effect to update
  49734. * @param lightIndex The index of the light in the effect to update
  49735. * @returns The point light
  49736. */
  49737. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  49738. /**
  49739. * Prepares the list of defines specific to the light type.
  49740. * @param defines the list of defines
  49741. * @param lightIndex defines the index of the light for the effect
  49742. */
  49743. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49744. }
  49745. }
  49746. declare module BABYLON {
  49747. /**
  49748. * Header information of HDR texture files.
  49749. */
  49750. export interface HDRInfo {
  49751. /**
  49752. * The height of the texture in pixels.
  49753. */
  49754. height: number;
  49755. /**
  49756. * The width of the texture in pixels.
  49757. */
  49758. width: number;
  49759. /**
  49760. * The index of the beginning of the data in the binary file.
  49761. */
  49762. dataPosition: number;
  49763. }
  49764. /**
  49765. * This groups tools to convert HDR texture to native colors array.
  49766. */
  49767. export class HDRTools {
  49768. private static Ldexp;
  49769. private static Rgbe2float;
  49770. private static readStringLine;
  49771. /**
  49772. * Reads header information from an RGBE texture stored in a native array.
  49773. * More information on this format are available here:
  49774. * https://en.wikipedia.org/wiki/RGBE_image_format
  49775. *
  49776. * @param uint8array The binary file stored in native array.
  49777. * @return The header information.
  49778. */
  49779. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49780. /**
  49781. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49782. * This RGBE texture needs to store the information as a panorama.
  49783. *
  49784. * More information on this format are available here:
  49785. * https://en.wikipedia.org/wiki/RGBE_image_format
  49786. *
  49787. * @param buffer The binary file stored in an array buffer.
  49788. * @param size The expected size of the extracted cubemap.
  49789. * @return The Cube Map information.
  49790. */
  49791. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49792. /**
  49793. * Returns the pixels data extracted from an RGBE texture.
  49794. * This pixels will be stored left to right up to down in the R G B order in one array.
  49795. *
  49796. * More information on this format are available here:
  49797. * https://en.wikipedia.org/wiki/RGBE_image_format
  49798. *
  49799. * @param uint8array The binary file stored in an array buffer.
  49800. * @param hdrInfo The header information of the file.
  49801. * @return The pixels data in RGB right to left up to down order.
  49802. */
  49803. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49804. private static RGBE_ReadPixels_RLE;
  49805. }
  49806. }
  49807. declare module BABYLON {
  49808. /**
  49809. * This represents a texture coming from an HDR input.
  49810. *
  49811. * The only supported format is currently panorama picture stored in RGBE format.
  49812. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49813. */
  49814. export class HDRCubeTexture extends BaseTexture {
  49815. private static _facesMapping;
  49816. private _generateHarmonics;
  49817. private _noMipmap;
  49818. private _textureMatrix;
  49819. private _size;
  49820. private _onLoad;
  49821. private _onError;
  49822. /**
  49823. * The texture URL.
  49824. */
  49825. url: string;
  49826. /**
  49827. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49828. */
  49829. coordinatesMode: number;
  49830. protected _isBlocking: boolean;
  49831. /**
  49832. * Sets wether or not the texture is blocking during loading.
  49833. */
  49834. /**
  49835. * Gets wether or not the texture is blocking during loading.
  49836. */
  49837. isBlocking: boolean;
  49838. protected _rotationY: number;
  49839. /**
  49840. * Sets texture matrix rotation angle around Y axis in radians.
  49841. */
  49842. /**
  49843. * Gets texture matrix rotation angle around Y axis radians.
  49844. */
  49845. rotationY: number;
  49846. /**
  49847. * Gets or sets the center of the bounding box associated with the cube texture
  49848. * It must define where the camera used to render the texture was set
  49849. */
  49850. boundingBoxPosition: Vector3;
  49851. private _boundingBoxSize;
  49852. /**
  49853. * Gets or sets the size of the bounding box associated with the cube texture
  49854. * When defined, the cubemap will switch to local mode
  49855. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49856. * @example https://www.babylonjs-playground.com/#RNASML
  49857. */
  49858. boundingBoxSize: Vector3;
  49859. /**
  49860. * Instantiates an HDRTexture from the following parameters.
  49861. *
  49862. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49863. * @param scene The scene the texture will be used in
  49864. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49865. * @param noMipmap Forces to not generate the mipmap if true
  49866. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49867. * @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)
  49868. * @param reserved Reserved flag for internal use.
  49869. */
  49870. 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>);
  49871. /**
  49872. * Get the current class name of the texture useful for serialization or dynamic coding.
  49873. * @returns "HDRCubeTexture"
  49874. */
  49875. getClassName(): string;
  49876. /**
  49877. * Occurs when the file is raw .hdr file.
  49878. */
  49879. private loadTexture;
  49880. clone(): HDRCubeTexture;
  49881. delayLoad(): void;
  49882. /**
  49883. * Get the texture reflection matrix used to rotate/transform the reflection.
  49884. * @returns the reflection matrix
  49885. */
  49886. getReflectionTextureMatrix(): Matrix;
  49887. /**
  49888. * Set the texture reflection matrix used to rotate/transform the reflection.
  49889. * @param value Define the reflection matrix to set
  49890. */
  49891. setReflectionTextureMatrix(value: Matrix): void;
  49892. /**
  49893. * Parses a JSON representation of an HDR Texture in order to create the texture
  49894. * @param parsedTexture Define the JSON representation
  49895. * @param scene Define the scene the texture should be created in
  49896. * @param rootUrl Define the root url in case we need to load relative dependencies
  49897. * @returns the newly created texture after parsing
  49898. */
  49899. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49900. serialize(): any;
  49901. }
  49902. }
  49903. declare module BABYLON {
  49904. /**
  49905. * Class used to control physics engine
  49906. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49907. */
  49908. export class PhysicsEngine implements IPhysicsEngine {
  49909. private _physicsPlugin;
  49910. /**
  49911. * Global value used to control the smallest number supported by the simulation
  49912. */
  49913. static Epsilon: number;
  49914. private _impostors;
  49915. private _joints;
  49916. /**
  49917. * Gets the gravity vector used by the simulation
  49918. */
  49919. gravity: Vector3;
  49920. /**
  49921. * Factory used to create the default physics plugin.
  49922. * @returns The default physics plugin
  49923. */
  49924. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49925. /**
  49926. * Creates a new Physics Engine
  49927. * @param gravity defines the gravity vector used by the simulation
  49928. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49929. */
  49930. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49931. /**
  49932. * Sets the gravity vector used by the simulation
  49933. * @param gravity defines the gravity vector to use
  49934. */
  49935. setGravity(gravity: Vector3): void;
  49936. /**
  49937. * Set the time step of the physics engine.
  49938. * Default is 1/60.
  49939. * To slow it down, enter 1/600 for example.
  49940. * To speed it up, 1/30
  49941. * @param newTimeStep defines the new timestep to apply to this world.
  49942. */
  49943. setTimeStep(newTimeStep?: number): void;
  49944. /**
  49945. * Get the time step of the physics engine.
  49946. * @returns the current time step
  49947. */
  49948. getTimeStep(): number;
  49949. /**
  49950. * Release all resources
  49951. */
  49952. dispose(): void;
  49953. /**
  49954. * Gets the name of the current physics plugin
  49955. * @returns the name of the plugin
  49956. */
  49957. getPhysicsPluginName(): string;
  49958. /**
  49959. * Adding a new impostor for the impostor tracking.
  49960. * This will be done by the impostor itself.
  49961. * @param impostor the impostor to add
  49962. */
  49963. addImpostor(impostor: PhysicsImpostor): void;
  49964. /**
  49965. * Remove an impostor from the engine.
  49966. * This impostor and its mesh will not longer be updated by the physics engine.
  49967. * @param impostor the impostor to remove
  49968. */
  49969. removeImpostor(impostor: PhysicsImpostor): void;
  49970. /**
  49971. * Add a joint to the physics engine
  49972. * @param mainImpostor defines the main impostor to which the joint is added.
  49973. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49974. * @param joint defines the joint that will connect both impostors.
  49975. */
  49976. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49977. /**
  49978. * Removes a joint from the simulation
  49979. * @param mainImpostor defines the impostor used with the joint
  49980. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49981. * @param joint defines the joint to remove
  49982. */
  49983. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49984. /**
  49985. * Called by the scene. No need to call it.
  49986. * @param delta defines the timespam between frames
  49987. */
  49988. _step(delta: number): void;
  49989. /**
  49990. * Gets the current plugin used to run the simulation
  49991. * @returns current plugin
  49992. */
  49993. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49994. /**
  49995. * Gets the list of physic impostors
  49996. * @returns an array of PhysicsImpostor
  49997. */
  49998. getImpostors(): Array<PhysicsImpostor>;
  49999. /**
  50000. * Gets the impostor for a physics enabled object
  50001. * @param object defines the object impersonated by the impostor
  50002. * @returns the PhysicsImpostor or null if not found
  50003. */
  50004. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50005. /**
  50006. * Gets the impostor for a physics body object
  50007. * @param body defines physics body used by the impostor
  50008. * @returns the PhysicsImpostor or null if not found
  50009. */
  50010. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50011. /**
  50012. * Does a raycast in the physics world
  50013. * @param from when should the ray start?
  50014. * @param to when should the ray end?
  50015. * @returns PhysicsRaycastResult
  50016. */
  50017. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50018. }
  50019. }
  50020. declare module BABYLON {
  50021. /** @hidden */
  50022. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50023. private _useDeltaForWorldStep;
  50024. world: any;
  50025. name: string;
  50026. private _physicsMaterials;
  50027. private _fixedTimeStep;
  50028. private _cannonRaycastResult;
  50029. private _raycastResult;
  50030. private _physicsBodysToRemoveAfterStep;
  50031. BJSCANNON: any;
  50032. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50033. setGravity(gravity: Vector3): void;
  50034. setTimeStep(timeStep: number): void;
  50035. getTimeStep(): number;
  50036. executeStep(delta: number): void;
  50037. private _removeMarkedPhysicsBodiesFromWorld;
  50038. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50039. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50040. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50041. private _processChildMeshes;
  50042. removePhysicsBody(impostor: PhysicsImpostor): void;
  50043. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50044. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50045. private _addMaterial;
  50046. private _checkWithEpsilon;
  50047. private _createShape;
  50048. private _createHeightmap;
  50049. private _minus90X;
  50050. private _plus90X;
  50051. private _tmpPosition;
  50052. private _tmpDeltaPosition;
  50053. private _tmpUnityRotation;
  50054. private _updatePhysicsBodyTransformation;
  50055. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50056. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50057. isSupported(): boolean;
  50058. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50059. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50060. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50061. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50062. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50063. getBodyMass(impostor: PhysicsImpostor): number;
  50064. getBodyFriction(impostor: PhysicsImpostor): number;
  50065. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50066. getBodyRestitution(impostor: PhysicsImpostor): number;
  50067. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50068. sleepBody(impostor: PhysicsImpostor): void;
  50069. wakeUpBody(impostor: PhysicsImpostor): void;
  50070. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50071. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50072. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50073. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50074. getRadius(impostor: PhysicsImpostor): number;
  50075. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50076. dispose(): void;
  50077. private _extendNamespace;
  50078. /**
  50079. * Does a raycast in the physics world
  50080. * @param from when should the ray start?
  50081. * @param to when should the ray end?
  50082. * @returns PhysicsRaycastResult
  50083. */
  50084. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50085. }
  50086. }
  50087. declare module BABYLON {
  50088. /** @hidden */
  50089. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50090. world: any;
  50091. name: string;
  50092. BJSOIMO: any;
  50093. private _raycastResult;
  50094. constructor(iterations?: number, oimoInjection?: any);
  50095. setGravity(gravity: Vector3): void;
  50096. setTimeStep(timeStep: number): void;
  50097. getTimeStep(): number;
  50098. private _tmpImpostorsArray;
  50099. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50100. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50101. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50102. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50103. private _tmpPositionVector;
  50104. removePhysicsBody(impostor: PhysicsImpostor): void;
  50105. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50106. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50107. isSupported(): boolean;
  50108. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50109. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50110. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50111. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50112. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50113. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50114. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50115. getBodyMass(impostor: PhysicsImpostor): number;
  50116. getBodyFriction(impostor: PhysicsImpostor): number;
  50117. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50118. getBodyRestitution(impostor: PhysicsImpostor): number;
  50119. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50120. sleepBody(impostor: PhysicsImpostor): void;
  50121. wakeUpBody(impostor: PhysicsImpostor): void;
  50122. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50123. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50124. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50125. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50126. getRadius(impostor: PhysicsImpostor): number;
  50127. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50128. dispose(): void;
  50129. /**
  50130. * Does a raycast in the physics world
  50131. * @param from when should the ray start?
  50132. * @param to when should the ray end?
  50133. * @returns PhysicsRaycastResult
  50134. */
  50135. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50136. }
  50137. }
  50138. declare module BABYLON {
  50139. /**
  50140. * Class containing static functions to help procedurally build meshes
  50141. */
  50142. export class RibbonBuilder {
  50143. /**
  50144. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50145. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50146. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50147. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50148. * * 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
  50149. * * 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
  50150. * * 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
  50151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50152. * * 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
  50153. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50154. * * 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
  50155. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50156. * * 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
  50157. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50158. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50159. * @param name defines the name of the mesh
  50160. * @param options defines the options used to create the mesh
  50161. * @param scene defines the hosting scene
  50162. * @returns the ribbon mesh
  50163. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50164. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50165. */
  50166. static CreateRibbon(name: string, options: {
  50167. pathArray: Vector3[][];
  50168. closeArray?: boolean;
  50169. closePath?: boolean;
  50170. offset?: number;
  50171. updatable?: boolean;
  50172. sideOrientation?: number;
  50173. frontUVs?: Vector4;
  50174. backUVs?: Vector4;
  50175. instance?: Mesh;
  50176. invertUV?: boolean;
  50177. uvs?: Vector2[];
  50178. colors?: Color4[];
  50179. }, scene?: Nullable<Scene>): Mesh;
  50180. }
  50181. }
  50182. declare module BABYLON {
  50183. /**
  50184. * Class containing static functions to help procedurally build meshes
  50185. */
  50186. export class ShapeBuilder {
  50187. /**
  50188. * 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.
  50189. * * 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.
  50190. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50191. * * 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.
  50192. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50193. * * 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
  50194. * * 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
  50195. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50196. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50197. * * 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
  50198. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50200. * @param name defines the name of the mesh
  50201. * @param options defines the options used to create the mesh
  50202. * @param scene defines the hosting scene
  50203. * @returns the extruded shape mesh
  50204. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50205. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50206. */
  50207. static ExtrudeShape(name: string, options: {
  50208. shape: Vector3[];
  50209. path: Vector3[];
  50210. scale?: number;
  50211. rotation?: number;
  50212. cap?: number;
  50213. updatable?: boolean;
  50214. sideOrientation?: number;
  50215. frontUVs?: Vector4;
  50216. backUVs?: Vector4;
  50217. instance?: Mesh;
  50218. invertUV?: boolean;
  50219. }, scene?: Nullable<Scene>): Mesh;
  50220. /**
  50221. * Creates an custom extruded shape mesh.
  50222. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50223. * * 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.
  50224. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50225. * * 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
  50226. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50227. * * 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
  50228. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50229. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50230. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50231. * * 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
  50232. * * 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
  50233. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50234. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50235. * * 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
  50236. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50238. * @param name defines the name of the mesh
  50239. * @param options defines the options used to create the mesh
  50240. * @param scene defines the hosting scene
  50241. * @returns the custom extruded shape mesh
  50242. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50243. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50244. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50245. */
  50246. static ExtrudeShapeCustom(name: string, options: {
  50247. shape: Vector3[];
  50248. path: Vector3[];
  50249. scaleFunction?: any;
  50250. rotationFunction?: any;
  50251. ribbonCloseArray?: boolean;
  50252. ribbonClosePath?: boolean;
  50253. cap?: number;
  50254. updatable?: boolean;
  50255. sideOrientation?: number;
  50256. frontUVs?: Vector4;
  50257. backUVs?: Vector4;
  50258. instance?: Mesh;
  50259. invertUV?: boolean;
  50260. }, scene?: Nullable<Scene>): Mesh;
  50261. private static _ExtrudeShapeGeneric;
  50262. }
  50263. }
  50264. declare module BABYLON {
  50265. /**
  50266. * AmmoJS Physics plugin
  50267. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50268. * @see https://github.com/kripken/ammo.js/
  50269. */
  50270. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50271. private _useDeltaForWorldStep;
  50272. /**
  50273. * Reference to the Ammo library
  50274. */
  50275. bjsAMMO: any;
  50276. /**
  50277. * Created ammoJS world which physics bodies are added to
  50278. */
  50279. world: any;
  50280. /**
  50281. * Name of the plugin
  50282. */
  50283. name: string;
  50284. private _timeStep;
  50285. private _fixedTimeStep;
  50286. private _maxSteps;
  50287. private _tmpQuaternion;
  50288. private _tmpAmmoTransform;
  50289. private _tmpAmmoQuaternion;
  50290. private _tmpAmmoConcreteContactResultCallback;
  50291. private _collisionConfiguration;
  50292. private _dispatcher;
  50293. private _overlappingPairCache;
  50294. private _solver;
  50295. private _softBodySolver;
  50296. private _tmpAmmoVectorA;
  50297. private _tmpAmmoVectorB;
  50298. private _tmpAmmoVectorC;
  50299. private _tmpAmmoVectorD;
  50300. private _tmpContactCallbackResult;
  50301. private _tmpAmmoVectorRCA;
  50302. private _tmpAmmoVectorRCB;
  50303. private _raycastResult;
  50304. private static readonly DISABLE_COLLISION_FLAG;
  50305. private static readonly KINEMATIC_FLAG;
  50306. private static readonly DISABLE_DEACTIVATION_FLAG;
  50307. /**
  50308. * Initializes the ammoJS plugin
  50309. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50310. * @param ammoInjection can be used to inject your own ammo reference
  50311. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  50312. */
  50313. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  50314. /**
  50315. * Sets the gravity of the physics world (m/(s^2))
  50316. * @param gravity Gravity to set
  50317. */
  50318. setGravity(gravity: Vector3): void;
  50319. /**
  50320. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50321. * @param timeStep timestep to use in seconds
  50322. */
  50323. setTimeStep(timeStep: number): void;
  50324. /**
  50325. * 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)
  50326. * @param fixedTimeStep fixedTimeStep to use in seconds
  50327. */
  50328. setFixedTimeStep(fixedTimeStep: number): void;
  50329. /**
  50330. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50331. * @param maxSteps the maximum number of steps by the physics engine per frame
  50332. */
  50333. setMaxSteps(maxSteps: number): void;
  50334. /**
  50335. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50336. * @returns the current timestep in seconds
  50337. */
  50338. getTimeStep(): number;
  50339. private _isImpostorInContact;
  50340. private _isImpostorPairInContact;
  50341. private _stepSimulation;
  50342. /**
  50343. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50344. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50345. * After the step the babylon meshes are set to the position of the physics imposters
  50346. * @param delta amount of time to step forward
  50347. * @param impostors array of imposters to update before/after the step
  50348. */
  50349. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50350. /**
  50351. * Update babylon mesh to match physics world object
  50352. * @param impostor imposter to match
  50353. */
  50354. private _afterSoftStep;
  50355. /**
  50356. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50357. * @param impostor imposter to match
  50358. */
  50359. private _ropeStep;
  50360. /**
  50361. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50362. * @param impostor imposter to match
  50363. */
  50364. private _softbodyOrClothStep;
  50365. private _tmpVector;
  50366. private _tmpMatrix;
  50367. /**
  50368. * Applies an impulse on the imposter
  50369. * @param impostor imposter to apply impulse to
  50370. * @param force amount of force to be applied to the imposter
  50371. * @param contactPoint the location to apply the impulse on the imposter
  50372. */
  50373. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50374. /**
  50375. * Applies a force on the imposter
  50376. * @param impostor imposter to apply force
  50377. * @param force amount of force to be applied to the imposter
  50378. * @param contactPoint the location to apply the force on the imposter
  50379. */
  50380. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50381. /**
  50382. * Creates a physics body using the plugin
  50383. * @param impostor the imposter to create the physics body on
  50384. */
  50385. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50386. /**
  50387. * Removes the physics body from the imposter and disposes of the body's memory
  50388. * @param impostor imposter to remove the physics body from
  50389. */
  50390. removePhysicsBody(impostor: PhysicsImpostor): void;
  50391. /**
  50392. * Generates a joint
  50393. * @param impostorJoint the imposter joint to create the joint with
  50394. */
  50395. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50396. /**
  50397. * Removes a joint
  50398. * @param impostorJoint the imposter joint to remove the joint from
  50399. */
  50400. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50401. private _addMeshVerts;
  50402. /**
  50403. * Initialise the soft body vertices to match its object's (mesh) vertices
  50404. * Softbody vertices (nodes) are in world space and to match this
  50405. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50406. * @param impostor to create the softbody for
  50407. */
  50408. private _softVertexData;
  50409. /**
  50410. * Create an impostor's soft body
  50411. * @param impostor to create the softbody for
  50412. */
  50413. private _createSoftbody;
  50414. /**
  50415. * Create cloth for an impostor
  50416. * @param impostor to create the softbody for
  50417. */
  50418. private _createCloth;
  50419. /**
  50420. * Create rope for an impostor
  50421. * @param impostor to create the softbody for
  50422. */
  50423. private _createRope;
  50424. private _addHullVerts;
  50425. private _createShape;
  50426. /**
  50427. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50428. * @param impostor imposter containing the physics body and babylon object
  50429. */
  50430. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50431. /**
  50432. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50433. * @param impostor imposter containing the physics body and babylon object
  50434. * @param newPosition new position
  50435. * @param newRotation new rotation
  50436. */
  50437. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50438. /**
  50439. * If this plugin is supported
  50440. * @returns true if its supported
  50441. */
  50442. isSupported(): boolean;
  50443. /**
  50444. * Sets the linear velocity of the physics body
  50445. * @param impostor imposter to set the velocity on
  50446. * @param velocity velocity to set
  50447. */
  50448. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50449. /**
  50450. * Sets the angular velocity of the physics body
  50451. * @param impostor imposter to set the velocity on
  50452. * @param velocity velocity to set
  50453. */
  50454. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50455. /**
  50456. * gets the linear velocity
  50457. * @param impostor imposter to get linear velocity from
  50458. * @returns linear velocity
  50459. */
  50460. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50461. /**
  50462. * gets the angular velocity
  50463. * @param impostor imposter to get angular velocity from
  50464. * @returns angular velocity
  50465. */
  50466. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50467. /**
  50468. * Sets the mass of physics body
  50469. * @param impostor imposter to set the mass on
  50470. * @param mass mass to set
  50471. */
  50472. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50473. /**
  50474. * Gets the mass of the physics body
  50475. * @param impostor imposter to get the mass from
  50476. * @returns mass
  50477. */
  50478. getBodyMass(impostor: PhysicsImpostor): number;
  50479. /**
  50480. * Gets friction of the impostor
  50481. * @param impostor impostor to get friction from
  50482. * @returns friction value
  50483. */
  50484. getBodyFriction(impostor: PhysicsImpostor): number;
  50485. /**
  50486. * Sets friction of the impostor
  50487. * @param impostor impostor to set friction on
  50488. * @param friction friction value
  50489. */
  50490. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50491. /**
  50492. * Gets restitution of the impostor
  50493. * @param impostor impostor to get restitution from
  50494. * @returns restitution value
  50495. */
  50496. getBodyRestitution(impostor: PhysicsImpostor): number;
  50497. /**
  50498. * Sets resitution of the impostor
  50499. * @param impostor impostor to set resitution on
  50500. * @param restitution resitution value
  50501. */
  50502. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50503. /**
  50504. * Gets pressure inside the impostor
  50505. * @param impostor impostor to get pressure from
  50506. * @returns pressure value
  50507. */
  50508. getBodyPressure(impostor: PhysicsImpostor): number;
  50509. /**
  50510. * Sets pressure inside a soft body impostor
  50511. * Cloth and rope must remain 0 pressure
  50512. * @param impostor impostor to set pressure on
  50513. * @param pressure pressure value
  50514. */
  50515. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50516. /**
  50517. * Gets stiffness of the impostor
  50518. * @param impostor impostor to get stiffness from
  50519. * @returns pressure value
  50520. */
  50521. getBodyStiffness(impostor: PhysicsImpostor): number;
  50522. /**
  50523. * Sets stiffness of the impostor
  50524. * @param impostor impostor to set stiffness on
  50525. * @param stiffness stiffness value from 0 to 1
  50526. */
  50527. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50528. /**
  50529. * Gets velocityIterations of the impostor
  50530. * @param impostor impostor to get velocity iterations from
  50531. * @returns velocityIterations value
  50532. */
  50533. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50534. /**
  50535. * Sets velocityIterations of the impostor
  50536. * @param impostor impostor to set velocity iterations on
  50537. * @param velocityIterations velocityIterations value
  50538. */
  50539. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50540. /**
  50541. * Gets positionIterations of the impostor
  50542. * @param impostor impostor to get position iterations from
  50543. * @returns positionIterations value
  50544. */
  50545. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50546. /**
  50547. * Sets positionIterations of the impostor
  50548. * @param impostor impostor to set position on
  50549. * @param positionIterations positionIterations value
  50550. */
  50551. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50552. /**
  50553. * Append an anchor to a cloth object
  50554. * @param impostor is the cloth impostor to add anchor to
  50555. * @param otherImpostor is the rigid impostor to anchor to
  50556. * @param width ratio across width from 0 to 1
  50557. * @param height ratio up height from 0 to 1
  50558. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50559. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50560. */
  50561. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50562. /**
  50563. * Append an hook to a rope object
  50564. * @param impostor is the rope impostor to add hook to
  50565. * @param otherImpostor is the rigid impostor to hook to
  50566. * @param length ratio along the rope from 0 to 1
  50567. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50568. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50569. */
  50570. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50571. /**
  50572. * Sleeps the physics body and stops it from being active
  50573. * @param impostor impostor to sleep
  50574. */
  50575. sleepBody(impostor: PhysicsImpostor): void;
  50576. /**
  50577. * Activates the physics body
  50578. * @param impostor impostor to activate
  50579. */
  50580. wakeUpBody(impostor: PhysicsImpostor): void;
  50581. /**
  50582. * Updates the distance parameters of the joint
  50583. * @param joint joint to update
  50584. * @param maxDistance maximum distance of the joint
  50585. * @param minDistance minimum distance of the joint
  50586. */
  50587. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50588. /**
  50589. * Sets a motor on the joint
  50590. * @param joint joint to set motor on
  50591. * @param speed speed of the motor
  50592. * @param maxForce maximum force of the motor
  50593. * @param motorIndex index of the motor
  50594. */
  50595. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50596. /**
  50597. * Sets the motors limit
  50598. * @param joint joint to set limit on
  50599. * @param upperLimit upper limit
  50600. * @param lowerLimit lower limit
  50601. */
  50602. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50603. /**
  50604. * Syncs the position and rotation of a mesh with the impostor
  50605. * @param mesh mesh to sync
  50606. * @param impostor impostor to update the mesh with
  50607. */
  50608. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50609. /**
  50610. * Gets the radius of the impostor
  50611. * @param impostor impostor to get radius from
  50612. * @returns the radius
  50613. */
  50614. getRadius(impostor: PhysicsImpostor): number;
  50615. /**
  50616. * Gets the box size of the impostor
  50617. * @param impostor impostor to get box size from
  50618. * @param result the resulting box size
  50619. */
  50620. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50621. /**
  50622. * Disposes of the impostor
  50623. */
  50624. dispose(): void;
  50625. /**
  50626. * Does a raycast in the physics world
  50627. * @param from when should the ray start?
  50628. * @param to when should the ray end?
  50629. * @returns PhysicsRaycastResult
  50630. */
  50631. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50632. }
  50633. }
  50634. declare module BABYLON {
  50635. interface AbstractScene {
  50636. /**
  50637. * The list of reflection probes added to the scene
  50638. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50639. */
  50640. reflectionProbes: Array<ReflectionProbe>;
  50641. /**
  50642. * Removes the given reflection probe from this scene.
  50643. * @param toRemove The reflection probe to remove
  50644. * @returns The index of the removed reflection probe
  50645. */
  50646. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50647. /**
  50648. * Adds the given reflection probe to this scene.
  50649. * @param newReflectionProbe The reflection probe to add
  50650. */
  50651. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  50652. }
  50653. /**
  50654. * Class used to generate realtime reflection / refraction cube textures
  50655. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50656. */
  50657. export class ReflectionProbe {
  50658. /** defines the name of the probe */
  50659. name: string;
  50660. private _scene;
  50661. private _renderTargetTexture;
  50662. private _projectionMatrix;
  50663. private _viewMatrix;
  50664. private _target;
  50665. private _add;
  50666. private _attachedMesh;
  50667. private _invertYAxis;
  50668. /** Gets or sets probe position (center of the cube map) */
  50669. position: Vector3;
  50670. /**
  50671. * Creates a new reflection probe
  50672. * @param name defines the name of the probe
  50673. * @param size defines the texture resolution (for each face)
  50674. * @param scene defines the hosting scene
  50675. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  50676. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  50677. */
  50678. constructor(
  50679. /** defines the name of the probe */
  50680. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  50681. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  50682. samples: number;
  50683. /** Gets or sets the refresh rate to use (on every frame by default) */
  50684. refreshRate: number;
  50685. /**
  50686. * Gets the hosting scene
  50687. * @returns a Scene
  50688. */
  50689. getScene(): Scene;
  50690. /** Gets the internal CubeTexture used to render to */
  50691. readonly cubeTexture: RenderTargetTexture;
  50692. /** Gets the list of meshes to render */
  50693. readonly renderList: Nullable<AbstractMesh[]>;
  50694. /**
  50695. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  50696. * @param mesh defines the mesh to attach to
  50697. */
  50698. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50699. /**
  50700. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  50701. * @param renderingGroupId The rendering group id corresponding to its index
  50702. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  50703. */
  50704. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  50705. /**
  50706. * Clean all associated resources
  50707. */
  50708. dispose(): void;
  50709. /**
  50710. * Converts the reflection probe information to a readable string for debug purpose.
  50711. * @param fullDetails Supports for multiple levels of logging within scene loading
  50712. * @returns the human readable reflection probe info
  50713. */
  50714. toString(fullDetails?: boolean): string;
  50715. /**
  50716. * Get the class name of the relfection probe.
  50717. * @returns "ReflectionProbe"
  50718. */
  50719. getClassName(): string;
  50720. /**
  50721. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  50722. * @returns The JSON representation of the texture
  50723. */
  50724. serialize(): any;
  50725. /**
  50726. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  50727. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  50728. * @param scene Define the scene the parsed reflection probe should be instantiated in
  50729. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  50730. * @returns The parsed reflection probe if successful
  50731. */
  50732. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  50733. }
  50734. }
  50735. declare module BABYLON {
  50736. /** @hidden */
  50737. export var _BabylonLoaderRegistered: boolean;
  50738. }
  50739. declare module BABYLON {
  50740. /**
  50741. * The Physically based simple base material of BJS.
  50742. *
  50743. * This enables better naming and convention enforcements on top of the pbrMaterial.
  50744. * It is used as the base class for both the specGloss and metalRough conventions.
  50745. */
  50746. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  50747. /**
  50748. * Number of Simultaneous lights allowed on the material.
  50749. */
  50750. maxSimultaneousLights: number;
  50751. /**
  50752. * If sets to true, disables all the lights affecting the material.
  50753. */
  50754. disableLighting: boolean;
  50755. /**
  50756. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  50757. */
  50758. environmentTexture: BaseTexture;
  50759. /**
  50760. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50761. */
  50762. invertNormalMapX: boolean;
  50763. /**
  50764. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50765. */
  50766. invertNormalMapY: boolean;
  50767. /**
  50768. * Normal map used in the model.
  50769. */
  50770. normalTexture: BaseTexture;
  50771. /**
  50772. * Emissivie color used to self-illuminate the model.
  50773. */
  50774. emissiveColor: Color3;
  50775. /**
  50776. * Emissivie texture used to self-illuminate the model.
  50777. */
  50778. emissiveTexture: BaseTexture;
  50779. /**
  50780. * Occlusion Channel Strenght.
  50781. */
  50782. occlusionStrength: number;
  50783. /**
  50784. * Occlusion Texture of the material (adding extra occlusion effects).
  50785. */
  50786. occlusionTexture: BaseTexture;
  50787. /**
  50788. * Defines the alpha limits in alpha test mode.
  50789. */
  50790. alphaCutOff: number;
  50791. /**
  50792. * Gets the current double sided mode.
  50793. */
  50794. /**
  50795. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50796. */
  50797. doubleSided: boolean;
  50798. /**
  50799. * Stores the pre-calculated light information of a mesh in a texture.
  50800. */
  50801. lightmapTexture: BaseTexture;
  50802. /**
  50803. * If true, the light map contains occlusion information instead of lighting info.
  50804. */
  50805. useLightmapAsShadowmap: boolean;
  50806. /**
  50807. * Instantiates a new PBRMaterial instance.
  50808. *
  50809. * @param name The material name
  50810. * @param scene The scene the material will be use in.
  50811. */
  50812. constructor(name: string, scene: Scene);
  50813. getClassName(): string;
  50814. }
  50815. }
  50816. declare module BABYLON {
  50817. /**
  50818. * The PBR material of BJS following the metal roughness convention.
  50819. *
  50820. * This fits to the PBR convention in the GLTF definition:
  50821. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50822. */
  50823. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50824. /**
  50825. * The base color has two different interpretations depending on the value of metalness.
  50826. * When the material is a metal, the base color is the specific measured reflectance value
  50827. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50828. * of the material.
  50829. */
  50830. baseColor: Color3;
  50831. /**
  50832. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50833. * well as opacity information in the alpha channel.
  50834. */
  50835. baseTexture: BaseTexture;
  50836. /**
  50837. * Specifies the metallic scalar value of the material.
  50838. * Can also be used to scale the metalness values of the metallic texture.
  50839. */
  50840. metallic: number;
  50841. /**
  50842. * Specifies the roughness scalar value of the material.
  50843. * Can also be used to scale the roughness values of the metallic texture.
  50844. */
  50845. roughness: number;
  50846. /**
  50847. * Texture containing both the metallic value in the B channel and the
  50848. * roughness value in the G channel to keep better precision.
  50849. */
  50850. metallicRoughnessTexture: BaseTexture;
  50851. /**
  50852. * Instantiates a new PBRMetalRoughnessMaterial instance.
  50853. *
  50854. * @param name The material name
  50855. * @param scene The scene the material will be use in.
  50856. */
  50857. constructor(name: string, scene: Scene);
  50858. /**
  50859. * Return the currrent class name of the material.
  50860. */
  50861. getClassName(): string;
  50862. /**
  50863. * Makes a duplicate of the current material.
  50864. * @param name - name to use for the new material.
  50865. */
  50866. clone(name: string): PBRMetallicRoughnessMaterial;
  50867. /**
  50868. * Serialize the material to a parsable JSON object.
  50869. */
  50870. serialize(): any;
  50871. /**
  50872. * Parses a JSON object correponding to the serialize function.
  50873. */
  50874. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  50875. }
  50876. }
  50877. declare module BABYLON {
  50878. /**
  50879. * The PBR material of BJS following the specular glossiness convention.
  50880. *
  50881. * This fits to the PBR convention in the GLTF definition:
  50882. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  50883. */
  50884. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  50885. /**
  50886. * Specifies the diffuse color of the material.
  50887. */
  50888. diffuseColor: Color3;
  50889. /**
  50890. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  50891. * channel.
  50892. */
  50893. diffuseTexture: BaseTexture;
  50894. /**
  50895. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  50896. */
  50897. specularColor: Color3;
  50898. /**
  50899. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  50900. */
  50901. glossiness: number;
  50902. /**
  50903. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  50904. */
  50905. specularGlossinessTexture: BaseTexture;
  50906. /**
  50907. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  50908. *
  50909. * @param name The material name
  50910. * @param scene The scene the material will be use in.
  50911. */
  50912. constructor(name: string, scene: Scene);
  50913. /**
  50914. * Return the currrent class name of the material.
  50915. */
  50916. getClassName(): string;
  50917. /**
  50918. * Makes a duplicate of the current material.
  50919. * @param name - name to use for the new material.
  50920. */
  50921. clone(name: string): PBRSpecularGlossinessMaterial;
  50922. /**
  50923. * Serialize the material to a parsable JSON object.
  50924. */
  50925. serialize(): any;
  50926. /**
  50927. * Parses a JSON object correponding to the serialize function.
  50928. */
  50929. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50930. }
  50931. }
  50932. declare module BABYLON {
  50933. /**
  50934. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50935. * It can help converting any input color in a desired output one. This can then be used to create effects
  50936. * from sepia, black and white to sixties or futuristic rendering...
  50937. *
  50938. * The only supported format is currently 3dl.
  50939. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50940. */
  50941. export class ColorGradingTexture extends BaseTexture {
  50942. /**
  50943. * The current texture matrix. (will always be identity in color grading texture)
  50944. */
  50945. private _textureMatrix;
  50946. /**
  50947. * The texture URL.
  50948. */
  50949. url: string;
  50950. /**
  50951. * Empty line regex stored for GC.
  50952. */
  50953. private static _noneEmptyLineRegex;
  50954. private _engine;
  50955. /**
  50956. * Instantiates a ColorGradingTexture from the following parameters.
  50957. *
  50958. * @param url The location of the color gradind data (currently only supporting 3dl)
  50959. * @param scene The scene the texture will be used in
  50960. */
  50961. constructor(url: string, scene: Scene);
  50962. /**
  50963. * Returns the texture matrix used in most of the material.
  50964. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  50965. */
  50966. getTextureMatrix(): Matrix;
  50967. /**
  50968. * Occurs when the file being loaded is a .3dl LUT file.
  50969. */
  50970. private load3dlTexture;
  50971. /**
  50972. * Starts the loading process of the texture.
  50973. */
  50974. private loadTexture;
  50975. /**
  50976. * Clones the color gradind texture.
  50977. */
  50978. clone(): ColorGradingTexture;
  50979. /**
  50980. * Called during delayed load for textures.
  50981. */
  50982. delayLoad(): void;
  50983. /**
  50984. * Parses a color grading texture serialized by Babylon.
  50985. * @param parsedTexture The texture information being parsedTexture
  50986. * @param scene The scene to load the texture in
  50987. * @param rootUrl The root url of the data assets to load
  50988. * @return A color gradind texture
  50989. */
  50990. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  50991. /**
  50992. * Serializes the LUT texture to json format.
  50993. */
  50994. serialize(): any;
  50995. }
  50996. }
  50997. declare module BABYLON {
  50998. /**
  50999. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51000. */
  51001. export class EquiRectangularCubeTexture extends BaseTexture {
  51002. /** The six faces of the cube. */
  51003. private static _FacesMapping;
  51004. private _noMipmap;
  51005. private _onLoad;
  51006. private _onError;
  51007. /** The size of the cubemap. */
  51008. private _size;
  51009. /** The buffer of the image. */
  51010. private _buffer;
  51011. /** The width of the input image. */
  51012. private _width;
  51013. /** The height of the input image. */
  51014. private _height;
  51015. /** The URL to the image. */
  51016. url: string;
  51017. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51018. coordinatesMode: number;
  51019. /**
  51020. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51021. * @param url The location of the image
  51022. * @param scene The scene the texture will be used in
  51023. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51024. * @param noMipmap Forces to not generate the mipmap if true
  51025. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51026. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51027. * @param onLoad — defines a callback called when texture is loaded
  51028. * @param onError — defines a callback called if there is an error
  51029. */
  51030. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51031. /**
  51032. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51033. */
  51034. private loadImage;
  51035. /**
  51036. * Convert the image buffer into a cubemap and create a CubeTexture.
  51037. */
  51038. private loadTexture;
  51039. /**
  51040. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51041. * @param buffer The ArrayBuffer that should be converted.
  51042. * @returns The buffer as Float32Array.
  51043. */
  51044. private getFloat32ArrayFromArrayBuffer;
  51045. /**
  51046. * Get the current class name of the texture useful for serialization or dynamic coding.
  51047. * @returns "EquiRectangularCubeTexture"
  51048. */
  51049. getClassName(): string;
  51050. /**
  51051. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51052. * @returns A clone of the current EquiRectangularCubeTexture.
  51053. */
  51054. clone(): EquiRectangularCubeTexture;
  51055. }
  51056. }
  51057. declare module BABYLON {
  51058. /**
  51059. * Based on jsTGALoader - Javascript loader for TGA file
  51060. * By Vincent Thibault
  51061. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51062. */
  51063. export class TGATools {
  51064. private static _TYPE_INDEXED;
  51065. private static _TYPE_RGB;
  51066. private static _TYPE_GREY;
  51067. private static _TYPE_RLE_INDEXED;
  51068. private static _TYPE_RLE_RGB;
  51069. private static _TYPE_RLE_GREY;
  51070. private static _ORIGIN_MASK;
  51071. private static _ORIGIN_SHIFT;
  51072. private static _ORIGIN_BL;
  51073. private static _ORIGIN_BR;
  51074. private static _ORIGIN_UL;
  51075. private static _ORIGIN_UR;
  51076. /**
  51077. * Gets the header of a TGA file
  51078. * @param data defines the TGA data
  51079. * @returns the header
  51080. */
  51081. static GetTGAHeader(data: Uint8Array): any;
  51082. /**
  51083. * Uploads TGA content to a Babylon Texture
  51084. * @hidden
  51085. */
  51086. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51087. /** @hidden */
  51088. 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;
  51089. /** @hidden */
  51090. 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;
  51091. /** @hidden */
  51092. 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;
  51093. /** @hidden */
  51094. 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;
  51095. /** @hidden */
  51096. 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;
  51097. /** @hidden */
  51098. 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;
  51099. }
  51100. }
  51101. declare module BABYLON {
  51102. /**
  51103. * Implementation of the TGA Texture Loader.
  51104. * @hidden
  51105. */
  51106. export class _TGATextureLoader implements IInternalTextureLoader {
  51107. /**
  51108. * Defines wether the loader supports cascade loading the different faces.
  51109. */
  51110. readonly supportCascades: boolean;
  51111. /**
  51112. * This returns if the loader support the current file information.
  51113. * @param extension defines the file extension of the file being loaded
  51114. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51115. * @param fallback defines the fallback internal texture if any
  51116. * @param isBase64 defines whether the texture is encoded as a base64
  51117. * @param isBuffer defines whether the texture data are stored as a buffer
  51118. * @returns true if the loader can load the specified file
  51119. */
  51120. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51121. /**
  51122. * Transform the url before loading if required.
  51123. * @param rootUrl the url of the texture
  51124. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51125. * @returns the transformed texture
  51126. */
  51127. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51128. /**
  51129. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51130. * @param rootUrl the url of the texture
  51131. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51132. * @returns the fallback texture
  51133. */
  51134. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51135. /**
  51136. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51137. * @param data contains the texture data
  51138. * @param texture defines the BabylonJS internal texture
  51139. * @param createPolynomials will be true if polynomials have been requested
  51140. * @param onLoad defines the callback to trigger once the texture is ready
  51141. * @param onError defines the callback to trigger in case of error
  51142. */
  51143. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51144. /**
  51145. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51146. * @param data contains the texture data
  51147. * @param texture defines the BabylonJS internal texture
  51148. * @param callback defines the method to call once ready to upload
  51149. */
  51150. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51151. }
  51152. }
  51153. declare module BABYLON {
  51154. /**
  51155. * Info about the .basis files
  51156. */
  51157. class BasisFileInfo {
  51158. /**
  51159. * If the file has alpha
  51160. */
  51161. hasAlpha: boolean;
  51162. /**
  51163. * Info about each image of the basis file
  51164. */
  51165. images: Array<{
  51166. levels: Array<{
  51167. width: number;
  51168. height: number;
  51169. transcodedPixels: ArrayBufferView;
  51170. }>;
  51171. }>;
  51172. }
  51173. /**
  51174. * Result of transcoding a basis file
  51175. */
  51176. class TranscodeResult {
  51177. /**
  51178. * Info about the .basis file
  51179. */
  51180. fileInfo: BasisFileInfo;
  51181. /**
  51182. * Format to use when loading the file
  51183. */
  51184. format: number;
  51185. }
  51186. /**
  51187. * Configuration options for the Basis transcoder
  51188. */
  51189. export class BasisTranscodeConfiguration {
  51190. /**
  51191. * Supported compression formats used to determine the supported output format of the transcoder
  51192. */
  51193. supportedCompressionFormats?: {
  51194. /**
  51195. * etc1 compression format
  51196. */
  51197. etc1?: boolean;
  51198. /**
  51199. * s3tc compression format
  51200. */
  51201. s3tc?: boolean;
  51202. /**
  51203. * pvrtc compression format
  51204. */
  51205. pvrtc?: boolean;
  51206. /**
  51207. * etc2 compression format
  51208. */
  51209. etc2?: boolean;
  51210. };
  51211. /**
  51212. * If mipmap levels should be loaded for transcoded images (Default: true)
  51213. */
  51214. loadMipmapLevels?: boolean;
  51215. /**
  51216. * Index of a single image to load (Default: all images)
  51217. */
  51218. loadSingleImage?: number;
  51219. }
  51220. /**
  51221. * Used to load .Basis files
  51222. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  51223. */
  51224. export class BasisTools {
  51225. private static _IgnoreSupportedFormats;
  51226. /**
  51227. * URL to use when loading the basis transcoder
  51228. */
  51229. static JSModuleURL: string;
  51230. /**
  51231. * URL to use when loading the wasm module for the transcoder
  51232. */
  51233. static WasmModuleURL: string;
  51234. /**
  51235. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  51236. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  51237. * @returns internal format corresponding to the Basis format
  51238. */
  51239. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  51240. private static _WorkerPromise;
  51241. private static _Worker;
  51242. private static _actionId;
  51243. private static _CreateWorkerAsync;
  51244. /**
  51245. * Transcodes a loaded image file to compressed pixel data
  51246. * @param imageData image data to transcode
  51247. * @param config configuration options for the transcoding
  51248. * @returns a promise resulting in the transcoded image
  51249. */
  51250. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  51251. /**
  51252. * Loads a texture from the transcode result
  51253. * @param texture texture load to
  51254. * @param transcodeResult the result of transcoding the basis file to load from
  51255. */
  51256. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  51257. }
  51258. }
  51259. declare module BABYLON {
  51260. /**
  51261. * Loader for .basis file format
  51262. */
  51263. export class _BasisTextureLoader implements IInternalTextureLoader {
  51264. /**
  51265. * Defines whether the loader supports cascade loading the different faces.
  51266. */
  51267. readonly supportCascades: boolean;
  51268. /**
  51269. * This returns if the loader support the current file information.
  51270. * @param extension defines the file extension of the file being loaded
  51271. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51272. * @param fallback defines the fallback internal texture if any
  51273. * @param isBase64 defines whether the texture is encoded as a base64
  51274. * @param isBuffer defines whether the texture data are stored as a buffer
  51275. * @returns true if the loader can load the specified file
  51276. */
  51277. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51278. /**
  51279. * Transform the url before loading if required.
  51280. * @param rootUrl the url of the texture
  51281. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51282. * @returns the transformed texture
  51283. */
  51284. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51285. /**
  51286. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51287. * @param rootUrl the url of the texture
  51288. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51289. * @returns the fallback texture
  51290. */
  51291. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51292. /**
  51293. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  51294. * @param data contains the texture data
  51295. * @param texture defines the BabylonJS internal texture
  51296. * @param createPolynomials will be true if polynomials have been requested
  51297. * @param onLoad defines the callback to trigger once the texture is ready
  51298. * @param onError defines the callback to trigger in case of error
  51299. */
  51300. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51301. /**
  51302. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51303. * @param data contains the texture data
  51304. * @param texture defines the BabylonJS internal texture
  51305. * @param callback defines the method to call once ready to upload
  51306. */
  51307. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51308. }
  51309. }
  51310. declare module BABYLON {
  51311. /**
  51312. * 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.
  51313. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51314. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51315. */
  51316. export class CustomProceduralTexture extends ProceduralTexture {
  51317. private _animate;
  51318. private _time;
  51319. private _config;
  51320. private _texturePath;
  51321. /**
  51322. * Instantiates a new Custom Procedural Texture.
  51323. * 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.
  51324. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51325. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51326. * @param name Define the name of the texture
  51327. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51328. * @param size Define the size of the texture to create
  51329. * @param scene Define the scene the texture belongs to
  51330. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51331. * @param generateMipMaps Define if the texture should creates mip maps or not
  51332. */
  51333. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51334. private _loadJson;
  51335. /**
  51336. * Is the texture ready to be used ? (rendered at least once)
  51337. * @returns true if ready, otherwise, false.
  51338. */
  51339. isReady(): boolean;
  51340. /**
  51341. * Render the texture to its associated render target.
  51342. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51343. */
  51344. render(useCameraPostProcess?: boolean): void;
  51345. /**
  51346. * Update the list of dependant textures samplers in the shader.
  51347. */
  51348. updateTextures(): void;
  51349. /**
  51350. * Update the uniform values of the procedural texture in the shader.
  51351. */
  51352. updateShaderUniforms(): void;
  51353. /**
  51354. * Define if the texture animates or not.
  51355. */
  51356. animate: boolean;
  51357. }
  51358. }
  51359. declare module BABYLON {
  51360. /** @hidden */
  51361. export var noisePixelShader: {
  51362. name: string;
  51363. shader: string;
  51364. };
  51365. }
  51366. declare module BABYLON {
  51367. /**
  51368. * Class used to generate noise procedural textures
  51369. */
  51370. export class NoiseProceduralTexture extends ProceduralTexture {
  51371. private _time;
  51372. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51373. brightness: number;
  51374. /** Defines the number of octaves to process */
  51375. octaves: number;
  51376. /** Defines the level of persistence (0.8 by default) */
  51377. persistence: number;
  51378. /** Gets or sets animation speed factor (default is 1) */
  51379. animationSpeedFactor: number;
  51380. /**
  51381. * Creates a new NoiseProceduralTexture
  51382. * @param name defines the name fo the texture
  51383. * @param size defines the size of the texture (default is 256)
  51384. * @param scene defines the hosting scene
  51385. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51386. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51387. */
  51388. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51389. private _updateShaderUniforms;
  51390. protected _getDefines(): string;
  51391. /** Generate the current state of the procedural texture */
  51392. render(useCameraPostProcess?: boolean): void;
  51393. /**
  51394. * Serializes this noise procedural texture
  51395. * @returns a serialized noise procedural texture object
  51396. */
  51397. serialize(): any;
  51398. /**
  51399. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51400. * @param parsedTexture defines parsed texture data
  51401. * @param scene defines the current scene
  51402. * @param rootUrl defines the root URL containing noise procedural texture information
  51403. * @returns a parsed NoiseProceduralTexture
  51404. */
  51405. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51406. }
  51407. }
  51408. declare module BABYLON {
  51409. /**
  51410. * Raw cube texture where the raw buffers are passed in
  51411. */
  51412. export class RawCubeTexture extends CubeTexture {
  51413. /**
  51414. * Creates a cube texture where the raw buffers are passed in.
  51415. * @param scene defines the scene the texture is attached to
  51416. * @param data defines the array of data to use to create each face
  51417. * @param size defines the size of the textures
  51418. * @param format defines the format of the data
  51419. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51420. * @param generateMipMaps defines if the engine should generate the mip levels
  51421. * @param invertY defines if data must be stored with Y axis inverted
  51422. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51423. * @param compression defines the compression used (null by default)
  51424. */
  51425. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51426. /**
  51427. * Updates the raw cube texture.
  51428. * @param data defines the data to store
  51429. * @param format defines the data format
  51430. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51431. * @param invertY defines if data must be stored with Y axis inverted
  51432. * @param compression defines the compression used (null by default)
  51433. * @param level defines which level of the texture to update
  51434. */
  51435. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51436. /**
  51437. * Updates a raw cube texture with RGBD encoded data.
  51438. * @param data defines the array of data [mipmap][face] to use to create each face
  51439. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51440. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51441. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51442. * @returns a promsie that resolves when the operation is complete
  51443. */
  51444. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51445. /**
  51446. * Clones the raw cube texture.
  51447. * @return a new cube texture
  51448. */
  51449. clone(): CubeTexture;
  51450. /** @hidden */
  51451. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51452. }
  51453. }
  51454. declare module BABYLON {
  51455. /**
  51456. * Class used to store 3D textures containing user data
  51457. */
  51458. export class RawTexture3D extends Texture {
  51459. /** Gets or sets the texture format to use */
  51460. format: number;
  51461. private _engine;
  51462. /**
  51463. * Create a new RawTexture3D
  51464. * @param data defines the data of the texture
  51465. * @param width defines the width of the texture
  51466. * @param height defines the height of the texture
  51467. * @param depth defines the depth of the texture
  51468. * @param format defines the texture format to use
  51469. * @param scene defines the hosting scene
  51470. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51471. * @param invertY defines if texture must be stored with Y axis inverted
  51472. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51473. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51474. */
  51475. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51476. /** Gets or sets the texture format to use */
  51477. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51478. /**
  51479. * Update the texture with new data
  51480. * @param data defines the data to store in the texture
  51481. */
  51482. update(data: ArrayBufferView): void;
  51483. }
  51484. }
  51485. declare module BABYLON {
  51486. /**
  51487. * Creates a refraction texture used by refraction channel of the standard material.
  51488. * It is like a mirror but to see through a material.
  51489. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51490. */
  51491. export class RefractionTexture extends RenderTargetTexture {
  51492. /**
  51493. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51494. * 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.
  51495. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51496. */
  51497. refractionPlane: Plane;
  51498. /**
  51499. * Define how deep under the surface we should see.
  51500. */
  51501. depth: number;
  51502. /**
  51503. * Creates a refraction texture used by refraction channel of the standard material.
  51504. * It is like a mirror but to see through a material.
  51505. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51506. * @param name Define the texture name
  51507. * @param size Define the size of the underlying texture
  51508. * @param scene Define the scene the refraction belongs to
  51509. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51510. */
  51511. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51512. /**
  51513. * Clone the refraction texture.
  51514. * @returns the cloned texture
  51515. */
  51516. clone(): RefractionTexture;
  51517. /**
  51518. * Serialize the texture to a JSON representation you could use in Parse later on
  51519. * @returns the serialized JSON representation
  51520. */
  51521. serialize(): any;
  51522. }
  51523. }
  51524. declare module BABYLON {
  51525. /**
  51526. * Defines the options related to the creation of an HtmlElementTexture
  51527. */
  51528. export interface IHtmlElementTextureOptions {
  51529. /**
  51530. * Defines wether mip maps should be created or not.
  51531. */
  51532. generateMipMaps?: boolean;
  51533. /**
  51534. * Defines the sampling mode of the texture.
  51535. */
  51536. samplingMode?: number;
  51537. /**
  51538. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51539. */
  51540. engine: Nullable<Engine>;
  51541. /**
  51542. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51543. */
  51544. scene: Nullable<Scene>;
  51545. }
  51546. /**
  51547. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51548. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51549. * is automatically managed.
  51550. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51551. * in your application.
  51552. *
  51553. * As the update is not automatic, you need to call them manually.
  51554. */
  51555. export class HtmlElementTexture extends BaseTexture {
  51556. /**
  51557. * The texture URL.
  51558. */
  51559. element: HTMLVideoElement | HTMLCanvasElement;
  51560. private static readonly DefaultOptions;
  51561. private _textureMatrix;
  51562. private _engine;
  51563. private _isVideo;
  51564. private _generateMipMaps;
  51565. private _samplingMode;
  51566. /**
  51567. * Instantiates a HtmlElementTexture from the following parameters.
  51568. *
  51569. * @param name Defines the name of the texture
  51570. * @param element Defines the video or canvas the texture is filled with
  51571. * @param options Defines the other none mandatory texture creation options
  51572. */
  51573. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51574. private _createInternalTexture;
  51575. /**
  51576. * Returns the texture matrix used in most of the material.
  51577. */
  51578. getTextureMatrix(): Matrix;
  51579. /**
  51580. * Updates the content of the texture.
  51581. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51582. */
  51583. update(invertY?: Nullable<boolean>): void;
  51584. }
  51585. }
  51586. declare module BABYLON {
  51587. /**
  51588. * Enum used to define the target of a block
  51589. */
  51590. export enum NodeMaterialBlockTargets {
  51591. /** Vertex shader */
  51592. Vertex = 1,
  51593. /** Fragment shader */
  51594. Fragment = 2,
  51595. /** Neutral */
  51596. Neutral = 4,
  51597. /** Vertex and Fragment */
  51598. VertexAndFragment = 3
  51599. }
  51600. }
  51601. declare module BABYLON {
  51602. /**
  51603. * Defines the kind of connection point for node based material
  51604. */
  51605. export enum NodeMaterialBlockConnectionPointTypes {
  51606. /** Float */
  51607. Float = 1,
  51608. /** Int */
  51609. Int = 2,
  51610. /** Vector2 */
  51611. Vector2 = 4,
  51612. /** Vector3 */
  51613. Vector3 = 8,
  51614. /** Vector4 */
  51615. Vector4 = 16,
  51616. /** Color3 */
  51617. Color3 = 32,
  51618. /** Color4 */
  51619. Color4 = 64,
  51620. /** Matrix */
  51621. Matrix = 128,
  51622. /** Detect type based on connection */
  51623. AutoDetect = 1024,
  51624. /** Output type that will be defined by input type */
  51625. BasedOnInput = 2048
  51626. }
  51627. }
  51628. declare module BABYLON {
  51629. /**
  51630. * Root class for all node material optimizers
  51631. */
  51632. export class NodeMaterialOptimizer {
  51633. /**
  51634. * Function used to optimize a NodeMaterial graph
  51635. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  51636. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  51637. */
  51638. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  51639. }
  51640. }
  51641. declare module BABYLON {
  51642. /**
  51643. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  51644. */
  51645. export class TransformBlock extends NodeMaterialBlock {
  51646. /**
  51647. * Defines the value to use to complement W value to transform it to a Vector4
  51648. */
  51649. complementW: number;
  51650. /**
  51651. * Defines the value to use to complement z value to transform it to a Vector4
  51652. */
  51653. complementZ: number;
  51654. /**
  51655. * Creates a new TransformBlock
  51656. * @param name defines the block name
  51657. */
  51658. constructor(name: string);
  51659. /**
  51660. * Gets the current class name
  51661. * @returns the class name
  51662. */
  51663. getClassName(): string;
  51664. /**
  51665. * Gets the vector input
  51666. */
  51667. readonly vector: NodeMaterialConnectionPoint;
  51668. /**
  51669. * Gets the output component
  51670. */
  51671. readonly output: NodeMaterialConnectionPoint;
  51672. /**
  51673. * Gets the matrix transform input
  51674. */
  51675. readonly transform: NodeMaterialConnectionPoint;
  51676. protected _buildBlock(state: NodeMaterialBuildState): this;
  51677. serialize(): any;
  51678. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51679. }
  51680. }
  51681. declare module BABYLON {
  51682. /**
  51683. * Block used to output the vertex position
  51684. */
  51685. export class VertexOutputBlock extends NodeMaterialBlock {
  51686. /**
  51687. * Creates a new VertexOutputBlock
  51688. * @param name defines the block name
  51689. */
  51690. constructor(name: string);
  51691. /**
  51692. * Gets the current class name
  51693. * @returns the class name
  51694. */
  51695. getClassName(): string;
  51696. /**
  51697. * Gets the vector input component
  51698. */
  51699. readonly vector: NodeMaterialConnectionPoint;
  51700. protected _buildBlock(state: NodeMaterialBuildState): this;
  51701. }
  51702. }
  51703. declare module BABYLON {
  51704. /**
  51705. * Block used to output the final color
  51706. */
  51707. export class FragmentOutputBlock extends NodeMaterialBlock {
  51708. /**
  51709. * Create a new FragmentOutputBlock
  51710. * @param name defines the block name
  51711. */
  51712. constructor(name: string);
  51713. /**
  51714. * Gets the current class name
  51715. * @returns the class name
  51716. */
  51717. getClassName(): string;
  51718. /**
  51719. * Gets the rgba input component
  51720. */
  51721. readonly rgba: NodeMaterialConnectionPoint;
  51722. /**
  51723. * Gets the rgb input component
  51724. */
  51725. readonly rgb: NodeMaterialConnectionPoint;
  51726. /**
  51727. * Gets the a input component
  51728. */
  51729. readonly a: NodeMaterialConnectionPoint;
  51730. protected _buildBlock(state: NodeMaterialBuildState): this;
  51731. }
  51732. }
  51733. declare module BABYLON {
  51734. /**
  51735. * Interface used to configure the node material editor
  51736. */
  51737. export interface INodeMaterialEditorOptions {
  51738. /** Define the URl to load node editor script */
  51739. editorURL?: string;
  51740. }
  51741. /** @hidden */
  51742. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  51743. /** BONES */
  51744. NUM_BONE_INFLUENCERS: number;
  51745. BonesPerMesh: number;
  51746. BONETEXTURE: boolean;
  51747. /** MORPH TARGETS */
  51748. MORPHTARGETS: boolean;
  51749. MORPHTARGETS_NORMAL: boolean;
  51750. MORPHTARGETS_TANGENT: boolean;
  51751. MORPHTARGETS_UV: boolean;
  51752. NUM_MORPH_INFLUENCERS: number;
  51753. /** IMAGE PROCESSING */
  51754. IMAGEPROCESSING: boolean;
  51755. VIGNETTE: boolean;
  51756. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51757. VIGNETTEBLENDMODEOPAQUE: boolean;
  51758. TONEMAPPING: boolean;
  51759. TONEMAPPING_ACES: boolean;
  51760. CONTRAST: boolean;
  51761. EXPOSURE: boolean;
  51762. COLORCURVES: boolean;
  51763. COLORGRADING: boolean;
  51764. COLORGRADING3D: boolean;
  51765. SAMPLER3DGREENDEPTH: boolean;
  51766. SAMPLER3DBGRMAP: boolean;
  51767. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51768. constructor();
  51769. setValue(name: string, value: boolean): void;
  51770. }
  51771. /**
  51772. * Class used to configure NodeMaterial
  51773. */
  51774. export interface INodeMaterialOptions {
  51775. /**
  51776. * Defines if blocks should emit comments
  51777. */
  51778. emitComments: boolean;
  51779. }
  51780. /**
  51781. * Class used to create a node based material built by assembling shader blocks
  51782. */
  51783. export class NodeMaterial extends PushMaterial {
  51784. private static _BuildIdGenerator;
  51785. private _options;
  51786. private _vertexCompilationState;
  51787. private _fragmentCompilationState;
  51788. private _sharedData;
  51789. private _buildId;
  51790. private _buildWasSuccessful;
  51791. private _cachedWorldViewMatrix;
  51792. private _cachedWorldViewProjectionMatrix;
  51793. private _optimizers;
  51794. private _animationFrame;
  51795. /** Define the URl to load node editor script */
  51796. static EditorURL: string;
  51797. private BJSNODEMATERIALEDITOR;
  51798. /** Get the inspector from bundle or global */
  51799. private _getGlobalNodeMaterialEditor;
  51800. /**
  51801. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  51802. */
  51803. ignoreAlpha: boolean;
  51804. /**
  51805. * Defines the maximum number of lights that can be used in the material
  51806. */
  51807. maxSimultaneousLights: number;
  51808. /**
  51809. * Observable raised when the material is built
  51810. */
  51811. onBuildObservable: Observable<NodeMaterial>;
  51812. /**
  51813. * Gets or sets the root nodes of the material vertex shader
  51814. */
  51815. _vertexOutputNodes: NodeMaterialBlock[];
  51816. /**
  51817. * Gets or sets the root nodes of the material fragment (pixel) shader
  51818. */
  51819. _fragmentOutputNodes: NodeMaterialBlock[];
  51820. /** Gets or sets options to control the node material overall behavior */
  51821. options: INodeMaterialOptions;
  51822. /**
  51823. * Default configuration related to image processing available in the standard Material.
  51824. */
  51825. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51826. /**
  51827. * Gets the image processing configuration used either in this material.
  51828. */
  51829. /**
  51830. * Sets the Default image processing configuration used either in the this material.
  51831. *
  51832. * If sets to null, the scene one is in use.
  51833. */
  51834. imageProcessingConfiguration: ImageProcessingConfiguration;
  51835. /**
  51836. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  51837. */
  51838. attachedBlocks: NodeMaterialBlock[];
  51839. /**
  51840. * Create a new node based material
  51841. * @param name defines the material name
  51842. * @param scene defines the hosting scene
  51843. * @param options defines creation option
  51844. */
  51845. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  51846. /**
  51847. * Gets the current class name of the material e.g. "NodeMaterial"
  51848. * @returns the class name
  51849. */
  51850. getClassName(): string;
  51851. /**
  51852. * Keep track of the image processing observer to allow dispose and replace.
  51853. */
  51854. private _imageProcessingObserver;
  51855. /**
  51856. * Attaches a new image processing configuration to the Standard Material.
  51857. * @param configuration
  51858. */
  51859. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51860. /**
  51861. * Get a block by its name
  51862. * @param name defines the name of the block to retrieve
  51863. * @returns the required block or null if not found
  51864. */
  51865. getBlockByName(name: string): NodeMaterialBlock | null;
  51866. /**
  51867. * Gets the list of input blocks attached to this material
  51868. * @returns an array of InputBlocks
  51869. */
  51870. getInputBlocks(): InputBlock[];
  51871. /**
  51872. * Adds a new optimizer to the list of optimizers
  51873. * @param optimizer defines the optimizers to add
  51874. * @returns the current material
  51875. */
  51876. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51877. /**
  51878. * Remove an optimizer from the list of optimizers
  51879. * @param optimizer defines the optimizers to remove
  51880. * @returns the current material
  51881. */
  51882. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51883. /**
  51884. * Add a new block to the list of output nodes
  51885. * @param node defines the node to add
  51886. * @returns the current material
  51887. */
  51888. addOutputNode(node: NodeMaterialBlock): this;
  51889. /**
  51890. * Remove a block from the list of root nodes
  51891. * @param node defines the node to remove
  51892. * @returns the current material
  51893. */
  51894. removeOutputNode(node: NodeMaterialBlock): this;
  51895. private _addVertexOutputNode;
  51896. private _removeVertexOutputNode;
  51897. private _addFragmentOutputNode;
  51898. private _removeFragmentOutputNode;
  51899. /**
  51900. * Specifies if the material will require alpha blending
  51901. * @returns a boolean specifying if alpha blending is needed
  51902. */
  51903. needAlphaBlending(): boolean;
  51904. /**
  51905. * Specifies if this material should be rendered in alpha test mode
  51906. * @returns a boolean specifying if an alpha test is needed.
  51907. */
  51908. needAlphaTesting(): boolean;
  51909. private _initializeBlock;
  51910. private _resetDualBlocks;
  51911. /**
  51912. * Build the material and generates the inner effect
  51913. * @param verbose defines if the build should log activity
  51914. */
  51915. build(verbose?: boolean): void;
  51916. /**
  51917. * Runs an otpimization phase to try to improve the shader code
  51918. */
  51919. optimize(): void;
  51920. private _prepareDefinesForAttributes;
  51921. /**
  51922. * Get if the submesh is ready to be used and all its information available.
  51923. * Child classes can use it to update shaders
  51924. * @param mesh defines the mesh to check
  51925. * @param subMesh defines which submesh to check
  51926. * @param useInstances specifies that instances should be used
  51927. * @returns a boolean indicating that the submesh is ready or not
  51928. */
  51929. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51930. /**
  51931. * Get a string representing the shaders built by the current node graph
  51932. */
  51933. readonly compiledShaders: string;
  51934. /**
  51935. * Binds the world matrix to the material
  51936. * @param world defines the world transformation matrix
  51937. */
  51938. bindOnlyWorldMatrix(world: Matrix): void;
  51939. /**
  51940. * Binds the submesh to this material by preparing the effect and shader to draw
  51941. * @param world defines the world transformation matrix
  51942. * @param mesh defines the mesh containing the submesh
  51943. * @param subMesh defines the submesh to bind the material to
  51944. */
  51945. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51946. /**
  51947. * Gets the active textures from the material
  51948. * @returns an array of textures
  51949. */
  51950. getActiveTextures(): BaseTexture[];
  51951. /**
  51952. * Specifies if the material uses a texture
  51953. * @param texture defines the texture to check against the material
  51954. * @returns a boolean specifying if the material uses the texture
  51955. */
  51956. hasTexture(texture: BaseTexture): boolean;
  51957. /**
  51958. * Disposes the material
  51959. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  51960. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  51961. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  51962. */
  51963. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  51964. /** Creates the node editor window. */
  51965. private _createNodeEditor;
  51966. /**
  51967. * Launch the node material editor
  51968. * @param config Define the configuration of the editor
  51969. * @return a promise fulfilled when the node editor is visible
  51970. */
  51971. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  51972. /**
  51973. * Clear the current material
  51974. */
  51975. clear(): void;
  51976. /**
  51977. * Clear the current material and set it to a default state
  51978. */
  51979. setToDefault(): void;
  51980. private _gatherBlocks;
  51981. /**
  51982. * Serializes this material in a JSON representation
  51983. * @returns the serialized material object
  51984. */
  51985. serialize(): any;
  51986. /**
  51987. * Clear the current graph and load a new one from a serialization object
  51988. * @param source defines the JSON representation of the material
  51989. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  51990. */
  51991. loadFromSerialization(source: any, rootUrl?: string): void;
  51992. /**
  51993. * Creates a node material from parsed material data
  51994. * @param source defines the JSON representation of the material
  51995. * @param scene defines the hosting scene
  51996. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  51997. * @returns a new node material
  51998. */
  51999. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  52000. /**
  52001. * Creates a new node material set to default basic configuration
  52002. * @param name defines the name of the material
  52003. * @param scene defines the hosting scene
  52004. * @returns a new NodeMaterial
  52005. */
  52006. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  52007. }
  52008. }
  52009. declare module BABYLON {
  52010. /**
  52011. * Block used to read a texture from a sampler
  52012. */
  52013. export class TextureBlock extends NodeMaterialBlock {
  52014. private _defineName;
  52015. private _samplerName;
  52016. private _transformedUVName;
  52017. private _textureTransformName;
  52018. private _textureInfoName;
  52019. private _mainUVName;
  52020. private _mainUVDefineName;
  52021. /**
  52022. * Gets or sets the texture associated with the node
  52023. */
  52024. texture: Nullable<BaseTexture>;
  52025. /**
  52026. * Create a new TextureBlock
  52027. * @param name defines the block name
  52028. */
  52029. constructor(name: string);
  52030. /**
  52031. * Gets the current class name
  52032. * @returns the class name
  52033. */
  52034. getClassName(): string;
  52035. /**
  52036. * Gets the uv input component
  52037. */
  52038. readonly uv: NodeMaterialConnectionPoint;
  52039. /**
  52040. * Gets the rgba output component
  52041. */
  52042. readonly rgba: NodeMaterialConnectionPoint;
  52043. /**
  52044. * Gets the rgb output component
  52045. */
  52046. readonly rgb: NodeMaterialConnectionPoint;
  52047. /**
  52048. * Gets the r output component
  52049. */
  52050. readonly r: NodeMaterialConnectionPoint;
  52051. /**
  52052. * Gets the g output component
  52053. */
  52054. readonly g: NodeMaterialConnectionPoint;
  52055. /**
  52056. * Gets the b output component
  52057. */
  52058. readonly b: NodeMaterialConnectionPoint;
  52059. /**
  52060. * Gets the a output component
  52061. */
  52062. readonly a: NodeMaterialConnectionPoint;
  52063. autoConfigure(): void;
  52064. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52065. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52066. isReady(): boolean;
  52067. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52068. private _injectVertexCode;
  52069. private _writeOutput;
  52070. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52071. serialize(): any;
  52072. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52073. }
  52074. }
  52075. declare module BABYLON {
  52076. /**
  52077. * Enum used to define well known values e.g. values automatically provided by the system
  52078. */
  52079. export enum NodeMaterialWellKnownValues {
  52080. /** World */
  52081. World = 1,
  52082. /** View */
  52083. View = 2,
  52084. /** Projection */
  52085. Projection = 3,
  52086. /** ViewProjection */
  52087. ViewProjection = 4,
  52088. /** WorldView */
  52089. WorldView = 5,
  52090. /** WorldViewProjection */
  52091. WorldViewProjection = 6,
  52092. /** CameraPosition */
  52093. CameraPosition = 7,
  52094. /** Fog Color */
  52095. FogColor = 8
  52096. }
  52097. }
  52098. declare module BABYLON {
  52099. /**
  52100. * Block used to read a reflection texture from a sampler
  52101. */
  52102. export class ReflectionTextureBlock extends NodeMaterialBlock {
  52103. private _define3DName;
  52104. private _defineCubicName;
  52105. private _defineExplicitName;
  52106. private _defineProjectionName;
  52107. private _defineLocalCubicName;
  52108. private _defineSphericalName;
  52109. private _definePlanarName;
  52110. private _defineEquirectangularName;
  52111. private _defineMirroredEquirectangularFixedName;
  52112. private _defineEquirectangularFixedName;
  52113. private _defineSkyboxName;
  52114. private _cubeSamplerName;
  52115. private _2DSamplerName;
  52116. private _positionUVWName;
  52117. private _directionWName;
  52118. private _reflectionCoordsName;
  52119. private _reflection2DCoordsName;
  52120. private _reflectionColorName;
  52121. private _reflectionMatrixName;
  52122. /**
  52123. * Gets or sets the texture associated with the node
  52124. */
  52125. texture: Nullable<BaseTexture>;
  52126. /**
  52127. * Create a new TextureBlock
  52128. * @param name defines the block name
  52129. */
  52130. constructor(name: string);
  52131. /**
  52132. * Gets the current class name
  52133. * @returns the class name
  52134. */
  52135. getClassName(): string;
  52136. /**
  52137. * Gets the world position input component
  52138. */
  52139. readonly position: NodeMaterialConnectionPoint;
  52140. /**
  52141. * Gets the world position input component
  52142. */
  52143. readonly worldPosition: NodeMaterialConnectionPoint;
  52144. /**
  52145. * Gets the world normal input component
  52146. */
  52147. readonly worldNormal: NodeMaterialConnectionPoint;
  52148. /**
  52149. * Gets the world input component
  52150. */
  52151. readonly world: NodeMaterialConnectionPoint;
  52152. /**
  52153. * Gets the camera (or eye) position component
  52154. */
  52155. readonly cameraPosition: NodeMaterialConnectionPoint;
  52156. /**
  52157. * Gets the view input component
  52158. */
  52159. readonly view: NodeMaterialConnectionPoint;
  52160. /**
  52161. * Gets the rgb output component
  52162. */
  52163. readonly rgb: NodeMaterialConnectionPoint;
  52164. /**
  52165. * Gets the r output component
  52166. */
  52167. readonly r: NodeMaterialConnectionPoint;
  52168. /**
  52169. * Gets the g output component
  52170. */
  52171. readonly g: NodeMaterialConnectionPoint;
  52172. /**
  52173. * Gets the b output component
  52174. */
  52175. readonly b: NodeMaterialConnectionPoint;
  52176. autoConfigure(): void;
  52177. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52178. isReady(): boolean;
  52179. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52180. private _injectVertexCode;
  52181. private _writeOutput;
  52182. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52183. serialize(): any;
  52184. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52185. }
  52186. }
  52187. declare module BABYLON {
  52188. /**
  52189. * Class used to store shared data between 2 NodeMaterialBuildState
  52190. */
  52191. export class NodeMaterialBuildStateSharedData {
  52192. /**
  52193. * Gets the list of emitted varyings
  52194. */
  52195. temps: string[];
  52196. /**
  52197. * Gets the list of emitted varyings
  52198. */
  52199. varyings: string[];
  52200. /**
  52201. * Gets the varying declaration string
  52202. */
  52203. varyingDeclaration: string;
  52204. /**
  52205. * Input blocks
  52206. */
  52207. inputBlocks: InputBlock[];
  52208. /**
  52209. * Input blocks
  52210. */
  52211. textureBlocks: (TextureBlock | ReflectionTextureBlock)[];
  52212. /**
  52213. * Bindable blocks (Blocks that need to set data to the effect)
  52214. */
  52215. bindableBlocks: NodeMaterialBlock[];
  52216. /**
  52217. * List of blocks that can provide a compilation fallback
  52218. */
  52219. blocksWithFallbacks: NodeMaterialBlock[];
  52220. /**
  52221. * List of blocks that can provide a define update
  52222. */
  52223. blocksWithDefines: NodeMaterialBlock[];
  52224. /**
  52225. * List of blocks that can provide a repeatable content
  52226. */
  52227. repeatableContentBlocks: NodeMaterialBlock[];
  52228. /**
  52229. * List of blocks that can provide a dynamic list of uniforms
  52230. */
  52231. dynamicUniformBlocks: NodeMaterialBlock[];
  52232. /**
  52233. * List of blocks that can block the isReady function for the material
  52234. */
  52235. blockingBlocks: NodeMaterialBlock[];
  52236. /**
  52237. * Gets the list of animated inputs
  52238. */
  52239. animatedInputs: InputBlock[];
  52240. /**
  52241. * Build Id used to avoid multiple recompilations
  52242. */
  52243. buildId: number;
  52244. /** List of emitted variables */
  52245. variableNames: {
  52246. [key: string]: number;
  52247. };
  52248. /** List of emitted defines */
  52249. defineNames: {
  52250. [key: string]: number;
  52251. };
  52252. /** Should emit comments? */
  52253. emitComments: boolean;
  52254. /** Emit build activity */
  52255. verbose: boolean;
  52256. /**
  52257. * Gets the compilation hints emitted at compilation time
  52258. */
  52259. hints: {
  52260. needWorldViewMatrix: boolean;
  52261. needWorldViewProjectionMatrix: boolean;
  52262. needAlphaBlending: boolean;
  52263. needAlphaTesting: boolean;
  52264. };
  52265. /**
  52266. * List of compilation checks
  52267. */
  52268. checks: {
  52269. emitVertex: boolean;
  52270. emitFragment: boolean;
  52271. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  52272. };
  52273. /** Creates a new shared data */
  52274. constructor();
  52275. /**
  52276. * Emits console errors and exceptions if there is a failing check
  52277. */
  52278. emitErrors(): void;
  52279. }
  52280. }
  52281. declare module BABYLON {
  52282. /**
  52283. * Class used to store node based material build state
  52284. */
  52285. export class NodeMaterialBuildState {
  52286. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  52287. supportUniformBuffers: boolean;
  52288. /**
  52289. * Gets the list of emitted attributes
  52290. */
  52291. attributes: string[];
  52292. /**
  52293. * Gets the list of emitted uniforms
  52294. */
  52295. uniforms: string[];
  52296. /**
  52297. * Gets the list of emitted uniform buffers
  52298. */
  52299. uniformBuffers: string[];
  52300. /**
  52301. * Gets the list of emitted samplers
  52302. */
  52303. samplers: string[];
  52304. /**
  52305. * Gets the list of emitted functions
  52306. */
  52307. functions: {
  52308. [key: string]: string;
  52309. };
  52310. /**
  52311. * Gets the target of the compilation state
  52312. */
  52313. target: NodeMaterialBlockTargets;
  52314. /**
  52315. * Gets the list of emitted counters
  52316. */
  52317. counters: {
  52318. [key: string]: number;
  52319. };
  52320. /**
  52321. * Shared data between multiple NodeMaterialBuildState instances
  52322. */
  52323. sharedData: NodeMaterialBuildStateSharedData;
  52324. /** @hidden */
  52325. _vertexState: NodeMaterialBuildState;
  52326. /** @hidden */
  52327. _attributeDeclaration: string;
  52328. /** @hidden */
  52329. _uniformDeclaration: string;
  52330. /** @hidden */
  52331. _samplerDeclaration: string;
  52332. /** @hidden */
  52333. _varyingTransfer: string;
  52334. private _repeatableContentAnchorIndex;
  52335. /** @hidden */
  52336. _builtCompilationString: string;
  52337. /**
  52338. * Gets the emitted compilation strings
  52339. */
  52340. compilationString: string;
  52341. /**
  52342. * Finalize the compilation strings
  52343. * @param state defines the current compilation state
  52344. */
  52345. finalize(state: NodeMaterialBuildState): void;
  52346. /** @hidden */
  52347. readonly _repeatableContentAnchor: string;
  52348. /** @hidden */
  52349. _getFreeVariableName(prefix: string): string;
  52350. /** @hidden */
  52351. _getFreeDefineName(prefix: string): string;
  52352. /** @hidden */
  52353. _excludeVariableName(name: string): void;
  52354. /** @hidden */
  52355. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  52356. /** @hidden */
  52357. _emitFunction(name: string, code: string, comments: string): void;
  52358. /** @hidden */
  52359. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  52360. replaceStrings?: {
  52361. search: RegExp;
  52362. replace: string;
  52363. }[];
  52364. repeatKey?: string;
  52365. }): string;
  52366. /** @hidden */
  52367. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  52368. repeatKey?: string;
  52369. removeAttributes?: boolean;
  52370. removeUniforms?: boolean;
  52371. removeVaryings?: boolean;
  52372. removeIfDef?: boolean;
  52373. replaceStrings?: {
  52374. search: RegExp;
  52375. replace: string;
  52376. }[];
  52377. }, storeKey?: string): void;
  52378. /** @hidden */
  52379. _registerTempVariable(name: string): boolean;
  52380. /** @hidden */
  52381. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  52382. /** @hidden */
  52383. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  52384. }
  52385. }
  52386. declare module BABYLON {
  52387. /**
  52388. * Defines a block that can be used inside a node based material
  52389. */
  52390. export class NodeMaterialBlock {
  52391. private _buildId;
  52392. private _buildTarget;
  52393. private _target;
  52394. private _isFinalMerger;
  52395. private _isInput;
  52396. /** @hidden */
  52397. _inputs: NodeMaterialConnectionPoint[];
  52398. /** @hidden */
  52399. _outputs: NodeMaterialConnectionPoint[];
  52400. /**
  52401. * Gets or sets the name of the block
  52402. */
  52403. name: string;
  52404. /**
  52405. * Gets or sets the unique id of the node
  52406. */
  52407. uniqueId: number;
  52408. /**
  52409. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  52410. */
  52411. readonly isFinalMerger: boolean;
  52412. /**
  52413. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  52414. */
  52415. readonly isInput: boolean;
  52416. /**
  52417. * Gets or sets the build Id
  52418. */
  52419. buildId: number;
  52420. /**
  52421. * Gets or sets the target of the block
  52422. */
  52423. target: NodeMaterialBlockTargets;
  52424. /**
  52425. * Gets the list of input points
  52426. */
  52427. readonly inputs: NodeMaterialConnectionPoint[];
  52428. /** Gets the list of output points */
  52429. readonly outputs: NodeMaterialConnectionPoint[];
  52430. /**
  52431. * Find an input by its name
  52432. * @param name defines the name of the input to look for
  52433. * @returns the input or null if not found
  52434. */
  52435. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52436. /**
  52437. * Find an output by its name
  52438. * @param name defines the name of the outputto look for
  52439. * @returns the output or null if not found
  52440. */
  52441. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52442. /**
  52443. * Creates a new NodeMaterialBlock
  52444. * @param name defines the block name
  52445. * @param target defines the target of that block (Vertex by default)
  52446. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  52447. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  52448. */
  52449. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  52450. /**
  52451. * Initialize the block and prepare the context for build
  52452. * @param state defines the state that will be used for the build
  52453. */
  52454. initialize(state: NodeMaterialBuildState): void;
  52455. /**
  52456. * Bind data to effect. Will only be called for blocks with isBindable === true
  52457. * @param effect defines the effect to bind data to
  52458. * @param nodeMaterial defines the hosting NodeMaterial
  52459. * @param mesh defines the mesh that will be rendered
  52460. */
  52461. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52462. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  52463. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  52464. protected _writeFloat(value: number): string;
  52465. /**
  52466. * Gets the current class name e.g. "NodeMaterialBlock"
  52467. * @returns the class name
  52468. */
  52469. getClassName(): string;
  52470. /**
  52471. * Register a new input. Must be called inside a block constructor
  52472. * @param name defines the connection point name
  52473. * @param type defines the connection point type
  52474. * @param isOptional defines a boolean indicating that this input can be omitted
  52475. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  52476. * @returns the current block
  52477. */
  52478. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  52479. /**
  52480. * Register a new output. Must be called inside a block constructor
  52481. * @param name defines the connection point name
  52482. * @param type defines the connection point type
  52483. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  52484. * @returns the current block
  52485. */
  52486. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  52487. /**
  52488. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  52489. * @param forOutput defines an optional connection point to check compatibility with
  52490. * @returns the first available input or null
  52491. */
  52492. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  52493. /**
  52494. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  52495. * @param forBlock defines an optional block to check compatibility with
  52496. * @returns the first available input or null
  52497. */
  52498. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  52499. /**
  52500. * Gets the sibling of the given output
  52501. * @param current defines the current output
  52502. * @returns the next output in the list or null
  52503. */
  52504. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  52505. /**
  52506. * Connect current block with another block
  52507. * @param other defines the block to connect with
  52508. * @param options define the various options to help pick the right connections
  52509. * @returns the current block
  52510. */
  52511. connectTo(other: NodeMaterialBlock, options?: {
  52512. input?: string;
  52513. output?: string;
  52514. outputSwizzle?: string;
  52515. }): this | undefined;
  52516. protected _buildBlock(state: NodeMaterialBuildState): void;
  52517. /**
  52518. * Add uniforms, samplers and uniform buffers at compilation time
  52519. * @param state defines the state to update
  52520. * @param nodeMaterial defines the node material requesting the update
  52521. * @param defines defines the material defines to update
  52522. */
  52523. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52524. /**
  52525. * Add potential fallbacks if shader compilation fails
  52526. * @param mesh defines the mesh to be rendered
  52527. * @param fallbacks defines the current prioritized list of fallbacks
  52528. */
  52529. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52530. /**
  52531. * Update defines for shader compilation
  52532. * @param mesh defines the mesh to be rendered
  52533. * @param nodeMaterial defines the node material requesting the update
  52534. * @param defines defines the material defines to update
  52535. * @param useInstances specifies that instances should be used
  52536. */
  52537. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52538. /**
  52539. * Initialize defines for shader compilation
  52540. * @param mesh defines the mesh to be rendered
  52541. * @param nodeMaterial defines the node material requesting the update
  52542. * @param defines defines the material defines to be prepared
  52543. * @param useInstances specifies that instances should be used
  52544. */
  52545. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52546. /**
  52547. * Lets the block try to connect some inputs automatically
  52548. */
  52549. autoConfigure(): void;
  52550. /**
  52551. * Function called when a block is declared as repeatable content generator
  52552. * @param vertexShaderState defines the current compilation state for the vertex shader
  52553. * @param fragmentShaderState defines the current compilation state for the fragment shader
  52554. * @param mesh defines the mesh to be rendered
  52555. * @param defines defines the material defines to update
  52556. */
  52557. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52558. /**
  52559. * Checks if the block is ready
  52560. * @param mesh defines the mesh to be rendered
  52561. * @param nodeMaterial defines the node material requesting the update
  52562. * @param defines defines the material defines to update
  52563. * @param useInstances specifies that instances should be used
  52564. * @returns true if the block is ready
  52565. */
  52566. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  52567. private _processBuild;
  52568. /**
  52569. * Compile the current node and generate the shader code
  52570. * @param state defines the current compilation state (uniforms, samplers, current string)
  52571. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  52572. * @returns true if already built
  52573. */
  52574. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  52575. /**
  52576. * Clone the current block to a new identical block
  52577. * @param scene defines the hosting scene
  52578. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52579. * @returns a copy of the current block
  52580. */
  52581. clone(scene: Scene, rootUrl?: string): NodeMaterialBlock | null;
  52582. /**
  52583. * Serializes this block in a JSON representation
  52584. * @returns the serialized block object
  52585. */
  52586. serialize(): any;
  52587. /** @hidden */
  52588. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52589. }
  52590. }
  52591. declare module BABYLON {
  52592. /**
  52593. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52594. */
  52595. export enum NodeMaterialBlockConnectionPointMode {
  52596. /** Value is an uniform */
  52597. Uniform = 0,
  52598. /** Value is a mesh attribute */
  52599. Attribute = 1,
  52600. /** Value is a varying between vertex and fragment shaders */
  52601. Varying = 2,
  52602. /** Mode is undefined */
  52603. Undefined = 3
  52604. }
  52605. }
  52606. declare module BABYLON {
  52607. /**
  52608. * Enum defining the type of animations supported by InputBlock
  52609. */
  52610. export enum AnimatedInputBlockTypes {
  52611. /** No animation */
  52612. None = 0,
  52613. /** Time based animation. Will only work for floats */
  52614. Time = 1
  52615. }
  52616. }
  52617. declare module BABYLON {
  52618. /**
  52619. * Block used to expose an input value
  52620. */
  52621. export class InputBlock extends NodeMaterialBlock {
  52622. private _mode;
  52623. private _associatedVariableName;
  52624. private _storedValue;
  52625. private _valueCallback;
  52626. private _type;
  52627. private _animationType;
  52628. /** @hidden */
  52629. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  52630. /** Gets or sets a boolean indicating that this input can be edited in the Inspector */
  52631. visibleInInspector: boolean;
  52632. /**
  52633. * Gets or sets the connection point type (default is float)
  52634. */
  52635. readonly type: NodeMaterialBlockConnectionPointTypes;
  52636. /**
  52637. * Creates a new InputBlock
  52638. * @param name defines the block name
  52639. * @param target defines the target of that block (Vertex by default)
  52640. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  52641. */
  52642. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  52643. /**
  52644. * Gets the output component
  52645. */
  52646. readonly output: NodeMaterialConnectionPoint;
  52647. /**
  52648. * Set the source of this connection point to a vertex attribute
  52649. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  52650. * @returns the current connection point
  52651. */
  52652. setAsAttribute(attributeName?: string): InputBlock;
  52653. /**
  52654. * Set the source of this connection point to a well known value
  52655. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  52656. * @returns the current connection point
  52657. */
  52658. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  52659. /**
  52660. * Gets or sets the value of that point.
  52661. * Please note that this value will be ignored if valueCallback is defined
  52662. */
  52663. value: any;
  52664. /**
  52665. * Gets or sets a callback used to get the value of that point.
  52666. * Please note that setting this value will force the connection point to ignore the value property
  52667. */
  52668. valueCallback: () => any;
  52669. /**
  52670. * Gets or sets the associated variable name in the shader
  52671. */
  52672. associatedVariableName: string;
  52673. /** Gets or sets the type of animation applied to the input */
  52674. animationType: AnimatedInputBlockTypes;
  52675. /**
  52676. * Gets a boolean indicating that this connection point not defined yet
  52677. */
  52678. readonly isUndefined: boolean;
  52679. /**
  52680. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  52681. * In this case the connection point name must be the name of the uniform to use.
  52682. * Can only be set on inputs
  52683. */
  52684. isUniform: boolean;
  52685. /**
  52686. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  52687. * In this case the connection point name must be the name of the attribute to use
  52688. * Can only be set on inputs
  52689. */
  52690. isAttribute: boolean;
  52691. /**
  52692. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  52693. * Can only be set on exit points
  52694. */
  52695. isVarying: boolean;
  52696. /**
  52697. * Gets a boolean indicating that the current connection point is a well known value
  52698. */
  52699. readonly isWellKnownValue: boolean;
  52700. /**
  52701. * Gets or sets the current well known value or null if not defined as well know value
  52702. */
  52703. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  52704. /**
  52705. * Gets the current class name
  52706. * @returns the class name
  52707. */
  52708. getClassName(): string;
  52709. /**
  52710. * Animate the input if animationType !== None
  52711. * @param scene defines the rendering scene
  52712. */
  52713. animate(scene: Scene): void;
  52714. private _emitDefine;
  52715. /**
  52716. * Set the input block to its default value (based on its type)
  52717. */
  52718. setDefaultValue(): void;
  52719. private _emit;
  52720. /** @hidden */
  52721. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  52722. /** @hidden */
  52723. _transmit(effect: Effect, scene: Scene): void;
  52724. protected _buildBlock(state: NodeMaterialBuildState): void;
  52725. serialize(): any;
  52726. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52727. }
  52728. }
  52729. declare module BABYLON {
  52730. /**
  52731. * Defines a connection point for a block
  52732. */
  52733. export class NodeMaterialConnectionPoint {
  52734. /** @hidden */
  52735. _ownerBlock: NodeMaterialBlock;
  52736. /** @hidden */
  52737. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52738. private _endpoints;
  52739. private _associatedVariableName;
  52740. /** @hidden */
  52741. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  52742. private _type;
  52743. /** @hidden */
  52744. _enforceAssociatedVariableName: boolean;
  52745. /**
  52746. * Gets or sets the additional types supported byt this connection point
  52747. */
  52748. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  52749. /**
  52750. * Gets or sets the associated variable name in the shader
  52751. */
  52752. associatedVariableName: string;
  52753. /**
  52754. * Gets or sets the connection point type (default is float)
  52755. */
  52756. type: NodeMaterialBlockConnectionPointTypes;
  52757. /**
  52758. * Gets or sets the connection point name
  52759. */
  52760. name: string;
  52761. /**
  52762. * Gets or sets a boolean indicating that this connection point can be omitted
  52763. */
  52764. isOptional: boolean;
  52765. /**
  52766. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  52767. */
  52768. define: string;
  52769. /** Gets or sets the target of that connection point */
  52770. target: NodeMaterialBlockTargets;
  52771. /**
  52772. * Gets a boolean indicating that the current point is connected
  52773. */
  52774. readonly isConnected: boolean;
  52775. /**
  52776. * Gets a boolean indicating that the current point is connected to an input block
  52777. */
  52778. readonly isConnectedToInputBlock: boolean;
  52779. /**
  52780. * Gets a the connected input block (if any)
  52781. */
  52782. readonly connectInputBlock: Nullable<InputBlock>;
  52783. /** Get the other side of the connection (if any) */
  52784. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52785. /** Get the block that owns this connection point */
  52786. readonly ownerBlock: NodeMaterialBlock;
  52787. /** Get the block connected on the other side of this connection (if any) */
  52788. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  52789. /** Get the block connected on the endpoints of this connection (if any) */
  52790. readonly connectedBlocks: Array<NodeMaterialBlock>;
  52791. /** Gets the list of connected endpoints */
  52792. readonly endpoints: NodeMaterialConnectionPoint[];
  52793. /** Gets a boolean indicating if that output point is connected to at least one input */
  52794. readonly hasEndpoints: boolean;
  52795. /**
  52796. * Creates a new connection point
  52797. * @param name defines the connection point name
  52798. * @param ownerBlock defines the block hosting this connection point
  52799. */
  52800. constructor(name: string, ownerBlock: NodeMaterialBlock);
  52801. /**
  52802. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  52803. * @returns the class name
  52804. */
  52805. getClassName(): string;
  52806. /**
  52807. * Gets an boolean indicating if the current point can be connected to another point
  52808. * @param connectionPoint defines the other connection point
  52809. * @returns true if the connection is possible
  52810. */
  52811. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  52812. /**
  52813. * Connect this point to another connection point
  52814. * @param connectionPoint defines the other connection point
  52815. * @returns the current connection point
  52816. */
  52817. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  52818. /**
  52819. * Disconnect this point from one of his endpoint
  52820. * @param endpoint defines the other connection point
  52821. * @returns the current connection point
  52822. */
  52823. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  52824. /**
  52825. * Serializes this point in a JSON representation
  52826. * @returns the serialized point object
  52827. */
  52828. serialize(): any;
  52829. }
  52830. }
  52831. declare module BABYLON {
  52832. /**
  52833. * Block used to add support for vertex skinning (bones)
  52834. */
  52835. export class BonesBlock extends NodeMaterialBlock {
  52836. /**
  52837. * Creates a new BonesBlock
  52838. * @param name defines the block name
  52839. */
  52840. constructor(name: string);
  52841. /**
  52842. * Initialize the block and prepare the context for build
  52843. * @param state defines the state that will be used for the build
  52844. */
  52845. initialize(state: NodeMaterialBuildState): void;
  52846. /**
  52847. * Gets the current class name
  52848. * @returns the class name
  52849. */
  52850. getClassName(): string;
  52851. /**
  52852. * Gets the matrix indices input component
  52853. */
  52854. readonly matricesIndices: NodeMaterialConnectionPoint;
  52855. /**
  52856. * Gets the matrix weights input component
  52857. */
  52858. readonly matricesWeights: NodeMaterialConnectionPoint;
  52859. /**
  52860. * Gets the extra matrix indices input component
  52861. */
  52862. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  52863. /**
  52864. * Gets the extra matrix weights input component
  52865. */
  52866. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  52867. /**
  52868. * Gets the world input component
  52869. */
  52870. readonly world: NodeMaterialConnectionPoint;
  52871. /**
  52872. * Gets the output component
  52873. */
  52874. readonly output: NodeMaterialConnectionPoint;
  52875. autoConfigure(): void;
  52876. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52877. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52878. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52879. protected _buildBlock(state: NodeMaterialBuildState): this;
  52880. }
  52881. }
  52882. declare module BABYLON {
  52883. /**
  52884. * Block used to add support for instances
  52885. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  52886. */
  52887. export class InstancesBlock extends NodeMaterialBlock {
  52888. /**
  52889. * Creates a new InstancesBlock
  52890. * @param name defines the block name
  52891. */
  52892. constructor(name: string);
  52893. /**
  52894. * Gets the current class name
  52895. * @returns the class name
  52896. */
  52897. getClassName(): string;
  52898. /**
  52899. * Gets the first world row input component
  52900. */
  52901. readonly world0: NodeMaterialConnectionPoint;
  52902. /**
  52903. * Gets the second world row input component
  52904. */
  52905. readonly world1: NodeMaterialConnectionPoint;
  52906. /**
  52907. * Gets the third world row input component
  52908. */
  52909. readonly world2: NodeMaterialConnectionPoint;
  52910. /**
  52911. * Gets the forth world row input component
  52912. */
  52913. readonly world3: NodeMaterialConnectionPoint;
  52914. /**
  52915. * Gets the world input component
  52916. */
  52917. readonly world: NodeMaterialConnectionPoint;
  52918. /**
  52919. * Gets the output component
  52920. */
  52921. readonly output: NodeMaterialConnectionPoint;
  52922. autoConfigure(): void;
  52923. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52924. protected _buildBlock(state: NodeMaterialBuildState): this;
  52925. }
  52926. }
  52927. declare module BABYLON {
  52928. /**
  52929. * Block used to add morph targets support to vertex shader
  52930. */
  52931. export class MorphTargetsBlock extends NodeMaterialBlock {
  52932. private _repeatableContentAnchor;
  52933. private _repeatebleContentGenerated;
  52934. /**
  52935. * Create a new MorphTargetsBlock
  52936. * @param name defines the block name
  52937. */
  52938. constructor(name: string);
  52939. /**
  52940. * Gets the current class name
  52941. * @returns the class name
  52942. */
  52943. getClassName(): string;
  52944. /**
  52945. * Gets the position input component
  52946. */
  52947. readonly position: NodeMaterialConnectionPoint;
  52948. /**
  52949. * Gets the normal input component
  52950. */
  52951. readonly normal: NodeMaterialConnectionPoint;
  52952. /**
  52953. * Gets the tangent input component
  52954. */
  52955. readonly tangent: NodeMaterialConnectionPoint;
  52956. /**
  52957. * Gets the tangent input component
  52958. */
  52959. readonly uv: NodeMaterialConnectionPoint;
  52960. /**
  52961. * Gets the position output component
  52962. */
  52963. readonly positionOutput: NodeMaterialConnectionPoint;
  52964. /**
  52965. * Gets the normal output component
  52966. */
  52967. readonly normalOutput: NodeMaterialConnectionPoint;
  52968. /**
  52969. * Gets the tangent output component
  52970. */
  52971. readonly tangentOutput: NodeMaterialConnectionPoint;
  52972. /**
  52973. * Gets the tangent output component
  52974. */
  52975. readonly uvOutput: NodeMaterialConnectionPoint;
  52976. initialize(state: NodeMaterialBuildState): void;
  52977. autoConfigure(): void;
  52978. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52979. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52980. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52981. protected _buildBlock(state: NodeMaterialBuildState): this;
  52982. }
  52983. }
  52984. declare module BABYLON {
  52985. /**
  52986. * Block used to add an alpha test in the fragment shader
  52987. */
  52988. export class AlphaTestBlock extends NodeMaterialBlock {
  52989. /**
  52990. * Gets or sets the alpha value where alpha testing happens
  52991. */
  52992. alphaCutOff: number;
  52993. /**
  52994. * Create a new AlphaTestBlock
  52995. * @param name defines the block name
  52996. */
  52997. constructor(name: string);
  52998. /**
  52999. * Gets the current class name
  53000. * @returns the class name
  53001. */
  53002. getClassName(): string;
  53003. /**
  53004. * Gets the color input component
  53005. */
  53006. readonly color: NodeMaterialConnectionPoint;
  53007. /**
  53008. * Gets the alpha input component
  53009. */
  53010. readonly alpha: NodeMaterialConnectionPoint;
  53011. protected _buildBlock(state: NodeMaterialBuildState): this;
  53012. }
  53013. }
  53014. declare module BABYLON {
  53015. /**
  53016. * Block used to compute fresnel value
  53017. */
  53018. export class FresnelBlock extends NodeMaterialBlock {
  53019. /**
  53020. * Create a new FresnelBlock
  53021. * @param name defines the block name
  53022. */
  53023. constructor(name: string);
  53024. /**
  53025. * Gets the current class name
  53026. * @returns the class name
  53027. */
  53028. getClassName(): string;
  53029. /**
  53030. * Gets the world position input component
  53031. */
  53032. readonly worldPosition: NodeMaterialConnectionPoint;
  53033. /**
  53034. * Gets the world normal input component
  53035. */
  53036. readonly worldNormal: NodeMaterialConnectionPoint;
  53037. /**
  53038. * Gets the camera (or eye) position component
  53039. */
  53040. readonly cameraPosition: NodeMaterialConnectionPoint;
  53041. /**
  53042. * Gets the bias input component
  53043. */
  53044. readonly bias: NodeMaterialConnectionPoint;
  53045. /**
  53046. * Gets the camera (or eye) position component
  53047. */
  53048. readonly power: NodeMaterialConnectionPoint;
  53049. /**
  53050. * Gets the fresnel output component
  53051. */
  53052. readonly fresnel: NodeMaterialConnectionPoint;
  53053. autoConfigure(): void;
  53054. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53055. }
  53056. }
  53057. declare module BABYLON {
  53058. /**
  53059. * Block used to add image processing support to fragment shader
  53060. */
  53061. export class ImageProcessingBlock extends NodeMaterialBlock {
  53062. /**
  53063. * Create a new ImageProcessingBlock
  53064. * @param name defines the block name
  53065. */
  53066. constructor(name: string);
  53067. /**
  53068. * Gets the current class name
  53069. * @returns the class name
  53070. */
  53071. getClassName(): string;
  53072. /**
  53073. * Gets the color input component
  53074. */
  53075. readonly color: NodeMaterialConnectionPoint;
  53076. /**
  53077. * Gets the output component
  53078. */
  53079. readonly output: NodeMaterialConnectionPoint;
  53080. /**
  53081. * Initialize the block and prepare the context for build
  53082. * @param state defines the state that will be used for the build
  53083. */
  53084. initialize(state: NodeMaterialBuildState): void;
  53085. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  53086. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53087. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53088. protected _buildBlock(state: NodeMaterialBuildState): this;
  53089. }
  53090. }
  53091. declare module BABYLON {
  53092. /**
  53093. * Block used to add support for scene fog
  53094. */
  53095. export class FogBlock extends NodeMaterialBlock {
  53096. private _fogDistanceName;
  53097. private _fogParameters;
  53098. /**
  53099. * Create a new FogBlock
  53100. * @param name defines the block name
  53101. */
  53102. constructor(name: string);
  53103. /**
  53104. * Gets the current class name
  53105. * @returns the class name
  53106. */
  53107. getClassName(): string;
  53108. /**
  53109. * Gets the world position input component
  53110. */
  53111. readonly worldPosition: NodeMaterialConnectionPoint;
  53112. /**
  53113. * Gets the view input component
  53114. */
  53115. readonly view: NodeMaterialConnectionPoint;
  53116. /**
  53117. * Gets the color input component
  53118. */
  53119. readonly color: NodeMaterialConnectionPoint;
  53120. /**
  53121. * Gets the fog color input component
  53122. */
  53123. readonly fogColor: NodeMaterialConnectionPoint;
  53124. /**
  53125. * Gets the output component
  53126. */
  53127. readonly output: NodeMaterialConnectionPoint;
  53128. autoConfigure(): void;
  53129. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53130. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53131. protected _buildBlock(state: NodeMaterialBuildState): this;
  53132. }
  53133. }
  53134. declare module BABYLON {
  53135. /**
  53136. * Block used to add light in the fragment shader
  53137. */
  53138. export class LightBlock extends NodeMaterialBlock {
  53139. private _lightId;
  53140. /**
  53141. * Gets or sets the light associated with this block
  53142. */
  53143. light: Nullable<Light>;
  53144. /**
  53145. * Create a new LightBlock
  53146. * @param name defines the block name
  53147. */
  53148. constructor(name: string);
  53149. /**
  53150. * Gets the current class name
  53151. * @returns the class name
  53152. */
  53153. getClassName(): string;
  53154. /**
  53155. * Gets the world position input component
  53156. */
  53157. readonly worldPosition: NodeMaterialConnectionPoint;
  53158. /**
  53159. * Gets the world normal input component
  53160. */
  53161. readonly worldNormal: NodeMaterialConnectionPoint;
  53162. /**
  53163. * Gets the camera (or eye) position component
  53164. */
  53165. readonly cameraPosition: NodeMaterialConnectionPoint;
  53166. /**
  53167. * Gets the diffuse output component
  53168. */
  53169. readonly diffuseOutput: NodeMaterialConnectionPoint;
  53170. /**
  53171. * Gets the specular output component
  53172. */
  53173. readonly specularOutput: NodeMaterialConnectionPoint;
  53174. autoConfigure(): void;
  53175. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53176. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53177. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53178. private _injectVertexCode;
  53179. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53180. serialize(): any;
  53181. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53182. }
  53183. }
  53184. declare module BABYLON {
  53185. /**
  53186. * Block used to multiply 2 values
  53187. */
  53188. export class MultiplyBlock extends NodeMaterialBlock {
  53189. /**
  53190. * Creates a new MultiplyBlock
  53191. * @param name defines the block name
  53192. */
  53193. constructor(name: string);
  53194. /**
  53195. * Gets the current class name
  53196. * @returns the class name
  53197. */
  53198. getClassName(): string;
  53199. /**
  53200. * Gets the left operand input component
  53201. */
  53202. readonly left: NodeMaterialConnectionPoint;
  53203. /**
  53204. * Gets the right operand input component
  53205. */
  53206. readonly right: NodeMaterialConnectionPoint;
  53207. /**
  53208. * Gets the output component
  53209. */
  53210. readonly output: NodeMaterialConnectionPoint;
  53211. protected _buildBlock(state: NodeMaterialBuildState): this;
  53212. }
  53213. }
  53214. declare module BABYLON {
  53215. /**
  53216. * Block used to add 2 vectors
  53217. */
  53218. export class AddBlock extends NodeMaterialBlock {
  53219. /**
  53220. * Creates a new AddBlock
  53221. * @param name defines the block name
  53222. */
  53223. constructor(name: string);
  53224. /**
  53225. * Gets the current class name
  53226. * @returns the class name
  53227. */
  53228. getClassName(): string;
  53229. /**
  53230. * Gets the left operand input component
  53231. */
  53232. readonly left: NodeMaterialConnectionPoint;
  53233. /**
  53234. * Gets the right operand input component
  53235. */
  53236. readonly right: NodeMaterialConnectionPoint;
  53237. /**
  53238. * Gets the output component
  53239. */
  53240. readonly output: NodeMaterialConnectionPoint;
  53241. protected _buildBlock(state: NodeMaterialBuildState): this;
  53242. }
  53243. }
  53244. declare module BABYLON {
  53245. /**
  53246. * Block used to scale a vector by a float
  53247. */
  53248. export class ScaleBlock extends NodeMaterialBlock {
  53249. /**
  53250. * Creates a new ScaleBlock
  53251. * @param name defines the block name
  53252. */
  53253. constructor(name: string);
  53254. /**
  53255. * Gets the current class name
  53256. * @returns the class name
  53257. */
  53258. getClassName(): string;
  53259. /**
  53260. * Gets the input component
  53261. */
  53262. readonly input: NodeMaterialConnectionPoint;
  53263. /**
  53264. * Gets the factor input component
  53265. */
  53266. readonly factor: NodeMaterialConnectionPoint;
  53267. /**
  53268. * Gets the output component
  53269. */
  53270. readonly output: NodeMaterialConnectionPoint;
  53271. protected _buildBlock(state: NodeMaterialBuildState): this;
  53272. }
  53273. }
  53274. declare module BABYLON {
  53275. /**
  53276. * Block used to clamp a float
  53277. */
  53278. export class ClampBlock extends NodeMaterialBlock {
  53279. /** Gets or sets the minimum range */
  53280. minimum: number;
  53281. /** Gets or sets the maximum range */
  53282. maximum: number;
  53283. /**
  53284. * Creates a new ClampBlock
  53285. * @param name defines the block name
  53286. */
  53287. constructor(name: string);
  53288. /**
  53289. * Gets the current class name
  53290. * @returns the class name
  53291. */
  53292. getClassName(): string;
  53293. /**
  53294. * Gets the value input component
  53295. */
  53296. readonly value: NodeMaterialConnectionPoint;
  53297. /**
  53298. * Gets the output component
  53299. */
  53300. readonly output: NodeMaterialConnectionPoint;
  53301. protected _buildBlock(state: NodeMaterialBuildState): this;
  53302. }
  53303. }
  53304. declare module BABYLON {
  53305. /**
  53306. * Block used to apply a cross product between 2 vectors
  53307. */
  53308. export class CrossBlock extends NodeMaterialBlock {
  53309. /**
  53310. * Creates a new CrossBlock
  53311. * @param name defines the block name
  53312. */
  53313. constructor(name: string);
  53314. /**
  53315. * Gets the current class name
  53316. * @returns the class name
  53317. */
  53318. getClassName(): string;
  53319. /**
  53320. * Gets the left operand input component
  53321. */
  53322. readonly left: NodeMaterialConnectionPoint;
  53323. /**
  53324. * Gets the right operand input component
  53325. */
  53326. readonly right: NodeMaterialConnectionPoint;
  53327. /**
  53328. * Gets the output component
  53329. */
  53330. readonly output: NodeMaterialConnectionPoint;
  53331. protected _buildBlock(state: NodeMaterialBuildState): this;
  53332. }
  53333. }
  53334. declare module BABYLON {
  53335. /**
  53336. * Block used to apply a dot product between 2 vectors
  53337. */
  53338. export class DotBlock extends NodeMaterialBlock {
  53339. /**
  53340. * Creates a new DotBlock
  53341. * @param name defines the block name
  53342. */
  53343. constructor(name: string);
  53344. /**
  53345. * Gets the current class name
  53346. * @returns the class name
  53347. */
  53348. getClassName(): string;
  53349. /**
  53350. * Gets the left operand input component
  53351. */
  53352. readonly left: NodeMaterialConnectionPoint;
  53353. /**
  53354. * Gets the right operand input component
  53355. */
  53356. readonly right: NodeMaterialConnectionPoint;
  53357. /**
  53358. * Gets the output component
  53359. */
  53360. readonly output: NodeMaterialConnectionPoint;
  53361. protected _buildBlock(state: NodeMaterialBuildState): this;
  53362. }
  53363. }
  53364. declare module BABYLON {
  53365. /**
  53366. * Block used to remap a float from a range to a new one
  53367. */
  53368. export class RemapBlock extends NodeMaterialBlock {
  53369. /**
  53370. * Gets or sets the source range
  53371. */
  53372. sourceRange: Vector2;
  53373. /**
  53374. * Gets or sets the target range
  53375. */
  53376. targetRange: Vector2;
  53377. /**
  53378. * Creates a new RemapBlock
  53379. * @param name defines the block name
  53380. */
  53381. constructor(name: string);
  53382. /**
  53383. * Gets the current class name
  53384. * @returns the class name
  53385. */
  53386. getClassName(): string;
  53387. /**
  53388. * Gets the input component
  53389. */
  53390. readonly input: NodeMaterialConnectionPoint;
  53391. /**
  53392. * Gets the output component
  53393. */
  53394. readonly output: NodeMaterialConnectionPoint;
  53395. protected _buildBlock(state: NodeMaterialBuildState): this;
  53396. }
  53397. }
  53398. declare module BABYLON {
  53399. /**
  53400. * Block used to normalize a vector
  53401. */
  53402. export class NormalizeBlock extends NodeMaterialBlock {
  53403. /**
  53404. * Creates a new NormalizeBlock
  53405. * @param name defines the block name
  53406. */
  53407. constructor(name: string);
  53408. /**
  53409. * Gets the current class name
  53410. * @returns the class name
  53411. */
  53412. getClassName(): string;
  53413. /**
  53414. * Gets the input component
  53415. */
  53416. readonly input: NodeMaterialConnectionPoint;
  53417. /**
  53418. * Gets the output component
  53419. */
  53420. readonly output: NodeMaterialConnectionPoint;
  53421. protected _buildBlock(state: NodeMaterialBuildState): this;
  53422. }
  53423. }
  53424. declare module BABYLON {
  53425. /**
  53426. * Operations supported by the Trigonometry block
  53427. */
  53428. export enum TrigonometryBlockOperations {
  53429. /** Cos */
  53430. Cos = 0,
  53431. /** Sin */
  53432. Sin = 1,
  53433. /** Abs */
  53434. Abs = 2
  53435. }
  53436. /**
  53437. * Block used to apply trigonometry operation to floats
  53438. */
  53439. export class TrigonometryBlock extends NodeMaterialBlock {
  53440. /**
  53441. * Gets or sets the operation applied by the block
  53442. */
  53443. operation: TrigonometryBlockOperations;
  53444. /**
  53445. * Creates a new TrigonometryBlock
  53446. * @param name defines the block name
  53447. */
  53448. constructor(name: string);
  53449. /**
  53450. * Gets the current class name
  53451. * @returns the class name
  53452. */
  53453. getClassName(): string;
  53454. /**
  53455. * Gets the input component
  53456. */
  53457. readonly input: NodeMaterialConnectionPoint;
  53458. /**
  53459. * Gets the output component
  53460. */
  53461. readonly output: NodeMaterialConnectionPoint;
  53462. protected _buildBlock(state: NodeMaterialBuildState): this;
  53463. }
  53464. }
  53465. declare module BABYLON {
  53466. /**
  53467. * Block used to create a Color3/4 out of individual inputs (one for each component)
  53468. */
  53469. export class ColorMergerBlock extends NodeMaterialBlock {
  53470. /**
  53471. * Create a new ColorMergerBlock
  53472. * @param name defines the block name
  53473. */
  53474. constructor(name: string);
  53475. /**
  53476. * Gets the current class name
  53477. * @returns the class name
  53478. */
  53479. getClassName(): string;
  53480. /**
  53481. * Gets the r component (input)
  53482. */
  53483. readonly r: NodeMaterialConnectionPoint;
  53484. /**
  53485. * Gets the g component (input)
  53486. */
  53487. readonly g: NodeMaterialConnectionPoint;
  53488. /**
  53489. * Gets the b component (input)
  53490. */
  53491. readonly b: NodeMaterialConnectionPoint;
  53492. /**
  53493. * Gets the a component (input)
  53494. */
  53495. readonly a: NodeMaterialConnectionPoint;
  53496. /**
  53497. * Gets the rgba component (output)
  53498. */
  53499. readonly rgba: NodeMaterialConnectionPoint;
  53500. /**
  53501. * Gets the rgb component (output)
  53502. */
  53503. readonly rgb: NodeMaterialConnectionPoint;
  53504. protected _buildBlock(state: NodeMaterialBuildState): this;
  53505. }
  53506. }
  53507. declare module BABYLON {
  53508. /**
  53509. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  53510. */
  53511. export class VectorMergerBlock extends NodeMaterialBlock {
  53512. /**
  53513. * Create a new VectorMergerBlock
  53514. * @param name defines the block name
  53515. */
  53516. constructor(name: string);
  53517. /**
  53518. * Gets the current class name
  53519. * @returns the class name
  53520. */
  53521. getClassName(): string;
  53522. /**
  53523. * Gets the x component (input)
  53524. */
  53525. readonly x: NodeMaterialConnectionPoint;
  53526. /**
  53527. * Gets the y component (input)
  53528. */
  53529. readonly y: NodeMaterialConnectionPoint;
  53530. /**
  53531. * Gets the z component (input)
  53532. */
  53533. readonly z: NodeMaterialConnectionPoint;
  53534. /**
  53535. * Gets the w component (input)
  53536. */
  53537. readonly w: NodeMaterialConnectionPoint;
  53538. /**
  53539. * Gets the xyzw component (output)
  53540. */
  53541. readonly xyzw: NodeMaterialConnectionPoint;
  53542. /**
  53543. * Gets the xyz component (output)
  53544. */
  53545. readonly xyz: NodeMaterialConnectionPoint;
  53546. /**
  53547. * Gets the xy component (output)
  53548. */
  53549. readonly xy: NodeMaterialConnectionPoint;
  53550. protected _buildBlock(state: NodeMaterialBuildState): this;
  53551. }
  53552. }
  53553. declare module BABYLON {
  53554. /**
  53555. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  53556. */
  53557. export class ColorSplitterBlock extends NodeMaterialBlock {
  53558. /**
  53559. * Create a new ColorSplitterBlock
  53560. * @param name defines the block name
  53561. */
  53562. constructor(name: string);
  53563. /**
  53564. * Gets the current class name
  53565. * @returns the class name
  53566. */
  53567. getClassName(): string;
  53568. /**
  53569. * Gets the rgba component (input)
  53570. */
  53571. readonly rgba: NodeMaterialConnectionPoint;
  53572. /**
  53573. * Gets the rgb component (input)
  53574. */
  53575. readonly rgbIn: NodeMaterialConnectionPoint;
  53576. /**
  53577. * Gets the rgb component (output)
  53578. */
  53579. readonly rgbOut: NodeMaterialConnectionPoint;
  53580. /**
  53581. * Gets the r component (output)
  53582. */
  53583. readonly r: NodeMaterialConnectionPoint;
  53584. /**
  53585. * Gets the g component (output)
  53586. */
  53587. readonly g: NodeMaterialConnectionPoint;
  53588. /**
  53589. * Gets the b component (output)
  53590. */
  53591. readonly b: NodeMaterialConnectionPoint;
  53592. /**
  53593. * Gets the a component (output)
  53594. */
  53595. readonly a: NodeMaterialConnectionPoint;
  53596. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53597. }
  53598. }
  53599. declare module BABYLON {
  53600. /**
  53601. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  53602. */
  53603. export class VectorSplitterBlock extends NodeMaterialBlock {
  53604. /**
  53605. * Create a new VectorSplitterBlock
  53606. * @param name defines the block name
  53607. */
  53608. constructor(name: string);
  53609. /**
  53610. * Gets the current class name
  53611. * @returns the class name
  53612. */
  53613. getClassName(): string;
  53614. /**
  53615. * Gets the xyzw component (input)
  53616. */
  53617. readonly xyzw: NodeMaterialConnectionPoint;
  53618. /**
  53619. * Gets the xyz component (input)
  53620. */
  53621. readonly xyzIn: NodeMaterialConnectionPoint;
  53622. /**
  53623. * Gets the xy component (input)
  53624. */
  53625. readonly xyIn: NodeMaterialConnectionPoint;
  53626. /**
  53627. * Gets the xyz component (output)
  53628. */
  53629. readonly xyzOut: NodeMaterialConnectionPoint;
  53630. /**
  53631. * Gets the xy component (output)
  53632. */
  53633. readonly xyOut: NodeMaterialConnectionPoint;
  53634. /**
  53635. * Gets the x component (output)
  53636. */
  53637. readonly x: NodeMaterialConnectionPoint;
  53638. /**
  53639. * Gets the y component (output)
  53640. */
  53641. readonly y: NodeMaterialConnectionPoint;
  53642. /**
  53643. * Gets the z component (output)
  53644. */
  53645. readonly z: NodeMaterialConnectionPoint;
  53646. /**
  53647. * Gets the w component (output)
  53648. */
  53649. readonly w: NodeMaterialConnectionPoint;
  53650. protected _buildBlock(state: NodeMaterialBuildState): this;
  53651. }
  53652. }
  53653. declare module BABYLON {
  53654. /**
  53655. * Effect Render Options
  53656. */
  53657. export interface IEffectRendererOptions {
  53658. /**
  53659. * Defines the vertices positions.
  53660. */
  53661. positions?: number[];
  53662. /**
  53663. * Defines the indices.
  53664. */
  53665. indices?: number[];
  53666. }
  53667. /**
  53668. * Helper class to render one or more effects
  53669. */
  53670. export class EffectRenderer {
  53671. private engine;
  53672. private static _DefaultOptions;
  53673. private _vertexBuffers;
  53674. private _indexBuffer;
  53675. private _ringBufferIndex;
  53676. private _ringScreenBuffer;
  53677. private _fullscreenViewport;
  53678. private _getNextFrameBuffer;
  53679. /**
  53680. * Creates an effect renderer
  53681. * @param engine the engine to use for rendering
  53682. * @param options defines the options of the effect renderer
  53683. */
  53684. constructor(engine: Engine, options?: IEffectRendererOptions);
  53685. /**
  53686. * Sets the current viewport in normalized coordinates 0-1
  53687. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  53688. */
  53689. setViewport(viewport?: Viewport): void;
  53690. /**
  53691. * Sets the current effect wrapper to use during draw.
  53692. * The effect needs to be ready before calling this api.
  53693. * This also sets the default full screen position attribute.
  53694. * @param effectWrapper Defines the effect to draw with
  53695. */
  53696. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  53697. /**
  53698. * Draws a full screen quad.
  53699. */
  53700. draw(): void;
  53701. /**
  53702. * renders one or more effects to a specified texture
  53703. * @param effectWrappers list of effects to renderer
  53704. * @param outputTexture texture to draw to, if null it will render to the screen
  53705. */
  53706. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  53707. /**
  53708. * Disposes of the effect renderer
  53709. */
  53710. dispose(): void;
  53711. }
  53712. /**
  53713. * Options to create an EffectWrapper
  53714. */
  53715. interface EffectWrapperCreationOptions {
  53716. /**
  53717. * Engine to use to create the effect
  53718. */
  53719. engine: Engine;
  53720. /**
  53721. * Fragment shader for the effect
  53722. */
  53723. fragmentShader: string;
  53724. /**
  53725. * Vertex shader for the effect
  53726. */
  53727. vertexShader?: string;
  53728. /**
  53729. * Attributes to use in the shader
  53730. */
  53731. attributeNames?: Array<string>;
  53732. /**
  53733. * Uniforms to use in the shader
  53734. */
  53735. uniformNames?: Array<string>;
  53736. /**
  53737. * Texture sampler names to use in the shader
  53738. */
  53739. samplerNames?: Array<string>;
  53740. /**
  53741. * The friendly name of the effect displayed in Spector.
  53742. */
  53743. name?: string;
  53744. }
  53745. /**
  53746. * Wraps an effect to be used for rendering
  53747. */
  53748. export class EffectWrapper {
  53749. /**
  53750. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  53751. */
  53752. onApplyObservable: Observable<{}>;
  53753. /**
  53754. * The underlying effect
  53755. */
  53756. effect: Effect;
  53757. /**
  53758. * Creates an effect to be renderer
  53759. * @param creationOptions options to create the effect
  53760. */
  53761. constructor(creationOptions: EffectWrapperCreationOptions);
  53762. /**
  53763. * Disposes of the effect wrapper
  53764. */
  53765. dispose(): void;
  53766. }
  53767. }
  53768. declare module BABYLON {
  53769. /**
  53770. * Helper class to push actions to a pool of workers.
  53771. */
  53772. export class WorkerPool implements IDisposable {
  53773. private _workerInfos;
  53774. private _pendingActions;
  53775. /**
  53776. * Constructor
  53777. * @param workers Array of workers to use for actions
  53778. */
  53779. constructor(workers: Array<Worker>);
  53780. /**
  53781. * Terminates all workers and clears any pending actions.
  53782. */
  53783. dispose(): void;
  53784. /**
  53785. * Pushes an action to the worker pool. If all the workers are active, the action will be
  53786. * pended until a worker has completed its action.
  53787. * @param action The action to perform. Call onComplete when the action is complete.
  53788. */
  53789. push(action: (worker: Worker, onComplete: () => void) => void): void;
  53790. private _execute;
  53791. }
  53792. }
  53793. declare module BABYLON {
  53794. /**
  53795. * Configuration for Draco compression
  53796. */
  53797. export interface IDracoCompressionConfiguration {
  53798. /**
  53799. * Configuration for the decoder.
  53800. */
  53801. decoder: {
  53802. /**
  53803. * The url to the WebAssembly module.
  53804. */
  53805. wasmUrl?: string;
  53806. /**
  53807. * The url to the WebAssembly binary.
  53808. */
  53809. wasmBinaryUrl?: string;
  53810. /**
  53811. * The url to the fallback JavaScript module.
  53812. */
  53813. fallbackUrl?: string;
  53814. };
  53815. }
  53816. /**
  53817. * Draco compression (https://google.github.io/draco/)
  53818. *
  53819. * This class wraps the Draco module.
  53820. *
  53821. * **Encoder**
  53822. *
  53823. * The encoder is not currently implemented.
  53824. *
  53825. * **Decoder**
  53826. *
  53827. * 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.
  53828. *
  53829. * To update the configuration, use the following code:
  53830. * ```javascript
  53831. * DracoCompression.Configuration = {
  53832. * decoder: {
  53833. * wasmUrl: "<url to the WebAssembly library>",
  53834. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  53835. * fallbackUrl: "<url to the fallback JavaScript library>",
  53836. * }
  53837. * };
  53838. * ```
  53839. *
  53840. * 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.
  53841. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  53842. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  53843. *
  53844. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  53845. * ```javascript
  53846. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  53847. * ```
  53848. *
  53849. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  53850. */
  53851. export class DracoCompression implements IDisposable {
  53852. private _workerPoolPromise?;
  53853. private _decoderModulePromise?;
  53854. /**
  53855. * The configuration. Defaults to the following urls:
  53856. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  53857. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  53858. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  53859. */
  53860. static Configuration: IDracoCompressionConfiguration;
  53861. /**
  53862. * Returns true if the decoder configuration is available.
  53863. */
  53864. static readonly DecoderAvailable: boolean;
  53865. /**
  53866. * Default number of workers to create when creating the draco compression object.
  53867. */
  53868. static DefaultNumWorkers: number;
  53869. private static GetDefaultNumWorkers;
  53870. private static _Default;
  53871. /**
  53872. * Default instance for the draco compression object.
  53873. */
  53874. static readonly Default: DracoCompression;
  53875. /**
  53876. * Constructor
  53877. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  53878. */
  53879. constructor(numWorkers?: number);
  53880. /**
  53881. * Stop all async operations and release resources.
  53882. */
  53883. dispose(): void;
  53884. /**
  53885. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  53886. * @returns a promise that resolves when ready
  53887. */
  53888. whenReadyAsync(): Promise<void>;
  53889. /**
  53890. * Decode Draco compressed mesh data to vertex data.
  53891. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  53892. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  53893. * @returns A promise that resolves with the decoded vertex data
  53894. */
  53895. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  53896. [kind: string]: number;
  53897. }): Promise<VertexData>;
  53898. }
  53899. }
  53900. declare module BABYLON {
  53901. /**
  53902. * Class for building Constructive Solid Geometry
  53903. */
  53904. export class CSG {
  53905. private polygons;
  53906. /**
  53907. * The world matrix
  53908. */
  53909. matrix: Matrix;
  53910. /**
  53911. * Stores the position
  53912. */
  53913. position: Vector3;
  53914. /**
  53915. * Stores the rotation
  53916. */
  53917. rotation: Vector3;
  53918. /**
  53919. * Stores the rotation quaternion
  53920. */
  53921. rotationQuaternion: Nullable<Quaternion>;
  53922. /**
  53923. * Stores the scaling vector
  53924. */
  53925. scaling: Vector3;
  53926. /**
  53927. * Convert the Mesh to CSG
  53928. * @param mesh The Mesh to convert to CSG
  53929. * @returns A new CSG from the Mesh
  53930. */
  53931. static FromMesh(mesh: Mesh): CSG;
  53932. /**
  53933. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  53934. * @param polygons Polygons used to construct a CSG solid
  53935. */
  53936. private static FromPolygons;
  53937. /**
  53938. * Clones, or makes a deep copy, of the CSG
  53939. * @returns A new CSG
  53940. */
  53941. clone(): CSG;
  53942. /**
  53943. * Unions this CSG with another CSG
  53944. * @param csg The CSG to union against this CSG
  53945. * @returns The unioned CSG
  53946. */
  53947. union(csg: CSG): CSG;
  53948. /**
  53949. * Unions this CSG with another CSG in place
  53950. * @param csg The CSG to union against this CSG
  53951. */
  53952. unionInPlace(csg: CSG): void;
  53953. /**
  53954. * Subtracts this CSG with another CSG
  53955. * @param csg The CSG to subtract against this CSG
  53956. * @returns A new CSG
  53957. */
  53958. subtract(csg: CSG): CSG;
  53959. /**
  53960. * Subtracts this CSG with another CSG in place
  53961. * @param csg The CSG to subtact against this CSG
  53962. */
  53963. subtractInPlace(csg: CSG): void;
  53964. /**
  53965. * Intersect this CSG with another CSG
  53966. * @param csg The CSG to intersect against this CSG
  53967. * @returns A new CSG
  53968. */
  53969. intersect(csg: CSG): CSG;
  53970. /**
  53971. * Intersects this CSG with another CSG in place
  53972. * @param csg The CSG to intersect against this CSG
  53973. */
  53974. intersectInPlace(csg: CSG): void;
  53975. /**
  53976. * Return a new CSG solid with solid and empty space switched. This solid is
  53977. * not modified.
  53978. * @returns A new CSG solid with solid and empty space switched
  53979. */
  53980. inverse(): CSG;
  53981. /**
  53982. * Inverses the CSG in place
  53983. */
  53984. inverseInPlace(): void;
  53985. /**
  53986. * This is used to keep meshes transformations so they can be restored
  53987. * when we build back a Babylon Mesh
  53988. * NB : All CSG operations are performed in world coordinates
  53989. * @param csg The CSG to copy the transform attributes from
  53990. * @returns This CSG
  53991. */
  53992. copyTransformAttributes(csg: CSG): CSG;
  53993. /**
  53994. * Build Raw mesh from CSG
  53995. * Coordinates here are in world space
  53996. * @param name The name of the mesh geometry
  53997. * @param scene The Scene
  53998. * @param keepSubMeshes Specifies if the submeshes should be kept
  53999. * @returns A new Mesh
  54000. */
  54001. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  54002. /**
  54003. * Build Mesh from CSG taking material and transforms into account
  54004. * @param name The name of the Mesh
  54005. * @param material The material of the Mesh
  54006. * @param scene The Scene
  54007. * @param keepSubMeshes Specifies if submeshes should be kept
  54008. * @returns The new Mesh
  54009. */
  54010. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  54011. }
  54012. }
  54013. declare module BABYLON {
  54014. /**
  54015. * Class used to create a trail following a mesh
  54016. */
  54017. export class TrailMesh extends Mesh {
  54018. private _generator;
  54019. private _autoStart;
  54020. private _running;
  54021. private _diameter;
  54022. private _length;
  54023. private _sectionPolygonPointsCount;
  54024. private _sectionVectors;
  54025. private _sectionNormalVectors;
  54026. private _beforeRenderObserver;
  54027. /**
  54028. * @constructor
  54029. * @param name The value used by scene.getMeshByName() to do a lookup.
  54030. * @param generator The mesh to generate a trail.
  54031. * @param scene The scene to add this mesh to.
  54032. * @param diameter Diameter of trailing mesh. Default is 1.
  54033. * @param length Length of trailing mesh. Default is 60.
  54034. * @param autoStart Automatically start trailing mesh. Default true.
  54035. */
  54036. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  54037. /**
  54038. * "TrailMesh"
  54039. * @returns "TrailMesh"
  54040. */
  54041. getClassName(): string;
  54042. private _createMesh;
  54043. /**
  54044. * Start trailing mesh.
  54045. */
  54046. start(): void;
  54047. /**
  54048. * Stop trailing mesh.
  54049. */
  54050. stop(): void;
  54051. /**
  54052. * Update trailing mesh geometry.
  54053. */
  54054. update(): void;
  54055. /**
  54056. * Returns a new TrailMesh object.
  54057. * @param name is a string, the name given to the new mesh
  54058. * @param newGenerator use new generator object for cloned trail mesh
  54059. * @returns a new mesh
  54060. */
  54061. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  54062. /**
  54063. * Serializes this trail mesh
  54064. * @param serializationObject object to write serialization to
  54065. */
  54066. serialize(serializationObject: any): void;
  54067. /**
  54068. * Parses a serialized trail mesh
  54069. * @param parsedMesh the serialized mesh
  54070. * @param scene the scene to create the trail mesh in
  54071. * @returns the created trail mesh
  54072. */
  54073. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  54074. }
  54075. }
  54076. declare module BABYLON {
  54077. /**
  54078. * Class containing static functions to help procedurally build meshes
  54079. */
  54080. export class TiledBoxBuilder {
  54081. /**
  54082. * Creates a box mesh
  54083. * 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)
  54084. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54085. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54086. * * 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
  54087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54088. * @param name defines the name of the mesh
  54089. * @param options defines the options used to create the mesh
  54090. * @param scene defines the hosting scene
  54091. * @returns the box mesh
  54092. */
  54093. static CreateTiledBox(name: string, options: {
  54094. pattern?: number;
  54095. width?: number;
  54096. height?: number;
  54097. depth?: number;
  54098. tileSize?: number;
  54099. tileWidth?: number;
  54100. tileHeight?: number;
  54101. alignHorizontal?: number;
  54102. alignVertical?: number;
  54103. faceUV?: Vector4[];
  54104. faceColors?: Color4[];
  54105. sideOrientation?: number;
  54106. updatable?: boolean;
  54107. }, scene?: Nullable<Scene>): Mesh;
  54108. }
  54109. }
  54110. declare module BABYLON {
  54111. /**
  54112. * Class containing static functions to help procedurally build meshes
  54113. */
  54114. export class TorusKnotBuilder {
  54115. /**
  54116. * Creates a torus knot mesh
  54117. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  54118. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  54119. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  54120. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  54121. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54122. * * 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
  54123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54124. * @param name defines the name of the mesh
  54125. * @param options defines the options used to create the mesh
  54126. * @param scene defines the hosting scene
  54127. * @returns the torus knot mesh
  54128. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54129. */
  54130. static CreateTorusKnot(name: string, options: {
  54131. radius?: number;
  54132. tube?: number;
  54133. radialSegments?: number;
  54134. tubularSegments?: number;
  54135. p?: number;
  54136. q?: number;
  54137. updatable?: boolean;
  54138. sideOrientation?: number;
  54139. frontUVs?: Vector4;
  54140. backUVs?: Vector4;
  54141. }, scene: any): Mesh;
  54142. }
  54143. }
  54144. declare module BABYLON {
  54145. /**
  54146. * Polygon
  54147. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  54148. */
  54149. export class Polygon {
  54150. /**
  54151. * Creates a rectangle
  54152. * @param xmin bottom X coord
  54153. * @param ymin bottom Y coord
  54154. * @param xmax top X coord
  54155. * @param ymax top Y coord
  54156. * @returns points that make the resulting rectation
  54157. */
  54158. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  54159. /**
  54160. * Creates a circle
  54161. * @param radius radius of circle
  54162. * @param cx scale in x
  54163. * @param cy scale in y
  54164. * @param numberOfSides number of sides that make up the circle
  54165. * @returns points that make the resulting circle
  54166. */
  54167. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  54168. /**
  54169. * Creates a polygon from input string
  54170. * @param input Input polygon data
  54171. * @returns the parsed points
  54172. */
  54173. static Parse(input: string): Vector2[];
  54174. /**
  54175. * Starts building a polygon from x and y coordinates
  54176. * @param x x coordinate
  54177. * @param y y coordinate
  54178. * @returns the started path2
  54179. */
  54180. static StartingAt(x: number, y: number): Path2;
  54181. }
  54182. /**
  54183. * Builds a polygon
  54184. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  54185. */
  54186. export class PolygonMeshBuilder {
  54187. private _points;
  54188. private _outlinepoints;
  54189. private _holes;
  54190. private _name;
  54191. private _scene;
  54192. private _epoints;
  54193. private _eholes;
  54194. private _addToepoint;
  54195. /**
  54196. * Babylon reference to the earcut plugin.
  54197. */
  54198. bjsEarcut: any;
  54199. /**
  54200. * Creates a PolygonMeshBuilder
  54201. * @param name name of the builder
  54202. * @param contours Path of the polygon
  54203. * @param scene scene to add to when creating the mesh
  54204. * @param earcutInjection can be used to inject your own earcut reference
  54205. */
  54206. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  54207. /**
  54208. * Adds a whole within the polygon
  54209. * @param hole Array of points defining the hole
  54210. * @returns this
  54211. */
  54212. addHole(hole: Vector2[]): PolygonMeshBuilder;
  54213. /**
  54214. * Creates the polygon
  54215. * @param updatable If the mesh should be updatable
  54216. * @param depth The depth of the mesh created
  54217. * @returns the created mesh
  54218. */
  54219. build(updatable?: boolean, depth?: number): Mesh;
  54220. /**
  54221. * Creates the polygon
  54222. * @param depth The depth of the mesh created
  54223. * @returns the created VertexData
  54224. */
  54225. buildVertexData(depth?: number): VertexData;
  54226. /**
  54227. * Adds a side to the polygon
  54228. * @param positions points that make the polygon
  54229. * @param normals normals of the polygon
  54230. * @param uvs uvs of the polygon
  54231. * @param indices indices of the polygon
  54232. * @param bounds bounds of the polygon
  54233. * @param points points of the polygon
  54234. * @param depth depth of the polygon
  54235. * @param flip flip of the polygon
  54236. */
  54237. private addSide;
  54238. }
  54239. }
  54240. declare module BABYLON {
  54241. /**
  54242. * Class containing static functions to help procedurally build meshes
  54243. */
  54244. export class PolygonBuilder {
  54245. /**
  54246. * Creates a polygon mesh
  54247. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  54248. * * 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
  54249. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54251. * * 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)
  54252. * * Remember you can only change the shape positions, not their number when updating a polygon
  54253. * @param name defines the name of the mesh
  54254. * @param options defines the options used to create the mesh
  54255. * @param scene defines the hosting scene
  54256. * @param earcutInjection can be used to inject your own earcut reference
  54257. * @returns the polygon mesh
  54258. */
  54259. static CreatePolygon(name: string, options: {
  54260. shape: Vector3[];
  54261. holes?: Vector3[][];
  54262. depth?: number;
  54263. faceUV?: Vector4[];
  54264. faceColors?: Color4[];
  54265. updatable?: boolean;
  54266. sideOrientation?: number;
  54267. frontUVs?: Vector4;
  54268. backUVs?: Vector4;
  54269. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54270. /**
  54271. * Creates an extruded polygon mesh, with depth in the Y direction.
  54272. * * 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)
  54273. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54274. * @param name defines the name of the mesh
  54275. * @param options defines the options used to create the mesh
  54276. * @param scene defines the hosting scene
  54277. * @param earcutInjection can be used to inject your own earcut reference
  54278. * @returns the polygon mesh
  54279. */
  54280. static ExtrudePolygon(name: string, options: {
  54281. shape: Vector3[];
  54282. holes?: Vector3[][];
  54283. depth?: number;
  54284. faceUV?: Vector4[];
  54285. faceColors?: Color4[];
  54286. updatable?: boolean;
  54287. sideOrientation?: number;
  54288. frontUVs?: Vector4;
  54289. backUVs?: Vector4;
  54290. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54291. }
  54292. }
  54293. declare module BABYLON {
  54294. /**
  54295. * Class containing static functions to help procedurally build meshes
  54296. */
  54297. export class LatheBuilder {
  54298. /**
  54299. * Creates lathe mesh.
  54300. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  54301. * * 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
  54302. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  54303. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  54304. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  54305. * * 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
  54306. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  54307. * * 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
  54308. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54309. * * 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
  54310. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54312. * @param name defines the name of the mesh
  54313. * @param options defines the options used to create the mesh
  54314. * @param scene defines the hosting scene
  54315. * @returns the lathe mesh
  54316. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  54317. */
  54318. static CreateLathe(name: string, options: {
  54319. shape: Vector3[];
  54320. radius?: number;
  54321. tessellation?: number;
  54322. clip?: number;
  54323. arc?: number;
  54324. closed?: boolean;
  54325. updatable?: boolean;
  54326. sideOrientation?: number;
  54327. frontUVs?: Vector4;
  54328. backUVs?: Vector4;
  54329. cap?: number;
  54330. invertUV?: boolean;
  54331. }, scene?: Nullable<Scene>): Mesh;
  54332. }
  54333. }
  54334. declare module BABYLON {
  54335. /**
  54336. * Class containing static functions to help procedurally build meshes
  54337. */
  54338. export class TiledPlaneBuilder {
  54339. /**
  54340. * Creates a tiled plane mesh
  54341. * * The parameter `pattern` will, depending on value, do nothing or
  54342. * * * flip (reflect about central vertical) alternate tiles across and up
  54343. * * * flip every tile on alternate rows
  54344. * * * rotate (180 degs) alternate tiles across and up
  54345. * * * rotate every tile on alternate rows
  54346. * * * flip and rotate alternate tiles across and up
  54347. * * * flip and rotate every tile on alternate rows
  54348. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  54349. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  54350. * * 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
  54351. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54352. * * 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)
  54353. * * 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)
  54354. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54355. * @param name defines the name of the mesh
  54356. * @param options defines the options used to create the mesh
  54357. * @param scene defines the hosting scene
  54358. * @returns the box mesh
  54359. */
  54360. static CreateTiledPlane(name: string, options: {
  54361. pattern?: number;
  54362. tileSize?: number;
  54363. tileWidth?: number;
  54364. tileHeight?: number;
  54365. size?: number;
  54366. width?: number;
  54367. height?: number;
  54368. alignHorizontal?: number;
  54369. alignVertical?: number;
  54370. sideOrientation?: number;
  54371. frontUVs?: Vector4;
  54372. backUVs?: Vector4;
  54373. updatable?: boolean;
  54374. }, scene?: Nullable<Scene>): Mesh;
  54375. }
  54376. }
  54377. declare module BABYLON {
  54378. /**
  54379. * Class containing static functions to help procedurally build meshes
  54380. */
  54381. export class TubeBuilder {
  54382. /**
  54383. * Creates a tube mesh.
  54384. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54385. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  54386. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  54387. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  54388. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  54389. * * 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)
  54390. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  54391. * * 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
  54392. * * 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
  54393. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54394. * * 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
  54395. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54397. * @param name defines the name of the mesh
  54398. * @param options defines the options used to create the mesh
  54399. * @param scene defines the hosting scene
  54400. * @returns the tube mesh
  54401. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54402. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  54403. */
  54404. static CreateTube(name: string, options: {
  54405. path: Vector3[];
  54406. radius?: number;
  54407. tessellation?: number;
  54408. radiusFunction?: {
  54409. (i: number, distance: number): number;
  54410. };
  54411. cap?: number;
  54412. arc?: number;
  54413. updatable?: boolean;
  54414. sideOrientation?: number;
  54415. frontUVs?: Vector4;
  54416. backUVs?: Vector4;
  54417. instance?: Mesh;
  54418. invertUV?: boolean;
  54419. }, scene?: Nullable<Scene>): Mesh;
  54420. }
  54421. }
  54422. declare module BABYLON {
  54423. /**
  54424. * Class containing static functions to help procedurally build meshes
  54425. */
  54426. export class IcoSphereBuilder {
  54427. /**
  54428. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  54429. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  54430. * * 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`)
  54431. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  54432. * * 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
  54433. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54434. * * 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
  54435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54436. * @param name defines the name of the mesh
  54437. * @param options defines the options used to create the mesh
  54438. * @param scene defines the hosting scene
  54439. * @returns the icosahedron mesh
  54440. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  54441. */
  54442. static CreateIcoSphere(name: string, options: {
  54443. radius?: number;
  54444. radiusX?: number;
  54445. radiusY?: number;
  54446. radiusZ?: number;
  54447. flat?: boolean;
  54448. subdivisions?: number;
  54449. sideOrientation?: number;
  54450. frontUVs?: Vector4;
  54451. backUVs?: Vector4;
  54452. updatable?: boolean;
  54453. }, scene?: Nullable<Scene>): Mesh;
  54454. }
  54455. }
  54456. declare module BABYLON {
  54457. /**
  54458. * Class containing static functions to help procedurally build meshes
  54459. */
  54460. export class DecalBuilder {
  54461. /**
  54462. * Creates a decal mesh.
  54463. * 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
  54464. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  54465. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  54466. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  54467. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  54468. * @param name defines the name of the mesh
  54469. * @param sourceMesh defines the mesh where the decal must be applied
  54470. * @param options defines the options used to create the mesh
  54471. * @param scene defines the hosting scene
  54472. * @returns the decal mesh
  54473. * @see https://doc.babylonjs.com/how_to/decals
  54474. */
  54475. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  54476. position?: Vector3;
  54477. normal?: Vector3;
  54478. size?: Vector3;
  54479. angle?: number;
  54480. }): Mesh;
  54481. }
  54482. }
  54483. declare module BABYLON {
  54484. /**
  54485. * Class containing static functions to help procedurally build meshes
  54486. */
  54487. export class MeshBuilder {
  54488. /**
  54489. * Creates a box mesh
  54490. * * The parameter `size` sets the size (float) of each box side (default 1)
  54491. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54492. * * 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)
  54493. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54494. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54495. * * 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
  54496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54497. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54498. * @param name defines the name of the mesh
  54499. * @param options defines the options used to create the mesh
  54500. * @param scene defines the hosting scene
  54501. * @returns the box mesh
  54502. */
  54503. static CreateBox(name: string, options: {
  54504. size?: number;
  54505. width?: number;
  54506. height?: number;
  54507. depth?: number;
  54508. faceUV?: Vector4[];
  54509. faceColors?: Color4[];
  54510. sideOrientation?: number;
  54511. frontUVs?: Vector4;
  54512. backUVs?: Vector4;
  54513. updatable?: boolean;
  54514. }, scene?: Nullable<Scene>): Mesh;
  54515. /**
  54516. * Creates a tiled box mesh
  54517. * * faceTiles sets the pattern, tile size and number of tiles for a face
  54518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54519. * @param name defines the name of the mesh
  54520. * @param options defines the options used to create the mesh
  54521. * @param scene defines the hosting scene
  54522. * @returns the tiled box mesh
  54523. */
  54524. static CreateTiledBox(name: string, options: {
  54525. pattern?: number;
  54526. size?: number;
  54527. width?: number;
  54528. height?: number;
  54529. depth: number;
  54530. tileSize?: number;
  54531. tileWidth?: number;
  54532. tileHeight?: number;
  54533. faceUV?: Vector4[];
  54534. faceColors?: Color4[];
  54535. alignHorizontal?: number;
  54536. alignVertical?: number;
  54537. sideOrientation?: number;
  54538. updatable?: boolean;
  54539. }, scene?: Nullable<Scene>): Mesh;
  54540. /**
  54541. * Creates a sphere mesh
  54542. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  54543. * * 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`)
  54544. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  54545. * * 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
  54546. * * 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)
  54547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54548. * * 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
  54549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54550. * @param name defines the name of the mesh
  54551. * @param options defines the options used to create the mesh
  54552. * @param scene defines the hosting scene
  54553. * @returns the sphere mesh
  54554. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  54555. */
  54556. static CreateSphere(name: string, options: {
  54557. segments?: number;
  54558. diameter?: number;
  54559. diameterX?: number;
  54560. diameterY?: number;
  54561. diameterZ?: number;
  54562. arc?: number;
  54563. slice?: number;
  54564. sideOrientation?: number;
  54565. frontUVs?: Vector4;
  54566. backUVs?: Vector4;
  54567. updatable?: boolean;
  54568. }, scene?: Nullable<Scene>): Mesh;
  54569. /**
  54570. * Creates a plane polygonal mesh. By default, this is a disc
  54571. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  54572. * * 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
  54573. * * 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
  54574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54575. * * 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
  54576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54577. * @param name defines the name of the mesh
  54578. * @param options defines the options used to create the mesh
  54579. * @param scene defines the hosting scene
  54580. * @returns the plane polygonal mesh
  54581. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  54582. */
  54583. static CreateDisc(name: string, options: {
  54584. radius?: number;
  54585. tessellation?: number;
  54586. arc?: number;
  54587. updatable?: boolean;
  54588. sideOrientation?: number;
  54589. frontUVs?: Vector4;
  54590. backUVs?: Vector4;
  54591. }, scene?: Nullable<Scene>): Mesh;
  54592. /**
  54593. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  54594. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  54595. * * 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`)
  54596. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  54597. * * 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
  54598. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54599. * * 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
  54600. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54601. * @param name defines the name of the mesh
  54602. * @param options defines the options used to create the mesh
  54603. * @param scene defines the hosting scene
  54604. * @returns the icosahedron mesh
  54605. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  54606. */
  54607. static CreateIcoSphere(name: string, options: {
  54608. radius?: number;
  54609. radiusX?: number;
  54610. radiusY?: number;
  54611. radiusZ?: number;
  54612. flat?: boolean;
  54613. subdivisions?: number;
  54614. sideOrientation?: number;
  54615. frontUVs?: Vector4;
  54616. backUVs?: Vector4;
  54617. updatable?: boolean;
  54618. }, scene?: Nullable<Scene>): Mesh;
  54619. /**
  54620. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54621. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54622. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54623. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54624. * * 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
  54625. * * 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
  54626. * * 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
  54627. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54628. * * 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
  54629. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54630. * * 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
  54631. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54632. * * 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
  54633. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54635. * @param name defines the name of the mesh
  54636. * @param options defines the options used to create the mesh
  54637. * @param scene defines the hosting scene
  54638. * @returns the ribbon mesh
  54639. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54640. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54641. */
  54642. static CreateRibbon(name: string, options: {
  54643. pathArray: Vector3[][];
  54644. closeArray?: boolean;
  54645. closePath?: boolean;
  54646. offset?: number;
  54647. updatable?: boolean;
  54648. sideOrientation?: number;
  54649. frontUVs?: Vector4;
  54650. backUVs?: Vector4;
  54651. instance?: Mesh;
  54652. invertUV?: boolean;
  54653. uvs?: Vector2[];
  54654. colors?: Color4[];
  54655. }, scene?: Nullable<Scene>): Mesh;
  54656. /**
  54657. * Creates a cylinder or a cone mesh
  54658. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  54659. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  54660. * * 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.
  54661. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  54662. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  54663. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  54664. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  54665. * * 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).
  54666. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  54667. * * 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).
  54668. * * 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
  54669. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  54670. * * 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
  54671. * * 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.
  54672. * * If `enclose` is false, a ring surface is one element.
  54673. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  54674. * * 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
  54675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54676. * * 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
  54677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54678. * @param name defines the name of the mesh
  54679. * @param options defines the options used to create the mesh
  54680. * @param scene defines the hosting scene
  54681. * @returns the cylinder mesh
  54682. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  54683. */
  54684. static CreateCylinder(name: string, options: {
  54685. height?: number;
  54686. diameterTop?: number;
  54687. diameterBottom?: number;
  54688. diameter?: number;
  54689. tessellation?: number;
  54690. subdivisions?: number;
  54691. arc?: number;
  54692. faceColors?: Color4[];
  54693. faceUV?: Vector4[];
  54694. updatable?: boolean;
  54695. hasRings?: boolean;
  54696. enclose?: boolean;
  54697. cap?: number;
  54698. sideOrientation?: number;
  54699. frontUVs?: Vector4;
  54700. backUVs?: Vector4;
  54701. }, scene?: Nullable<Scene>): Mesh;
  54702. /**
  54703. * Creates a torus mesh
  54704. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  54705. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  54706. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  54707. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54708. * * 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
  54709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54710. * @param name defines the name of the mesh
  54711. * @param options defines the options used to create the mesh
  54712. * @param scene defines the hosting scene
  54713. * @returns the torus mesh
  54714. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  54715. */
  54716. static CreateTorus(name: string, options: {
  54717. diameter?: number;
  54718. thickness?: number;
  54719. tessellation?: number;
  54720. updatable?: boolean;
  54721. sideOrientation?: number;
  54722. frontUVs?: Vector4;
  54723. backUVs?: Vector4;
  54724. }, scene?: Nullable<Scene>): Mesh;
  54725. /**
  54726. * Creates a torus knot mesh
  54727. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  54728. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  54729. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  54730. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  54731. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54732. * * 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
  54733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54734. * @param name defines the name of the mesh
  54735. * @param options defines the options used to create the mesh
  54736. * @param scene defines the hosting scene
  54737. * @returns the torus knot mesh
  54738. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54739. */
  54740. static CreateTorusKnot(name: string, options: {
  54741. radius?: number;
  54742. tube?: number;
  54743. radialSegments?: number;
  54744. tubularSegments?: number;
  54745. p?: number;
  54746. q?: number;
  54747. updatable?: boolean;
  54748. sideOrientation?: number;
  54749. frontUVs?: Vector4;
  54750. backUVs?: Vector4;
  54751. }, scene?: Nullable<Scene>): Mesh;
  54752. /**
  54753. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  54754. * * 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
  54755. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  54756. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  54757. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  54758. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  54759. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54760. * * 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
  54761. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  54762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54763. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  54764. * @param name defines the name of the new line system
  54765. * @param options defines the options used to create the line system
  54766. * @param scene defines the hosting scene
  54767. * @returns a new line system mesh
  54768. */
  54769. static CreateLineSystem(name: string, options: {
  54770. lines: Vector3[][];
  54771. updatable?: boolean;
  54772. instance?: Nullable<LinesMesh>;
  54773. colors?: Nullable<Color4[][]>;
  54774. useVertexAlpha?: boolean;
  54775. }, scene: Nullable<Scene>): LinesMesh;
  54776. /**
  54777. * Creates a line mesh
  54778. * 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
  54779. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54780. * * The parameter `points` is an array successive Vector3
  54781. * * 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
  54782. * * The optional parameter `colors` is an array of successive Color4, one per line point
  54783. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  54784. * * When updating an instance, remember that only point positions can change, not the number of points
  54785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54786. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  54787. * @param name defines the name of the new line system
  54788. * @param options defines the options used to create the line system
  54789. * @param scene defines the hosting scene
  54790. * @returns a new line mesh
  54791. */
  54792. static CreateLines(name: string, options: {
  54793. points: Vector3[];
  54794. updatable?: boolean;
  54795. instance?: Nullable<LinesMesh>;
  54796. colors?: Color4[];
  54797. useVertexAlpha?: boolean;
  54798. }, scene?: Nullable<Scene>): LinesMesh;
  54799. /**
  54800. * Creates a dashed line mesh
  54801. * * 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
  54802. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54803. * * The parameter `points` is an array successive Vector3
  54804. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  54805. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  54806. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  54807. * * 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
  54808. * * When updating an instance, remember that only point positions can change, not the number of points
  54809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54810. * @param name defines the name of the mesh
  54811. * @param options defines the options used to create the mesh
  54812. * @param scene defines the hosting scene
  54813. * @returns the dashed line mesh
  54814. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  54815. */
  54816. static CreateDashedLines(name: string, options: {
  54817. points: Vector3[];
  54818. dashSize?: number;
  54819. gapSize?: number;
  54820. dashNb?: number;
  54821. updatable?: boolean;
  54822. instance?: LinesMesh;
  54823. }, scene?: Nullable<Scene>): LinesMesh;
  54824. /**
  54825. * 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.
  54826. * * 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.
  54827. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54828. * * 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.
  54829. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54830. * * 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
  54831. * * 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
  54832. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54833. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54834. * * 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
  54835. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54837. * @param name defines the name of the mesh
  54838. * @param options defines the options used to create the mesh
  54839. * @param scene defines the hosting scene
  54840. * @returns the extruded shape mesh
  54841. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54842. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54843. */
  54844. static ExtrudeShape(name: string, options: {
  54845. shape: Vector3[];
  54846. path: Vector3[];
  54847. scale?: number;
  54848. rotation?: number;
  54849. cap?: number;
  54850. updatable?: boolean;
  54851. sideOrientation?: number;
  54852. frontUVs?: Vector4;
  54853. backUVs?: Vector4;
  54854. instance?: Mesh;
  54855. invertUV?: boolean;
  54856. }, scene?: Nullable<Scene>): Mesh;
  54857. /**
  54858. * Creates an custom extruded shape mesh.
  54859. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54860. * * 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.
  54861. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54862. * * 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
  54863. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54864. * * 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
  54865. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54866. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54867. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54868. * * 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
  54869. * * 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
  54870. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54871. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54872. * * 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
  54873. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54875. * @param name defines the name of the mesh
  54876. * @param options defines the options used to create the mesh
  54877. * @param scene defines the hosting scene
  54878. * @returns the custom extruded shape mesh
  54879. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54880. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54881. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54882. */
  54883. static ExtrudeShapeCustom(name: string, options: {
  54884. shape: Vector3[];
  54885. path: Vector3[];
  54886. scaleFunction?: any;
  54887. rotationFunction?: any;
  54888. ribbonCloseArray?: boolean;
  54889. ribbonClosePath?: boolean;
  54890. cap?: number;
  54891. updatable?: boolean;
  54892. sideOrientation?: number;
  54893. frontUVs?: Vector4;
  54894. backUVs?: Vector4;
  54895. instance?: Mesh;
  54896. invertUV?: boolean;
  54897. }, scene?: Nullable<Scene>): Mesh;
  54898. /**
  54899. * Creates lathe mesh.
  54900. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  54901. * * 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
  54902. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  54903. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  54904. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  54905. * * 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
  54906. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  54907. * * 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
  54908. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54909. * * 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
  54910. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54912. * @param name defines the name of the mesh
  54913. * @param options defines the options used to create the mesh
  54914. * @param scene defines the hosting scene
  54915. * @returns the lathe mesh
  54916. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  54917. */
  54918. static CreateLathe(name: string, options: {
  54919. shape: Vector3[];
  54920. radius?: number;
  54921. tessellation?: number;
  54922. clip?: number;
  54923. arc?: number;
  54924. closed?: boolean;
  54925. updatable?: boolean;
  54926. sideOrientation?: number;
  54927. frontUVs?: Vector4;
  54928. backUVs?: Vector4;
  54929. cap?: number;
  54930. invertUV?: boolean;
  54931. }, scene?: Nullable<Scene>): Mesh;
  54932. /**
  54933. * Creates a tiled plane mesh
  54934. * * You can set a limited pattern arrangement with the tiles
  54935. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54936. * * 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
  54937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54938. * @param name defines the name of the mesh
  54939. * @param options defines the options used to create the mesh
  54940. * @param scene defines the hosting scene
  54941. * @returns the plane mesh
  54942. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  54943. */
  54944. static CreateTiledPlane(name: string, options: {
  54945. pattern?: number;
  54946. tileSize?: number;
  54947. tileWidth?: number;
  54948. tileHeight?: number;
  54949. size?: number;
  54950. width?: number;
  54951. height?: number;
  54952. alignHorizontal?: number;
  54953. alignVertical?: number;
  54954. sideOrientation?: number;
  54955. frontUVs?: Vector4;
  54956. backUVs?: Vector4;
  54957. updatable?: boolean;
  54958. }, scene?: Nullable<Scene>): Mesh;
  54959. /**
  54960. * Creates a plane mesh
  54961. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  54962. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  54963. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  54964. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54965. * * 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
  54966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54967. * @param name defines the name of the mesh
  54968. * @param options defines the options used to create the mesh
  54969. * @param scene defines the hosting scene
  54970. * @returns the plane mesh
  54971. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  54972. */
  54973. static CreatePlane(name: string, options: {
  54974. size?: number;
  54975. width?: number;
  54976. height?: number;
  54977. sideOrientation?: number;
  54978. frontUVs?: Vector4;
  54979. backUVs?: Vector4;
  54980. updatable?: boolean;
  54981. sourcePlane?: Plane;
  54982. }, scene?: Nullable<Scene>): Mesh;
  54983. /**
  54984. * Creates a ground mesh
  54985. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  54986. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  54987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54988. * @param name defines the name of the mesh
  54989. * @param options defines the options used to create the mesh
  54990. * @param scene defines the hosting scene
  54991. * @returns the ground mesh
  54992. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  54993. */
  54994. static CreateGround(name: string, options: {
  54995. width?: number;
  54996. height?: number;
  54997. subdivisions?: number;
  54998. subdivisionsX?: number;
  54999. subdivisionsY?: number;
  55000. updatable?: boolean;
  55001. }, scene?: Nullable<Scene>): Mesh;
  55002. /**
  55003. * Creates a tiled ground mesh
  55004. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  55005. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  55006. * * 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
  55007. * * 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
  55008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55009. * @param name defines the name of the mesh
  55010. * @param options defines the options used to create the mesh
  55011. * @param scene defines the hosting scene
  55012. * @returns the tiled ground mesh
  55013. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  55014. */
  55015. static CreateTiledGround(name: string, options: {
  55016. xmin: number;
  55017. zmin: number;
  55018. xmax: number;
  55019. zmax: number;
  55020. subdivisions?: {
  55021. w: number;
  55022. h: number;
  55023. };
  55024. precision?: {
  55025. w: number;
  55026. h: number;
  55027. };
  55028. updatable?: boolean;
  55029. }, scene?: Nullable<Scene>): Mesh;
  55030. /**
  55031. * Creates a ground mesh from a height map
  55032. * * The parameter `url` sets the URL of the height map image resource.
  55033. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  55034. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  55035. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  55036. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  55037. * * 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.
  55038. * * 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).
  55039. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  55040. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55041. * @param name defines the name of the mesh
  55042. * @param url defines the url to the height map
  55043. * @param options defines the options used to create the mesh
  55044. * @param scene defines the hosting scene
  55045. * @returns the ground mesh
  55046. * @see https://doc.babylonjs.com/babylon101/height_map
  55047. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  55048. */
  55049. static CreateGroundFromHeightMap(name: string, url: string, options: {
  55050. width?: number;
  55051. height?: number;
  55052. subdivisions?: number;
  55053. minHeight?: number;
  55054. maxHeight?: number;
  55055. colorFilter?: Color3;
  55056. alphaFilter?: number;
  55057. updatable?: boolean;
  55058. onReady?: (mesh: GroundMesh) => void;
  55059. }, scene?: Nullable<Scene>): GroundMesh;
  55060. /**
  55061. * Creates a polygon mesh
  55062. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55063. * * 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
  55064. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55066. * * 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)
  55067. * * Remember you can only change the shape positions, not their number when updating a polygon
  55068. * @param name defines the name of the mesh
  55069. * @param options defines the options used to create the mesh
  55070. * @param scene defines the hosting scene
  55071. * @param earcutInjection can be used to inject your own earcut reference
  55072. * @returns the polygon mesh
  55073. */
  55074. static CreatePolygon(name: string, options: {
  55075. shape: Vector3[];
  55076. holes?: Vector3[][];
  55077. depth?: number;
  55078. faceUV?: Vector4[];
  55079. faceColors?: Color4[];
  55080. updatable?: boolean;
  55081. sideOrientation?: number;
  55082. frontUVs?: Vector4;
  55083. backUVs?: Vector4;
  55084. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55085. /**
  55086. * Creates an extruded polygon mesh, with depth in the Y direction.
  55087. * * 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)
  55088. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55089. * @param name defines the name of the mesh
  55090. * @param options defines the options used to create the mesh
  55091. * @param scene defines the hosting scene
  55092. * @param earcutInjection can be used to inject your own earcut reference
  55093. * @returns the polygon mesh
  55094. */
  55095. static ExtrudePolygon(name: string, options: {
  55096. shape: Vector3[];
  55097. holes?: Vector3[][];
  55098. depth?: number;
  55099. faceUV?: Vector4[];
  55100. faceColors?: Color4[];
  55101. updatable?: boolean;
  55102. sideOrientation?: number;
  55103. frontUVs?: Vector4;
  55104. backUVs?: Vector4;
  55105. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55106. /**
  55107. * Creates a tube mesh.
  55108. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55109. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55110. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55111. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55112. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55113. * * 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)
  55114. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55115. * * 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
  55116. * * 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
  55117. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55118. * * 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
  55119. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55121. * @param name defines the name of the mesh
  55122. * @param options defines the options used to create the mesh
  55123. * @param scene defines the hosting scene
  55124. * @returns the tube mesh
  55125. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55126. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55127. */
  55128. static CreateTube(name: string, options: {
  55129. path: Vector3[];
  55130. radius?: number;
  55131. tessellation?: number;
  55132. radiusFunction?: {
  55133. (i: number, distance: number): number;
  55134. };
  55135. cap?: number;
  55136. arc?: number;
  55137. updatable?: boolean;
  55138. sideOrientation?: number;
  55139. frontUVs?: Vector4;
  55140. backUVs?: Vector4;
  55141. instance?: Mesh;
  55142. invertUV?: boolean;
  55143. }, scene?: Nullable<Scene>): Mesh;
  55144. /**
  55145. * Creates a polyhedron mesh
  55146. * * 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
  55147. * * The parameter `size` (positive float, default 1) sets the polygon size
  55148. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55149. * * 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`
  55150. * * 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
  55151. * * 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)`)
  55152. * * 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
  55153. * * 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
  55154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55155. * * 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
  55156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55157. * @param name defines the name of the mesh
  55158. * @param options defines the options used to create the mesh
  55159. * @param scene defines the hosting scene
  55160. * @returns the polyhedron mesh
  55161. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55162. */
  55163. static CreatePolyhedron(name: string, options: {
  55164. type?: number;
  55165. size?: number;
  55166. sizeX?: number;
  55167. sizeY?: number;
  55168. sizeZ?: number;
  55169. custom?: any;
  55170. faceUV?: Vector4[];
  55171. faceColors?: Color4[];
  55172. flat?: boolean;
  55173. updatable?: boolean;
  55174. sideOrientation?: number;
  55175. frontUVs?: Vector4;
  55176. backUVs?: Vector4;
  55177. }, scene?: Nullable<Scene>): Mesh;
  55178. /**
  55179. * Creates a decal mesh.
  55180. * 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
  55181. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55182. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55183. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55184. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55185. * @param name defines the name of the mesh
  55186. * @param sourceMesh defines the mesh where the decal must be applied
  55187. * @param options defines the options used to create the mesh
  55188. * @param scene defines the hosting scene
  55189. * @returns the decal mesh
  55190. * @see https://doc.babylonjs.com/how_to/decals
  55191. */
  55192. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55193. position?: Vector3;
  55194. normal?: Vector3;
  55195. size?: Vector3;
  55196. angle?: number;
  55197. }): Mesh;
  55198. }
  55199. }
  55200. declare module BABYLON {
  55201. /**
  55202. * A simplifier interface for future simplification implementations
  55203. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55204. */
  55205. export interface ISimplifier {
  55206. /**
  55207. * Simplification of a given mesh according to the given settings.
  55208. * Since this requires computation, it is assumed that the function runs async.
  55209. * @param settings The settings of the simplification, including quality and distance
  55210. * @param successCallback A callback that will be called after the mesh was simplified.
  55211. * @param errorCallback in case of an error, this callback will be called. optional.
  55212. */
  55213. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  55214. }
  55215. /**
  55216. * Expected simplification settings.
  55217. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  55218. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55219. */
  55220. export interface ISimplificationSettings {
  55221. /**
  55222. * Gets or sets the expected quality
  55223. */
  55224. quality: number;
  55225. /**
  55226. * Gets or sets the distance when this optimized version should be used
  55227. */
  55228. distance: number;
  55229. /**
  55230. * Gets an already optimized mesh
  55231. */
  55232. optimizeMesh?: boolean;
  55233. }
  55234. /**
  55235. * Class used to specify simplification options
  55236. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55237. */
  55238. export class SimplificationSettings implements ISimplificationSettings {
  55239. /** expected quality */
  55240. quality: number;
  55241. /** distance when this optimized version should be used */
  55242. distance: number;
  55243. /** already optimized mesh */
  55244. optimizeMesh?: boolean | undefined;
  55245. /**
  55246. * Creates a SimplificationSettings
  55247. * @param quality expected quality
  55248. * @param distance distance when this optimized version should be used
  55249. * @param optimizeMesh already optimized mesh
  55250. */
  55251. constructor(
  55252. /** expected quality */
  55253. quality: number,
  55254. /** distance when this optimized version should be used */
  55255. distance: number,
  55256. /** already optimized mesh */
  55257. optimizeMesh?: boolean | undefined);
  55258. }
  55259. /**
  55260. * Interface used to define a simplification task
  55261. */
  55262. export interface ISimplificationTask {
  55263. /**
  55264. * Array of settings
  55265. */
  55266. settings: Array<ISimplificationSettings>;
  55267. /**
  55268. * Simplification type
  55269. */
  55270. simplificationType: SimplificationType;
  55271. /**
  55272. * Mesh to simplify
  55273. */
  55274. mesh: Mesh;
  55275. /**
  55276. * Callback called on success
  55277. */
  55278. successCallback?: () => void;
  55279. /**
  55280. * Defines if parallel processing can be used
  55281. */
  55282. parallelProcessing: boolean;
  55283. }
  55284. /**
  55285. * Queue used to order the simplification tasks
  55286. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55287. */
  55288. export class SimplificationQueue {
  55289. private _simplificationArray;
  55290. /**
  55291. * Gets a boolean indicating that the process is still running
  55292. */
  55293. running: boolean;
  55294. /**
  55295. * Creates a new queue
  55296. */
  55297. constructor();
  55298. /**
  55299. * Adds a new simplification task
  55300. * @param task defines a task to add
  55301. */
  55302. addTask(task: ISimplificationTask): void;
  55303. /**
  55304. * Execute next task
  55305. */
  55306. executeNext(): void;
  55307. /**
  55308. * Execute a simplification task
  55309. * @param task defines the task to run
  55310. */
  55311. runSimplification(task: ISimplificationTask): void;
  55312. private getSimplifier;
  55313. }
  55314. /**
  55315. * The implemented types of simplification
  55316. * At the moment only Quadratic Error Decimation is implemented
  55317. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55318. */
  55319. export enum SimplificationType {
  55320. /** Quadratic error decimation */
  55321. QUADRATIC = 0
  55322. }
  55323. }
  55324. declare module BABYLON {
  55325. interface Scene {
  55326. /** @hidden (Backing field) */
  55327. _simplificationQueue: SimplificationQueue;
  55328. /**
  55329. * Gets or sets the simplification queue attached to the scene
  55330. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55331. */
  55332. simplificationQueue: SimplificationQueue;
  55333. }
  55334. interface Mesh {
  55335. /**
  55336. * Simplify the mesh according to the given array of settings.
  55337. * Function will return immediately and will simplify async
  55338. * @param settings a collection of simplification settings
  55339. * @param parallelProcessing should all levels calculate parallel or one after the other
  55340. * @param simplificationType the type of simplification to run
  55341. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  55342. * @returns the current mesh
  55343. */
  55344. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  55345. }
  55346. /**
  55347. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  55348. * created in a scene
  55349. */
  55350. export class SimplicationQueueSceneComponent implements ISceneComponent {
  55351. /**
  55352. * The component name helpfull to identify the component in the list of scene components.
  55353. */
  55354. readonly name: string;
  55355. /**
  55356. * The scene the component belongs to.
  55357. */
  55358. scene: Scene;
  55359. /**
  55360. * Creates a new instance of the component for the given scene
  55361. * @param scene Defines the scene to register the component in
  55362. */
  55363. constructor(scene: Scene);
  55364. /**
  55365. * Registers the component in a given scene
  55366. */
  55367. register(): void;
  55368. /**
  55369. * Rebuilds the elements related to this component in case of
  55370. * context lost for instance.
  55371. */
  55372. rebuild(): void;
  55373. /**
  55374. * Disposes the component and the associated ressources
  55375. */
  55376. dispose(): void;
  55377. private _beforeCameraUpdate;
  55378. }
  55379. }
  55380. declare module BABYLON {
  55381. /**
  55382. * Navigation plugin interface to add navigation constrained by a navigation mesh
  55383. */
  55384. export interface INavigationEnginePlugin {
  55385. /**
  55386. * plugin name
  55387. */
  55388. name: string;
  55389. /**
  55390. * Creates a navigation mesh
  55391. * @param meshes array of all the geometry used to compute the navigatio mesh
  55392. * @param parameters bunch of parameters used to filter geometry
  55393. */
  55394. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  55395. /**
  55396. * Create a navigation mesh debug mesh
  55397. * @param scene is where the mesh will be added
  55398. * @returns debug display mesh
  55399. */
  55400. createDebugNavMesh(scene: Scene): Mesh;
  55401. /**
  55402. * Get a navigation mesh constrained position, closest to the parameter position
  55403. * @param position world position
  55404. * @returns the closest point to position constrained by the navigation mesh
  55405. */
  55406. getClosestPoint(position: Vector3): Vector3;
  55407. /**
  55408. * Get a navigation mesh constrained position, within a particular radius
  55409. * @param position world position
  55410. * @param maxRadius the maximum distance to the constrained world position
  55411. * @returns the closest point to position constrained by the navigation mesh
  55412. */
  55413. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  55414. /**
  55415. * Compute the final position from a segment made of destination-position
  55416. * @param position world position
  55417. * @param destination world position
  55418. * @returns the resulting point along the navmesh
  55419. */
  55420. moveAlong(position: Vector3, destination: Vector3): Vector3;
  55421. /**
  55422. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  55423. * @param start world position
  55424. * @param end world position
  55425. * @returns array containing world position composing the path
  55426. */
  55427. computePath(start: Vector3, end: Vector3): Vector3[];
  55428. /**
  55429. * If this plugin is supported
  55430. * @returns true if plugin is supported
  55431. */
  55432. isSupported(): boolean;
  55433. /**
  55434. * Create a new Crowd so you can add agents
  55435. * @param maxAgents the maximum agent count in the crowd
  55436. * @param maxAgentRadius the maximum radius an agent can have
  55437. * @param scene to attach the crowd to
  55438. * @returns the crowd you can add agents to
  55439. */
  55440. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  55441. /**
  55442. * Release all resources
  55443. */
  55444. dispose(): void;
  55445. }
  55446. /**
  55447. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  55448. */
  55449. export interface ICrowd {
  55450. /**
  55451. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  55452. * You can attach anything to that node. The node position is updated in the scene update tick.
  55453. * @param pos world position that will be constrained by the navigation mesh
  55454. * @param parameters agent parameters
  55455. * @param transform hooked to the agent that will be update by the scene
  55456. * @returns agent index
  55457. */
  55458. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  55459. /**
  55460. * Returns the agent position in world space
  55461. * @param index agent index returned by addAgent
  55462. * @returns world space position
  55463. */
  55464. getAgentPosition(index: number): Vector3;
  55465. /**
  55466. * Gets the agent velocity in world space
  55467. * @param index agent index returned by addAgent
  55468. * @returns world space velocity
  55469. */
  55470. getAgentVelocity(index: number): Vector3;
  55471. /**
  55472. * remove a particular agent previously created
  55473. * @param index agent index returned by addAgent
  55474. */
  55475. removeAgent(index: number): void;
  55476. /**
  55477. * get the list of all agents attached to this crowd
  55478. * @returns list of agent indices
  55479. */
  55480. getAgents(): number[];
  55481. /**
  55482. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  55483. * @param deltaTime in seconds
  55484. */
  55485. update(deltaTime: number): void;
  55486. /**
  55487. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  55488. * @param index agent index returned by addAgent
  55489. * @param destination targeted world position
  55490. */
  55491. agentGoto(index: number, destination: Vector3): void;
  55492. /**
  55493. * Release all resources
  55494. */
  55495. dispose(): void;
  55496. }
  55497. /**
  55498. * Configures an agent
  55499. */
  55500. export interface IAgentParameters {
  55501. /**
  55502. * Agent radius. [Limit: >= 0]
  55503. */
  55504. radius: number;
  55505. /**
  55506. * Agent height. [Limit: > 0]
  55507. */
  55508. height: number;
  55509. /**
  55510. * Maximum allowed acceleration. [Limit: >= 0]
  55511. */
  55512. maxAcceleration: number;
  55513. /**
  55514. * Maximum allowed speed. [Limit: >= 0]
  55515. */
  55516. maxSpeed: number;
  55517. /**
  55518. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  55519. */
  55520. collisionQueryRange: number;
  55521. /**
  55522. * The path visibility optimization range. [Limit: > 0]
  55523. */
  55524. pathOptimizationRange: number;
  55525. /**
  55526. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  55527. */
  55528. separationWeight: number;
  55529. }
  55530. /**
  55531. * Configures the navigation mesh creation
  55532. */
  55533. export interface INavMeshParameters {
  55534. /**
  55535. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  55536. */
  55537. cs: number;
  55538. /**
  55539. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  55540. */
  55541. ch: number;
  55542. /**
  55543. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  55544. */
  55545. walkableSlopeAngle: number;
  55546. /**
  55547. * Minimum floor to 'ceiling' height that will still allow the floor area to
  55548. * be considered walkable. [Limit: >= 3] [Units: vx]
  55549. */
  55550. walkableHeight: number;
  55551. /**
  55552. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  55553. */
  55554. walkableClimb: number;
  55555. /**
  55556. * The distance to erode/shrink the walkable area of the heightfield away from
  55557. * obstructions. [Limit: >=0] [Units: vx]
  55558. */
  55559. walkableRadius: number;
  55560. /**
  55561. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  55562. */
  55563. maxEdgeLen: number;
  55564. /**
  55565. * The maximum distance a simplfied contour's border edges should deviate
  55566. * the original raw contour. [Limit: >=0] [Units: vx]
  55567. */
  55568. maxSimplificationError: number;
  55569. /**
  55570. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  55571. */
  55572. minRegionArea: number;
  55573. /**
  55574. * Any regions with a span count smaller than this value will, if possible,
  55575. * be merged with larger regions. [Limit: >=0] [Units: vx]
  55576. */
  55577. mergeRegionArea: number;
  55578. /**
  55579. * The maximum number of vertices allowed for polygons generated during the
  55580. * contour to polygon conversion process. [Limit: >= 3]
  55581. */
  55582. maxVertsPerPoly: number;
  55583. /**
  55584. * Sets the sampling distance to use when generating the detail mesh.
  55585. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  55586. */
  55587. detailSampleDist: number;
  55588. /**
  55589. * The maximum distance the detail mesh surface should deviate from heightfield
  55590. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  55591. */
  55592. detailSampleMaxError: number;
  55593. }
  55594. }
  55595. declare module BABYLON {
  55596. /**
  55597. * RecastJS navigation plugin
  55598. */
  55599. export class RecastJSPlugin implements INavigationEnginePlugin {
  55600. /**
  55601. * Reference to the Recast library
  55602. */
  55603. bjsRECAST: any;
  55604. /**
  55605. * plugin name
  55606. */
  55607. name: string;
  55608. /**
  55609. * the first navmesh created. We might extend this to support multiple navmeshes
  55610. */
  55611. navMesh: any;
  55612. /**
  55613. * Initializes the recastJS plugin
  55614. * @param recastInjection can be used to inject your own recast reference
  55615. */
  55616. constructor(recastInjection?: any);
  55617. /**
  55618. * Creates a navigation mesh
  55619. * @param meshes array of all the geometry used to compute the navigatio mesh
  55620. * @param parameters bunch of parameters used to filter geometry
  55621. */
  55622. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  55623. /**
  55624. * Create a navigation mesh debug mesh
  55625. * @param scene is where the mesh will be added
  55626. * @returns debug display mesh
  55627. */
  55628. createDebugNavMesh(scene: Scene): Mesh;
  55629. /**
  55630. * Get a navigation mesh constrained position, closest to the parameter position
  55631. * @param position world position
  55632. * @returns the closest point to position constrained by the navigation mesh
  55633. */
  55634. getClosestPoint(position: Vector3): Vector3;
  55635. /**
  55636. * Get a navigation mesh constrained position, within a particular radius
  55637. * @param position world position
  55638. * @param maxRadius the maximum distance to the constrained world position
  55639. * @returns the closest point to position constrained by the navigation mesh
  55640. */
  55641. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  55642. /**
  55643. * Compute the final position from a segment made of destination-position
  55644. * @param position world position
  55645. * @param destination world position
  55646. * @returns the resulting point along the navmesh
  55647. */
  55648. moveAlong(position: Vector3, destination: Vector3): Vector3;
  55649. /**
  55650. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  55651. * @param start world position
  55652. * @param end world position
  55653. * @returns array containing world position composing the path
  55654. */
  55655. computePath(start: Vector3, end: Vector3): Vector3[];
  55656. /**
  55657. * Create a new Crowd so you can add agents
  55658. * @param maxAgents the maximum agent count in the crowd
  55659. * @param maxAgentRadius the maximum radius an agent can have
  55660. * @param scene to attach the crowd to
  55661. * @returns the crowd you can add agents to
  55662. */
  55663. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  55664. /**
  55665. * Disposes
  55666. */
  55667. dispose(): void;
  55668. /**
  55669. * If this plugin is supported
  55670. * @returns true if plugin is supported
  55671. */
  55672. isSupported(): boolean;
  55673. }
  55674. /**
  55675. * Recast detour crowd implementation
  55676. */
  55677. export class RecastJSCrowd implements ICrowd {
  55678. /**
  55679. * Recast/detour plugin
  55680. */
  55681. bjsRECASTPlugin: RecastJSPlugin;
  55682. /**
  55683. * Link to the detour crowd
  55684. */
  55685. recastCrowd: any;
  55686. /**
  55687. * One transform per agent
  55688. */
  55689. transforms: TransformNode[];
  55690. /**
  55691. * All agents created
  55692. */
  55693. agents: number[];
  55694. /**
  55695. * Link to the scene is kept to unregister the crowd from the scene
  55696. */
  55697. private _scene;
  55698. /**
  55699. * Observer for crowd updates
  55700. */
  55701. private _onBeforeAnimationsObserver;
  55702. /**
  55703. * Constructor
  55704. * @param plugin recastJS plugin
  55705. * @param maxAgents the maximum agent count in the crowd
  55706. * @param maxAgentRadius the maximum radius an agent can have
  55707. * @param scene to attach the crowd to
  55708. * @returns the crowd you can add agents to
  55709. */
  55710. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  55711. /**
  55712. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  55713. * You can attach anything to that node. The node position is updated in the scene update tick.
  55714. * @param pos world position that will be constrained by the navigation mesh
  55715. * @param parameters agent parameters
  55716. * @param transform hooked to the agent that will be update by the scene
  55717. * @returns agent index
  55718. */
  55719. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  55720. /**
  55721. * Returns the agent position in world space
  55722. * @param index agent index returned by addAgent
  55723. * @returns world space position
  55724. */
  55725. getAgentPosition(index: number): Vector3;
  55726. /**
  55727. * Returns the agent velocity in world space
  55728. * @param index agent index returned by addAgent
  55729. * @returns world space velocity
  55730. */
  55731. getAgentVelocity(index: number): Vector3;
  55732. /**
  55733. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  55734. * @param index agent index returned by addAgent
  55735. * @param destination targeted world position
  55736. */
  55737. agentGoto(index: number, destination: Vector3): void;
  55738. /**
  55739. * remove a particular agent previously created
  55740. * @param index agent index returned by addAgent
  55741. */
  55742. removeAgent(index: number): void;
  55743. /**
  55744. * get the list of all agents attached to this crowd
  55745. * @returns list of agent indices
  55746. */
  55747. getAgents(): number[];
  55748. /**
  55749. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  55750. * @param deltaTime in seconds
  55751. */
  55752. update(deltaTime: number): void;
  55753. /**
  55754. * Release all resources
  55755. */
  55756. dispose(): void;
  55757. }
  55758. }
  55759. declare module BABYLON {
  55760. /**
  55761. * Class used to enable access to IndexedDB
  55762. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  55763. */
  55764. export class Database implements IOfflineProvider {
  55765. private _callbackManifestChecked;
  55766. private _currentSceneUrl;
  55767. private _db;
  55768. private _enableSceneOffline;
  55769. private _enableTexturesOffline;
  55770. private _manifestVersionFound;
  55771. private _mustUpdateRessources;
  55772. private _hasReachedQuota;
  55773. private _isSupported;
  55774. private _idbFactory;
  55775. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  55776. private static IsUASupportingBlobStorage;
  55777. /**
  55778. * Gets a boolean indicating if Database storate is enabled (off by default)
  55779. */
  55780. static IDBStorageEnabled: boolean;
  55781. /**
  55782. * Gets a boolean indicating if scene must be saved in the database
  55783. */
  55784. readonly enableSceneOffline: boolean;
  55785. /**
  55786. * Gets a boolean indicating if textures must be saved in the database
  55787. */
  55788. readonly enableTexturesOffline: boolean;
  55789. /**
  55790. * Creates a new Database
  55791. * @param urlToScene defines the url to load the scene
  55792. * @param callbackManifestChecked defines the callback to use when manifest is checked
  55793. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  55794. */
  55795. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  55796. private static _ParseURL;
  55797. private static _ReturnFullUrlLocation;
  55798. private _checkManifestFile;
  55799. /**
  55800. * Open the database and make it available
  55801. * @param successCallback defines the callback to call on success
  55802. * @param errorCallback defines the callback to call on error
  55803. */
  55804. open(successCallback: () => void, errorCallback: () => void): void;
  55805. /**
  55806. * Loads an image from the database
  55807. * @param url defines the url to load from
  55808. * @param image defines the target DOM image
  55809. */
  55810. loadImage(url: string, image: HTMLImageElement): void;
  55811. private _loadImageFromDBAsync;
  55812. private _saveImageIntoDBAsync;
  55813. private _checkVersionFromDB;
  55814. private _loadVersionFromDBAsync;
  55815. private _saveVersionIntoDBAsync;
  55816. /**
  55817. * Loads a file from database
  55818. * @param url defines the URL to load from
  55819. * @param sceneLoaded defines a callback to call on success
  55820. * @param progressCallBack defines a callback to call when progress changed
  55821. * @param errorCallback defines a callback to call on error
  55822. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  55823. */
  55824. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  55825. private _loadFileAsync;
  55826. private _saveFileAsync;
  55827. /**
  55828. * Validates if xhr data is correct
  55829. * @param xhr defines the request to validate
  55830. * @param dataType defines the expected data type
  55831. * @returns true if data is correct
  55832. */
  55833. private static _ValidateXHRData;
  55834. }
  55835. }
  55836. declare module BABYLON {
  55837. /** @hidden */
  55838. export var gpuUpdateParticlesPixelShader: {
  55839. name: string;
  55840. shader: string;
  55841. };
  55842. }
  55843. declare module BABYLON {
  55844. /** @hidden */
  55845. export var gpuUpdateParticlesVertexShader: {
  55846. name: string;
  55847. shader: string;
  55848. };
  55849. }
  55850. declare module BABYLON {
  55851. /** @hidden */
  55852. export var clipPlaneFragmentDeclaration2: {
  55853. name: string;
  55854. shader: string;
  55855. };
  55856. }
  55857. declare module BABYLON {
  55858. /** @hidden */
  55859. export var gpuRenderParticlesPixelShader: {
  55860. name: string;
  55861. shader: string;
  55862. };
  55863. }
  55864. declare module BABYLON {
  55865. /** @hidden */
  55866. export var clipPlaneVertexDeclaration2: {
  55867. name: string;
  55868. shader: string;
  55869. };
  55870. }
  55871. declare module BABYLON {
  55872. /** @hidden */
  55873. export var gpuRenderParticlesVertexShader: {
  55874. name: string;
  55875. shader: string;
  55876. };
  55877. }
  55878. declare module BABYLON {
  55879. /**
  55880. * This represents a GPU particle system in Babylon
  55881. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  55882. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  55883. */
  55884. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  55885. /**
  55886. * The layer mask we are rendering the particles through.
  55887. */
  55888. layerMask: number;
  55889. private _capacity;
  55890. private _activeCount;
  55891. private _currentActiveCount;
  55892. private _accumulatedCount;
  55893. private _renderEffect;
  55894. private _updateEffect;
  55895. private _buffer0;
  55896. private _buffer1;
  55897. private _spriteBuffer;
  55898. private _updateVAO;
  55899. private _renderVAO;
  55900. private _targetIndex;
  55901. private _sourceBuffer;
  55902. private _targetBuffer;
  55903. private _engine;
  55904. private _currentRenderId;
  55905. private _started;
  55906. private _stopped;
  55907. private _timeDelta;
  55908. private _randomTexture;
  55909. private _randomTexture2;
  55910. private _attributesStrideSize;
  55911. private _updateEffectOptions;
  55912. private _randomTextureSize;
  55913. private _actualFrame;
  55914. private readonly _rawTextureWidth;
  55915. /**
  55916. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  55917. */
  55918. static readonly IsSupported: boolean;
  55919. /**
  55920. * An event triggered when the system is disposed.
  55921. */
  55922. onDisposeObservable: Observable<GPUParticleSystem>;
  55923. /**
  55924. * Gets the maximum number of particles active at the same time.
  55925. * @returns The max number of active particles.
  55926. */
  55927. getCapacity(): number;
  55928. /**
  55929. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  55930. * to override the particles.
  55931. */
  55932. forceDepthWrite: boolean;
  55933. /**
  55934. * Gets or set the number of active particles
  55935. */
  55936. activeParticleCount: number;
  55937. private _preWarmDone;
  55938. /**
  55939. * Is this system ready to be used/rendered
  55940. * @return true if the system is ready
  55941. */
  55942. isReady(): boolean;
  55943. /**
  55944. * Gets if the system has been started. (Note: this will still be true after stop is called)
  55945. * @returns True if it has been started, otherwise false.
  55946. */
  55947. isStarted(): boolean;
  55948. /**
  55949. * Starts the particle system and begins to emit
  55950. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  55951. */
  55952. start(delay?: number): void;
  55953. /**
  55954. * Stops the particle system.
  55955. */
  55956. stop(): void;
  55957. /**
  55958. * Remove all active particles
  55959. */
  55960. reset(): void;
  55961. /**
  55962. * Returns the string "GPUParticleSystem"
  55963. * @returns a string containing the class name
  55964. */
  55965. getClassName(): string;
  55966. private _colorGradientsTexture;
  55967. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  55968. /**
  55969. * Adds a new color gradient
  55970. * @param gradient defines the gradient to use (between 0 and 1)
  55971. * @param color1 defines the color to affect to the specified gradient
  55972. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  55973. * @returns the current particle system
  55974. */
  55975. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  55976. /**
  55977. * Remove a specific color gradient
  55978. * @param gradient defines the gradient to remove
  55979. * @returns the current particle system
  55980. */
  55981. removeColorGradient(gradient: number): GPUParticleSystem;
  55982. private _angularSpeedGradientsTexture;
  55983. private _sizeGradientsTexture;
  55984. private _velocityGradientsTexture;
  55985. private _limitVelocityGradientsTexture;
  55986. private _dragGradientsTexture;
  55987. private _addFactorGradient;
  55988. /**
  55989. * Adds a new size gradient
  55990. * @param gradient defines the gradient to use (between 0 and 1)
  55991. * @param factor defines the size factor to affect to the specified gradient
  55992. * @returns the current particle system
  55993. */
  55994. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  55995. /**
  55996. * Remove a specific size gradient
  55997. * @param gradient defines the gradient to remove
  55998. * @returns the current particle system
  55999. */
  56000. removeSizeGradient(gradient: number): GPUParticleSystem;
  56001. /**
  56002. * Adds a new angular speed gradient
  56003. * @param gradient defines the gradient to use (between 0 and 1)
  56004. * @param factor defines the angular speed to affect to the specified gradient
  56005. * @returns the current particle system
  56006. */
  56007. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  56008. /**
  56009. * Remove a specific angular speed gradient
  56010. * @param gradient defines the gradient to remove
  56011. * @returns the current particle system
  56012. */
  56013. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  56014. /**
  56015. * Adds a new velocity gradient
  56016. * @param gradient defines the gradient to use (between 0 and 1)
  56017. * @param factor defines the velocity to affect to the specified gradient
  56018. * @returns the current particle system
  56019. */
  56020. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56021. /**
  56022. * Remove a specific velocity gradient
  56023. * @param gradient defines the gradient to remove
  56024. * @returns the current particle system
  56025. */
  56026. removeVelocityGradient(gradient: number): GPUParticleSystem;
  56027. /**
  56028. * Adds a new limit velocity gradient
  56029. * @param gradient defines the gradient to use (between 0 and 1)
  56030. * @param factor defines the limit velocity value to affect to the specified gradient
  56031. * @returns the current particle system
  56032. */
  56033. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56034. /**
  56035. * Remove a specific limit velocity gradient
  56036. * @param gradient defines the gradient to remove
  56037. * @returns the current particle system
  56038. */
  56039. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  56040. /**
  56041. * Adds a new drag gradient
  56042. * @param gradient defines the gradient to use (between 0 and 1)
  56043. * @param factor defines the drag value to affect to the specified gradient
  56044. * @returns the current particle system
  56045. */
  56046. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  56047. /**
  56048. * Remove a specific drag gradient
  56049. * @param gradient defines the gradient to remove
  56050. * @returns the current particle system
  56051. */
  56052. removeDragGradient(gradient: number): GPUParticleSystem;
  56053. /**
  56054. * Not supported by GPUParticleSystem
  56055. * @param gradient defines the gradient to use (between 0 and 1)
  56056. * @param factor defines the emit rate value to affect to the specified gradient
  56057. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56058. * @returns the current particle system
  56059. */
  56060. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56061. /**
  56062. * Not supported by GPUParticleSystem
  56063. * @param gradient defines the gradient to remove
  56064. * @returns the current particle system
  56065. */
  56066. removeEmitRateGradient(gradient: number): IParticleSystem;
  56067. /**
  56068. * Not supported by GPUParticleSystem
  56069. * @param gradient defines the gradient to use (between 0 and 1)
  56070. * @param factor defines the start size value to affect to the specified gradient
  56071. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56072. * @returns the current particle system
  56073. */
  56074. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56075. /**
  56076. * Not supported by GPUParticleSystem
  56077. * @param gradient defines the gradient to remove
  56078. * @returns the current particle system
  56079. */
  56080. removeStartSizeGradient(gradient: number): IParticleSystem;
  56081. /**
  56082. * Not supported by GPUParticleSystem
  56083. * @param gradient defines the gradient to use (between 0 and 1)
  56084. * @param min defines the color remap minimal range
  56085. * @param max defines the color remap maximal range
  56086. * @returns the current particle system
  56087. */
  56088. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56089. /**
  56090. * Not supported by GPUParticleSystem
  56091. * @param gradient defines the gradient to remove
  56092. * @returns the current particle system
  56093. */
  56094. removeColorRemapGradient(): IParticleSystem;
  56095. /**
  56096. * Not supported by GPUParticleSystem
  56097. * @param gradient defines the gradient to use (between 0 and 1)
  56098. * @param min defines the alpha remap minimal range
  56099. * @param max defines the alpha remap maximal range
  56100. * @returns the current particle system
  56101. */
  56102. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56103. /**
  56104. * Not supported by GPUParticleSystem
  56105. * @param gradient defines the gradient to remove
  56106. * @returns the current particle system
  56107. */
  56108. removeAlphaRemapGradient(): IParticleSystem;
  56109. /**
  56110. * Not supported by GPUParticleSystem
  56111. * @param gradient defines the gradient to use (between 0 and 1)
  56112. * @param color defines the color to affect to the specified gradient
  56113. * @returns the current particle system
  56114. */
  56115. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  56116. /**
  56117. * Not supported by GPUParticleSystem
  56118. * @param gradient defines the gradient to remove
  56119. * @returns the current particle system
  56120. */
  56121. removeRampGradient(): IParticleSystem;
  56122. /**
  56123. * Not supported by GPUParticleSystem
  56124. * @returns the list of ramp gradients
  56125. */
  56126. getRampGradients(): Nullable<Array<Color3Gradient>>;
  56127. /**
  56128. * Not supported by GPUParticleSystem
  56129. * Gets or sets a boolean indicating that ramp gradients must be used
  56130. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  56131. */
  56132. useRampGradients: boolean;
  56133. /**
  56134. * Not supported by GPUParticleSystem
  56135. * @param gradient defines the gradient to use (between 0 and 1)
  56136. * @param factor defines the life time factor to affect to the specified gradient
  56137. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56138. * @returns the current particle system
  56139. */
  56140. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56141. /**
  56142. * Not supported by GPUParticleSystem
  56143. * @param gradient defines the gradient to remove
  56144. * @returns the current particle system
  56145. */
  56146. removeLifeTimeGradient(gradient: number): IParticleSystem;
  56147. /**
  56148. * Instantiates a GPU particle system.
  56149. * 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.
  56150. * @param name The name of the particle system
  56151. * @param options The options used to create the system
  56152. * @param scene The scene the particle system belongs to
  56153. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  56154. */
  56155. constructor(name: string, options: Partial<{
  56156. capacity: number;
  56157. randomTextureSize: number;
  56158. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  56159. protected _reset(): void;
  56160. private _createUpdateVAO;
  56161. private _createRenderVAO;
  56162. private _initialize;
  56163. /** @hidden */
  56164. _recreateUpdateEffect(): void;
  56165. /** @hidden */
  56166. _recreateRenderEffect(): void;
  56167. /**
  56168. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  56169. * @param preWarm defines if we are in the pre-warmimg phase
  56170. */
  56171. animate(preWarm?: boolean): void;
  56172. private _createFactorGradientTexture;
  56173. private _createSizeGradientTexture;
  56174. private _createAngularSpeedGradientTexture;
  56175. private _createVelocityGradientTexture;
  56176. private _createLimitVelocityGradientTexture;
  56177. private _createDragGradientTexture;
  56178. private _createColorGradientTexture;
  56179. /**
  56180. * Renders the particle system in its current state
  56181. * @param preWarm defines if the system should only update the particles but not render them
  56182. * @returns the current number of particles
  56183. */
  56184. render(preWarm?: boolean): number;
  56185. /**
  56186. * Rebuilds the particle system
  56187. */
  56188. rebuild(): void;
  56189. private _releaseBuffers;
  56190. private _releaseVAOs;
  56191. /**
  56192. * Disposes the particle system and free the associated resources
  56193. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  56194. */
  56195. dispose(disposeTexture?: boolean): void;
  56196. /**
  56197. * Clones the particle system.
  56198. * @param name The name of the cloned object
  56199. * @param newEmitter The new emitter to use
  56200. * @returns the cloned particle system
  56201. */
  56202. clone(name: string, newEmitter: any): GPUParticleSystem;
  56203. /**
  56204. * Serializes the particle system to a JSON object.
  56205. * @returns the JSON object
  56206. */
  56207. serialize(): any;
  56208. /**
  56209. * Parses a JSON object to create a GPU particle system.
  56210. * @param parsedParticleSystem The JSON object to parse
  56211. * @param scene The scene to create the particle system in
  56212. * @param rootUrl The root url to use to load external dependencies like texture
  56213. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  56214. * @returns the parsed GPU particle system
  56215. */
  56216. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  56217. }
  56218. }
  56219. declare module BABYLON {
  56220. /**
  56221. * Represents a set of particle systems working together to create a specific effect
  56222. */
  56223. export class ParticleSystemSet implements IDisposable {
  56224. private _emitterCreationOptions;
  56225. private _emitterNode;
  56226. /**
  56227. * Gets the particle system list
  56228. */
  56229. systems: IParticleSystem[];
  56230. /**
  56231. * Gets the emitter node used with this set
  56232. */
  56233. readonly emitterNode: Nullable<TransformNode>;
  56234. /**
  56235. * Creates a new emitter mesh as a sphere
  56236. * @param options defines the options used to create the sphere
  56237. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  56238. * @param scene defines the hosting scene
  56239. */
  56240. setEmitterAsSphere(options: {
  56241. diameter: number;
  56242. segments: number;
  56243. color: Color3;
  56244. }, renderingGroupId: number, scene: Scene): void;
  56245. /**
  56246. * Starts all particle systems of the set
  56247. * @param emitter defines an optional mesh to use as emitter for the particle systems
  56248. */
  56249. start(emitter?: AbstractMesh): void;
  56250. /**
  56251. * Release all associated resources
  56252. */
  56253. dispose(): void;
  56254. /**
  56255. * Serialize the set into a JSON compatible object
  56256. * @returns a JSON compatible representation of the set
  56257. */
  56258. serialize(): any;
  56259. /**
  56260. * Parse a new ParticleSystemSet from a serialized source
  56261. * @param data defines a JSON compatible representation of the set
  56262. * @param scene defines the hosting scene
  56263. * @param gpu defines if we want GPU particles or CPU particles
  56264. * @returns a new ParticleSystemSet
  56265. */
  56266. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  56267. }
  56268. }
  56269. declare module BABYLON {
  56270. /**
  56271. * This class is made for on one-liner static method to help creating particle system set.
  56272. */
  56273. export class ParticleHelper {
  56274. /**
  56275. * Gets or sets base Assets URL
  56276. */
  56277. static BaseAssetsUrl: string;
  56278. /**
  56279. * Create a default particle system that you can tweak
  56280. * @param emitter defines the emitter to use
  56281. * @param capacity defines the system capacity (default is 500 particles)
  56282. * @param scene defines the hosting scene
  56283. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  56284. * @returns the new Particle system
  56285. */
  56286. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  56287. /**
  56288. * This is the main static method (one-liner) of this helper to create different particle systems
  56289. * @param type This string represents the type to the particle system to create
  56290. * @param scene The scene where the particle system should live
  56291. * @param gpu If the system will use gpu
  56292. * @returns the ParticleSystemSet created
  56293. */
  56294. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  56295. /**
  56296. * Static function used to export a particle system to a ParticleSystemSet variable.
  56297. * Please note that the emitter shape is not exported
  56298. * @param systems defines the particle systems to export
  56299. * @returns the created particle system set
  56300. */
  56301. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  56302. }
  56303. }
  56304. declare module BABYLON {
  56305. interface Engine {
  56306. /**
  56307. * Create an effect to use with particle systems.
  56308. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  56309. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  56310. * @param uniformsNames defines a list of attribute names
  56311. * @param samplers defines an array of string used to represent textures
  56312. * @param defines defines the string containing the defines to use to compile the shaders
  56313. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  56314. * @param onCompiled defines a function to call when the effect creation is successful
  56315. * @param onError defines a function to call when the effect creation has failed
  56316. * @returns the new Effect
  56317. */
  56318. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  56319. }
  56320. interface Mesh {
  56321. /**
  56322. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  56323. * @returns an array of IParticleSystem
  56324. */
  56325. getEmittedParticleSystems(): IParticleSystem[];
  56326. /**
  56327. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  56328. * @returns an array of IParticleSystem
  56329. */
  56330. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  56331. }
  56332. /**
  56333. * @hidden
  56334. */
  56335. export var _IDoNeedToBeInTheBuild: number;
  56336. }
  56337. declare module BABYLON {
  56338. interface Scene {
  56339. /** @hidden (Backing field) */
  56340. _physicsEngine: Nullable<IPhysicsEngine>;
  56341. /**
  56342. * Gets the current physics engine
  56343. * @returns a IPhysicsEngine or null if none attached
  56344. */
  56345. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  56346. /**
  56347. * Enables physics to the current scene
  56348. * @param gravity defines the scene's gravity for the physics engine
  56349. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  56350. * @return a boolean indicating if the physics engine was initialized
  56351. */
  56352. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  56353. /**
  56354. * Disables and disposes the physics engine associated with the scene
  56355. */
  56356. disablePhysicsEngine(): void;
  56357. /**
  56358. * Gets a boolean indicating if there is an active physics engine
  56359. * @returns a boolean indicating if there is an active physics engine
  56360. */
  56361. isPhysicsEnabled(): boolean;
  56362. /**
  56363. * Deletes a physics compound impostor
  56364. * @param compound defines the compound to delete
  56365. */
  56366. deleteCompoundImpostor(compound: any): void;
  56367. /**
  56368. * An event triggered when physic simulation is about to be run
  56369. */
  56370. onBeforePhysicsObservable: Observable<Scene>;
  56371. /**
  56372. * An event triggered when physic simulation has been done
  56373. */
  56374. onAfterPhysicsObservable: Observable<Scene>;
  56375. }
  56376. interface AbstractMesh {
  56377. /** @hidden */
  56378. _physicsImpostor: Nullable<PhysicsImpostor>;
  56379. /**
  56380. * Gets or sets impostor used for physic simulation
  56381. * @see http://doc.babylonjs.com/features/physics_engine
  56382. */
  56383. physicsImpostor: Nullable<PhysicsImpostor>;
  56384. /**
  56385. * Gets the current physics impostor
  56386. * @see http://doc.babylonjs.com/features/physics_engine
  56387. * @returns a physics impostor or null
  56388. */
  56389. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  56390. /** Apply a physic impulse to the mesh
  56391. * @param force defines the force to apply
  56392. * @param contactPoint defines where to apply the force
  56393. * @returns the current mesh
  56394. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  56395. */
  56396. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  56397. /**
  56398. * Creates a physic joint between two meshes
  56399. * @param otherMesh defines the other mesh to use
  56400. * @param pivot1 defines the pivot to use on this mesh
  56401. * @param pivot2 defines the pivot to use on the other mesh
  56402. * @param options defines additional options (can be plugin dependent)
  56403. * @returns the current mesh
  56404. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  56405. */
  56406. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  56407. /** @hidden */
  56408. _disposePhysicsObserver: Nullable<Observer<Node>>;
  56409. }
  56410. /**
  56411. * Defines the physics engine scene component responsible to manage a physics engine
  56412. */
  56413. export class PhysicsEngineSceneComponent implements ISceneComponent {
  56414. /**
  56415. * The component name helpful to identify the component in the list of scene components.
  56416. */
  56417. readonly name: string;
  56418. /**
  56419. * The scene the component belongs to.
  56420. */
  56421. scene: Scene;
  56422. /**
  56423. * Creates a new instance of the component for the given scene
  56424. * @param scene Defines the scene to register the component in
  56425. */
  56426. constructor(scene: Scene);
  56427. /**
  56428. * Registers the component in a given scene
  56429. */
  56430. register(): void;
  56431. /**
  56432. * Rebuilds the elements related to this component in case of
  56433. * context lost for instance.
  56434. */
  56435. rebuild(): void;
  56436. /**
  56437. * Disposes the component and the associated ressources
  56438. */
  56439. dispose(): void;
  56440. }
  56441. }
  56442. declare module BABYLON {
  56443. /**
  56444. * A helper for physics simulations
  56445. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56446. */
  56447. export class PhysicsHelper {
  56448. private _scene;
  56449. private _physicsEngine;
  56450. /**
  56451. * Initializes the Physics helper
  56452. * @param scene Babylon.js scene
  56453. */
  56454. constructor(scene: Scene);
  56455. /**
  56456. * Applies a radial explosion impulse
  56457. * @param origin the origin of the explosion
  56458. * @param radiusOrEventOptions the radius or the options of radial explosion
  56459. * @param strength the explosion strength
  56460. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56461. * @returns A physics radial explosion event, or null
  56462. */
  56463. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56464. /**
  56465. * Applies a radial explosion force
  56466. * @param origin the origin of the explosion
  56467. * @param radiusOrEventOptions the radius or the options of radial explosion
  56468. * @param strength the explosion strength
  56469. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56470. * @returns A physics radial explosion event, or null
  56471. */
  56472. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56473. /**
  56474. * Creates a gravitational field
  56475. * @param origin the origin of the explosion
  56476. * @param radiusOrEventOptions the radius or the options of radial explosion
  56477. * @param strength the explosion strength
  56478. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56479. * @returns A physics gravitational field event, or null
  56480. */
  56481. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  56482. /**
  56483. * Creates a physics updraft event
  56484. * @param origin the origin of the updraft
  56485. * @param radiusOrEventOptions the radius or the options of the updraft
  56486. * @param strength the strength of the updraft
  56487. * @param height the height of the updraft
  56488. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  56489. * @returns A physics updraft event, or null
  56490. */
  56491. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  56492. /**
  56493. * Creates a physics vortex event
  56494. * @param origin the of the vortex
  56495. * @param radiusOrEventOptions the radius or the options of the vortex
  56496. * @param strength the strength of the vortex
  56497. * @param height the height of the vortex
  56498. * @returns a Physics vortex event, or null
  56499. * A physics vortex event or null
  56500. */
  56501. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  56502. }
  56503. /**
  56504. * Represents a physics radial explosion event
  56505. */
  56506. class PhysicsRadialExplosionEvent {
  56507. private _scene;
  56508. private _options;
  56509. private _sphere;
  56510. private _dataFetched;
  56511. /**
  56512. * Initializes a radial explosioin event
  56513. * @param _scene BabylonJS scene
  56514. * @param _options The options for the vortex event
  56515. */
  56516. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  56517. /**
  56518. * Returns the data related to the radial explosion event (sphere).
  56519. * @returns The radial explosion event data
  56520. */
  56521. getData(): PhysicsRadialExplosionEventData;
  56522. /**
  56523. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  56524. * @param impostor A physics imposter
  56525. * @param origin the origin of the explosion
  56526. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  56527. */
  56528. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  56529. /**
  56530. * Triggers affecterd impostors callbacks
  56531. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  56532. */
  56533. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  56534. /**
  56535. * Disposes the sphere.
  56536. * @param force Specifies if the sphere should be disposed by force
  56537. */
  56538. dispose(force?: boolean): void;
  56539. /*** Helpers ***/
  56540. private _prepareSphere;
  56541. private _intersectsWithSphere;
  56542. }
  56543. /**
  56544. * Represents a gravitational field event
  56545. */
  56546. class PhysicsGravitationalFieldEvent {
  56547. private _physicsHelper;
  56548. private _scene;
  56549. private _origin;
  56550. private _options;
  56551. private _tickCallback;
  56552. private _sphere;
  56553. private _dataFetched;
  56554. /**
  56555. * Initializes the physics gravitational field event
  56556. * @param _physicsHelper A physics helper
  56557. * @param _scene BabylonJS scene
  56558. * @param _origin The origin position of the gravitational field event
  56559. * @param _options The options for the vortex event
  56560. */
  56561. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  56562. /**
  56563. * Returns the data related to the gravitational field event (sphere).
  56564. * @returns A gravitational field event
  56565. */
  56566. getData(): PhysicsGravitationalFieldEventData;
  56567. /**
  56568. * Enables the gravitational field.
  56569. */
  56570. enable(): void;
  56571. /**
  56572. * Disables the gravitational field.
  56573. */
  56574. disable(): void;
  56575. /**
  56576. * Disposes the sphere.
  56577. * @param force The force to dispose from the gravitational field event
  56578. */
  56579. dispose(force?: boolean): void;
  56580. private _tick;
  56581. }
  56582. /**
  56583. * Represents a physics updraft event
  56584. */
  56585. class PhysicsUpdraftEvent {
  56586. private _scene;
  56587. private _origin;
  56588. private _options;
  56589. private _physicsEngine;
  56590. private _originTop;
  56591. private _originDirection;
  56592. private _tickCallback;
  56593. private _cylinder;
  56594. private _cylinderPosition;
  56595. private _dataFetched;
  56596. /**
  56597. * Initializes the physics updraft event
  56598. * @param _scene BabylonJS scene
  56599. * @param _origin The origin position of the updraft
  56600. * @param _options The options for the updraft event
  56601. */
  56602. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  56603. /**
  56604. * Returns the data related to the updraft event (cylinder).
  56605. * @returns A physics updraft event
  56606. */
  56607. getData(): PhysicsUpdraftEventData;
  56608. /**
  56609. * Enables the updraft.
  56610. */
  56611. enable(): void;
  56612. /**
  56613. * Disables the updraft.
  56614. */
  56615. disable(): void;
  56616. /**
  56617. * Disposes the cylinder.
  56618. * @param force Specifies if the updraft should be disposed by force
  56619. */
  56620. dispose(force?: boolean): void;
  56621. private getImpostorHitData;
  56622. private _tick;
  56623. /*** Helpers ***/
  56624. private _prepareCylinder;
  56625. private _intersectsWithCylinder;
  56626. }
  56627. /**
  56628. * Represents a physics vortex event
  56629. */
  56630. class PhysicsVortexEvent {
  56631. private _scene;
  56632. private _origin;
  56633. private _options;
  56634. private _physicsEngine;
  56635. private _originTop;
  56636. private _tickCallback;
  56637. private _cylinder;
  56638. private _cylinderPosition;
  56639. private _dataFetched;
  56640. /**
  56641. * Initializes the physics vortex event
  56642. * @param _scene The BabylonJS scene
  56643. * @param _origin The origin position of the vortex
  56644. * @param _options The options for the vortex event
  56645. */
  56646. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  56647. /**
  56648. * Returns the data related to the vortex event (cylinder).
  56649. * @returns The physics vortex event data
  56650. */
  56651. getData(): PhysicsVortexEventData;
  56652. /**
  56653. * Enables the vortex.
  56654. */
  56655. enable(): void;
  56656. /**
  56657. * Disables the cortex.
  56658. */
  56659. disable(): void;
  56660. /**
  56661. * Disposes the sphere.
  56662. * @param force
  56663. */
  56664. dispose(force?: boolean): void;
  56665. private getImpostorHitData;
  56666. private _tick;
  56667. /*** Helpers ***/
  56668. private _prepareCylinder;
  56669. private _intersectsWithCylinder;
  56670. }
  56671. /**
  56672. * Options fot the radial explosion event
  56673. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56674. */
  56675. export class PhysicsRadialExplosionEventOptions {
  56676. /**
  56677. * The radius of the sphere for the radial explosion.
  56678. */
  56679. radius: number;
  56680. /**
  56681. * The strenth of the explosion.
  56682. */
  56683. strength: number;
  56684. /**
  56685. * The strenght of the force in correspondence to the distance of the affected object
  56686. */
  56687. falloff: PhysicsRadialImpulseFalloff;
  56688. /**
  56689. * Sphere options for the radial explosion.
  56690. */
  56691. sphere: {
  56692. segments: number;
  56693. diameter: number;
  56694. };
  56695. /**
  56696. * Sphere options for the radial explosion.
  56697. */
  56698. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  56699. }
  56700. /**
  56701. * Options fot the updraft event
  56702. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56703. */
  56704. export class PhysicsUpdraftEventOptions {
  56705. /**
  56706. * The radius of the cylinder for the vortex
  56707. */
  56708. radius: number;
  56709. /**
  56710. * The strenth of the updraft.
  56711. */
  56712. strength: number;
  56713. /**
  56714. * The height of the cylinder for the updraft.
  56715. */
  56716. height: number;
  56717. /**
  56718. * The mode for the the updraft.
  56719. */
  56720. updraftMode: PhysicsUpdraftMode;
  56721. }
  56722. /**
  56723. * Options fot the vortex event
  56724. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56725. */
  56726. export class PhysicsVortexEventOptions {
  56727. /**
  56728. * The radius of the cylinder for the vortex
  56729. */
  56730. radius: number;
  56731. /**
  56732. * The strenth of the vortex.
  56733. */
  56734. strength: number;
  56735. /**
  56736. * The height of the cylinder for the vortex.
  56737. */
  56738. height: number;
  56739. /**
  56740. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  56741. */
  56742. centripetalForceThreshold: number;
  56743. /**
  56744. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  56745. */
  56746. centripetalForceMultiplier: number;
  56747. /**
  56748. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  56749. */
  56750. centrifugalForceMultiplier: number;
  56751. /**
  56752. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  56753. */
  56754. updraftForceMultiplier: number;
  56755. }
  56756. /**
  56757. * The strenght of the force in correspondence to the distance of the affected object
  56758. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56759. */
  56760. export enum PhysicsRadialImpulseFalloff {
  56761. /** Defines that impulse is constant in strength across it's whole radius */
  56762. Constant = 0,
  56763. /** Defines that impulse gets weaker if it's further from the origin */
  56764. Linear = 1
  56765. }
  56766. /**
  56767. * The strength of the force in correspondence to the distance of the affected object
  56768. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56769. */
  56770. export enum PhysicsUpdraftMode {
  56771. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  56772. Center = 0,
  56773. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  56774. Perpendicular = 1
  56775. }
  56776. /**
  56777. * Interface for a physics hit data
  56778. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56779. */
  56780. export interface PhysicsHitData {
  56781. /**
  56782. * The force applied at the contact point
  56783. */
  56784. force: Vector3;
  56785. /**
  56786. * The contact point
  56787. */
  56788. contactPoint: Vector3;
  56789. /**
  56790. * The distance from the origin to the contact point
  56791. */
  56792. distanceFromOrigin: number;
  56793. }
  56794. /**
  56795. * Interface for radial explosion event data
  56796. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56797. */
  56798. export interface PhysicsRadialExplosionEventData {
  56799. /**
  56800. * A sphere used for the radial explosion event
  56801. */
  56802. sphere: Mesh;
  56803. }
  56804. /**
  56805. * Interface for gravitational field event data
  56806. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56807. */
  56808. export interface PhysicsGravitationalFieldEventData {
  56809. /**
  56810. * A sphere mesh used for the gravitational field event
  56811. */
  56812. sphere: Mesh;
  56813. }
  56814. /**
  56815. * Interface for updraft event data
  56816. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56817. */
  56818. export interface PhysicsUpdraftEventData {
  56819. /**
  56820. * A cylinder used for the updraft event
  56821. */
  56822. cylinder: Mesh;
  56823. }
  56824. /**
  56825. * Interface for vortex event data
  56826. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56827. */
  56828. export interface PhysicsVortexEventData {
  56829. /**
  56830. * A cylinder used for the vortex event
  56831. */
  56832. cylinder: Mesh;
  56833. }
  56834. /**
  56835. * Interface for an affected physics impostor
  56836. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56837. */
  56838. export interface PhysicsAffectedImpostorWithData {
  56839. /**
  56840. * The impostor affected by the effect
  56841. */
  56842. impostor: PhysicsImpostor;
  56843. /**
  56844. * The data about the hit/horce from the explosion
  56845. */
  56846. hitData: PhysicsHitData;
  56847. }
  56848. }
  56849. declare module BABYLON {
  56850. /** @hidden */
  56851. export var blackAndWhitePixelShader: {
  56852. name: string;
  56853. shader: string;
  56854. };
  56855. }
  56856. declare module BABYLON {
  56857. /**
  56858. * Post process used to render in black and white
  56859. */
  56860. export class BlackAndWhitePostProcess extends PostProcess {
  56861. /**
  56862. * Linear about to convert he result to black and white (default: 1)
  56863. */
  56864. degree: number;
  56865. /**
  56866. * Creates a black and white post process
  56867. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  56868. * @param name The name of the effect.
  56869. * @param options The required width/height ratio to downsize to before computing the render pass.
  56870. * @param camera The camera to apply the render pass to.
  56871. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56872. * @param engine The engine which the post process will be applied. (default: current engine)
  56873. * @param reusable If the post process can be reused on the same frame. (default: false)
  56874. */
  56875. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56876. }
  56877. }
  56878. declare module BABYLON {
  56879. /**
  56880. * This represents a set of one or more post processes in Babylon.
  56881. * A post process can be used to apply a shader to a texture after it is rendered.
  56882. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56883. */
  56884. export class PostProcessRenderEffect {
  56885. private _postProcesses;
  56886. private _getPostProcesses;
  56887. private _singleInstance;
  56888. private _cameras;
  56889. private _indicesForCamera;
  56890. /**
  56891. * Name of the effect
  56892. * @hidden
  56893. */
  56894. _name: string;
  56895. /**
  56896. * Instantiates a post process render effect.
  56897. * A post process can be used to apply a shader to a texture after it is rendered.
  56898. * @param engine The engine the effect is tied to
  56899. * @param name The name of the effect
  56900. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  56901. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  56902. */
  56903. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  56904. /**
  56905. * Checks if all the post processes in the effect are supported.
  56906. */
  56907. readonly isSupported: boolean;
  56908. /**
  56909. * Updates the current state of the effect
  56910. * @hidden
  56911. */
  56912. _update(): void;
  56913. /**
  56914. * Attaches the effect on cameras
  56915. * @param cameras The camera to attach to.
  56916. * @hidden
  56917. */
  56918. _attachCameras(cameras: Camera): void;
  56919. /**
  56920. * Attaches the effect on cameras
  56921. * @param cameras The camera to attach to.
  56922. * @hidden
  56923. */
  56924. _attachCameras(cameras: Camera[]): void;
  56925. /**
  56926. * Detaches the effect on cameras
  56927. * @param cameras The camera to detatch from.
  56928. * @hidden
  56929. */
  56930. _detachCameras(cameras: Camera): void;
  56931. /**
  56932. * Detatches the effect on cameras
  56933. * @param cameras The camera to detatch from.
  56934. * @hidden
  56935. */
  56936. _detachCameras(cameras: Camera[]): void;
  56937. /**
  56938. * Enables the effect on given cameras
  56939. * @param cameras The camera to enable.
  56940. * @hidden
  56941. */
  56942. _enable(cameras: Camera): void;
  56943. /**
  56944. * Enables the effect on given cameras
  56945. * @param cameras The camera to enable.
  56946. * @hidden
  56947. */
  56948. _enable(cameras: Nullable<Camera[]>): void;
  56949. /**
  56950. * Disables the effect on the given cameras
  56951. * @param cameras The camera to disable.
  56952. * @hidden
  56953. */
  56954. _disable(cameras: Camera): void;
  56955. /**
  56956. * Disables the effect on the given cameras
  56957. * @param cameras The camera to disable.
  56958. * @hidden
  56959. */
  56960. _disable(cameras: Nullable<Camera[]>): void;
  56961. /**
  56962. * Gets a list of the post processes contained in the effect.
  56963. * @param camera The camera to get the post processes on.
  56964. * @returns The list of the post processes in the effect.
  56965. */
  56966. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  56967. }
  56968. }
  56969. declare module BABYLON {
  56970. /** @hidden */
  56971. export var extractHighlightsPixelShader: {
  56972. name: string;
  56973. shader: string;
  56974. };
  56975. }
  56976. declare module BABYLON {
  56977. /**
  56978. * 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.
  56979. */
  56980. export class ExtractHighlightsPostProcess extends PostProcess {
  56981. /**
  56982. * The luminance threshold, pixels below this value will be set to black.
  56983. */
  56984. threshold: number;
  56985. /** @hidden */
  56986. _exposure: number;
  56987. /**
  56988. * Post process which has the input texture to be used when performing highlight extraction
  56989. * @hidden
  56990. */
  56991. _inputPostProcess: Nullable<PostProcess>;
  56992. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56993. }
  56994. }
  56995. declare module BABYLON {
  56996. /** @hidden */
  56997. export var bloomMergePixelShader: {
  56998. name: string;
  56999. shader: string;
  57000. };
  57001. }
  57002. declare module BABYLON {
  57003. /**
  57004. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57005. */
  57006. export class BloomMergePostProcess extends PostProcess {
  57007. /** Weight of the bloom to be added to the original input. */
  57008. weight: number;
  57009. /**
  57010. * Creates a new instance of @see BloomMergePostProcess
  57011. * @param name The name of the effect.
  57012. * @param originalFromInput Post process which's input will be used for the merge.
  57013. * @param blurred Blurred highlights post process which's output will be used.
  57014. * @param weight Weight of the bloom to be added to the original input.
  57015. * @param options The required width/height ratio to downsize to before computing the render pass.
  57016. * @param camera The camera to apply the render pass to.
  57017. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57018. * @param engine The engine which the post process will be applied. (default: current engine)
  57019. * @param reusable If the post process can be reused on the same frame. (default: false)
  57020. * @param textureType Type of textures used when performing the post process. (default: 0)
  57021. * @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)
  57022. */
  57023. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  57024. /** Weight of the bloom to be added to the original input. */
  57025. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57026. }
  57027. }
  57028. declare module BABYLON {
  57029. /**
  57030. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  57031. */
  57032. export class BloomEffect extends PostProcessRenderEffect {
  57033. private bloomScale;
  57034. /**
  57035. * @hidden Internal
  57036. */
  57037. _effects: Array<PostProcess>;
  57038. /**
  57039. * @hidden Internal
  57040. */
  57041. _downscale: ExtractHighlightsPostProcess;
  57042. private _blurX;
  57043. private _blurY;
  57044. private _merge;
  57045. /**
  57046. * The luminance threshold to find bright areas of the image to bloom.
  57047. */
  57048. threshold: number;
  57049. /**
  57050. * The strength of the bloom.
  57051. */
  57052. weight: number;
  57053. /**
  57054. * Specifies the size of the bloom blur kernel, relative to the final output size
  57055. */
  57056. kernel: number;
  57057. /**
  57058. * Creates a new instance of @see BloomEffect
  57059. * @param scene The scene the effect belongs to.
  57060. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  57061. * @param bloomKernel The size of the kernel to be used when applying the blur.
  57062. * @param bloomWeight The the strength of bloom.
  57063. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57064. * @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)
  57065. */
  57066. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  57067. /**
  57068. * Disposes each of the internal effects for a given camera.
  57069. * @param camera The camera to dispose the effect on.
  57070. */
  57071. disposeEffects(camera: Camera): void;
  57072. /**
  57073. * @hidden Internal
  57074. */
  57075. _updateEffects(): void;
  57076. /**
  57077. * Internal
  57078. * @returns if all the contained post processes are ready.
  57079. * @hidden
  57080. */
  57081. _isReady(): boolean;
  57082. }
  57083. }
  57084. declare module BABYLON {
  57085. /** @hidden */
  57086. export var chromaticAberrationPixelShader: {
  57087. name: string;
  57088. shader: string;
  57089. };
  57090. }
  57091. declare module BABYLON {
  57092. /**
  57093. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  57094. */
  57095. export class ChromaticAberrationPostProcess extends PostProcess {
  57096. /**
  57097. * The amount of seperation of rgb channels (default: 30)
  57098. */
  57099. aberrationAmount: number;
  57100. /**
  57101. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  57102. */
  57103. radialIntensity: number;
  57104. /**
  57105. * 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))
  57106. */
  57107. direction: Vector2;
  57108. /**
  57109. * 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))
  57110. */
  57111. centerPosition: Vector2;
  57112. /**
  57113. * Creates a new instance ChromaticAberrationPostProcess
  57114. * @param name The name of the effect.
  57115. * @param screenWidth The width of the screen to apply the effect on.
  57116. * @param screenHeight The height of the screen to apply the effect on.
  57117. * @param options The required width/height ratio to downsize to before computing the render pass.
  57118. * @param camera The camera to apply the render pass to.
  57119. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57120. * @param engine The engine which the post process will be applied. (default: current engine)
  57121. * @param reusable If the post process can be reused on the same frame. (default: false)
  57122. * @param textureType Type of textures used when performing the post process. (default: 0)
  57123. * @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)
  57124. */
  57125. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57126. }
  57127. }
  57128. declare module BABYLON {
  57129. /** @hidden */
  57130. export var circleOfConfusionPixelShader: {
  57131. name: string;
  57132. shader: string;
  57133. };
  57134. }
  57135. declare module BABYLON {
  57136. /**
  57137. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  57138. */
  57139. export class CircleOfConfusionPostProcess extends PostProcess {
  57140. /**
  57141. * 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.
  57142. */
  57143. lensSize: number;
  57144. /**
  57145. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57146. */
  57147. fStop: number;
  57148. /**
  57149. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57150. */
  57151. focusDistance: number;
  57152. /**
  57153. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  57154. */
  57155. focalLength: number;
  57156. private _depthTexture;
  57157. /**
  57158. * Creates a new instance CircleOfConfusionPostProcess
  57159. * @param name The name of the effect.
  57160. * @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.
  57161. * @param options The required width/height ratio to downsize to before computing the render pass.
  57162. * @param camera The camera to apply the render pass to.
  57163. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57164. * @param engine The engine which the post process will be applied. (default: current engine)
  57165. * @param reusable If the post process can be reused on the same frame. (default: false)
  57166. * @param textureType Type of textures used when performing the post process. (default: 0)
  57167. * @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)
  57168. */
  57169. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57170. /**
  57171. * 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.
  57172. */
  57173. depthTexture: RenderTargetTexture;
  57174. }
  57175. }
  57176. declare module BABYLON {
  57177. /** @hidden */
  57178. export var colorCorrectionPixelShader: {
  57179. name: string;
  57180. shader: string;
  57181. };
  57182. }
  57183. declare module BABYLON {
  57184. /**
  57185. *
  57186. * This post-process allows the modification of rendered colors by using
  57187. * a 'look-up table' (LUT). This effect is also called Color Grading.
  57188. *
  57189. * The object needs to be provided an url to a texture containing the color
  57190. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  57191. * Use an image editing software to tweak the LUT to match your needs.
  57192. *
  57193. * For an example of a color LUT, see here:
  57194. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  57195. * For explanations on color grading, see here:
  57196. * @see http://udn.epicgames.com/Three/ColorGrading.html
  57197. *
  57198. */
  57199. export class ColorCorrectionPostProcess extends PostProcess {
  57200. private _colorTableTexture;
  57201. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57202. }
  57203. }
  57204. declare module BABYLON {
  57205. /** @hidden */
  57206. export var convolutionPixelShader: {
  57207. name: string;
  57208. shader: string;
  57209. };
  57210. }
  57211. declare module BABYLON {
  57212. /**
  57213. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  57214. * input texture to perform effects such as edge detection or sharpening
  57215. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  57216. */
  57217. export class ConvolutionPostProcess extends PostProcess {
  57218. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57219. kernel: number[];
  57220. /**
  57221. * Creates a new instance ConvolutionPostProcess
  57222. * @param name The name of the effect.
  57223. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  57224. * @param options The required width/height ratio to downsize to before computing the render pass.
  57225. * @param camera The camera to apply the render pass to.
  57226. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57227. * @param engine The engine which the post process will be applied. (default: current engine)
  57228. * @param reusable If the post process can be reused on the same frame. (default: false)
  57229. * @param textureType Type of textures used when performing the post process. (default: 0)
  57230. */
  57231. constructor(name: string,
  57232. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57233. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57234. /**
  57235. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57236. */
  57237. static EdgeDetect0Kernel: number[];
  57238. /**
  57239. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57240. */
  57241. static EdgeDetect1Kernel: number[];
  57242. /**
  57243. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57244. */
  57245. static EdgeDetect2Kernel: number[];
  57246. /**
  57247. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57248. */
  57249. static SharpenKernel: number[];
  57250. /**
  57251. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57252. */
  57253. static EmbossKernel: number[];
  57254. /**
  57255. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57256. */
  57257. static GaussianKernel: number[];
  57258. }
  57259. }
  57260. declare module BABYLON {
  57261. /**
  57262. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  57263. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  57264. * based on samples that have a large difference in distance than the center pixel.
  57265. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  57266. */
  57267. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  57268. direction: Vector2;
  57269. /**
  57270. * Creates a new instance CircleOfConfusionPostProcess
  57271. * @param name The name of the effect.
  57272. * @param scene The scene the effect belongs to.
  57273. * @param direction The direction the blur should be applied.
  57274. * @param kernel The size of the kernel used to blur.
  57275. * @param options The required width/height ratio to downsize to before computing the render pass.
  57276. * @param camera The camera to apply the render pass to.
  57277. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  57278. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  57279. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57280. * @param engine The engine which the post process will be applied. (default: current engine)
  57281. * @param reusable If the post process can be reused on the same frame. (default: false)
  57282. * @param textureType Type of textures used when performing the post process. (default: 0)
  57283. * @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)
  57284. */
  57285. 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);
  57286. }
  57287. }
  57288. declare module BABYLON {
  57289. /** @hidden */
  57290. export var depthOfFieldMergePixelShader: {
  57291. name: string;
  57292. shader: string;
  57293. };
  57294. }
  57295. declare module BABYLON {
  57296. /**
  57297. * Options to be set when merging outputs from the default pipeline.
  57298. */
  57299. export class DepthOfFieldMergePostProcessOptions {
  57300. /**
  57301. * The original image to merge on top of
  57302. */
  57303. originalFromInput: PostProcess;
  57304. /**
  57305. * Parameters to perform the merge of the depth of field effect
  57306. */
  57307. depthOfField?: {
  57308. circleOfConfusion: PostProcess;
  57309. blurSteps: Array<PostProcess>;
  57310. };
  57311. /**
  57312. * Parameters to perform the merge of bloom effect
  57313. */
  57314. bloom?: {
  57315. blurred: PostProcess;
  57316. weight: number;
  57317. };
  57318. }
  57319. /**
  57320. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57321. */
  57322. export class DepthOfFieldMergePostProcess extends PostProcess {
  57323. private blurSteps;
  57324. /**
  57325. * Creates a new instance of DepthOfFieldMergePostProcess
  57326. * @param name The name of the effect.
  57327. * @param originalFromInput Post process which's input will be used for the merge.
  57328. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  57329. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  57330. * @param options The required width/height ratio to downsize to before computing the render pass.
  57331. * @param camera The camera to apply the render pass to.
  57332. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57333. * @param engine The engine which the post process will be applied. (default: current engine)
  57334. * @param reusable If the post process can be reused on the same frame. (default: false)
  57335. * @param textureType Type of textures used when performing the post process. (default: 0)
  57336. * @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)
  57337. */
  57338. 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);
  57339. /**
  57340. * Updates the effect with the current post process compile time values and recompiles the shader.
  57341. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  57342. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  57343. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  57344. * @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
  57345. * @param onCompiled Called when the shader has been compiled.
  57346. * @param onError Called if there is an error when compiling a shader.
  57347. */
  57348. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  57349. }
  57350. }
  57351. declare module BABYLON {
  57352. /**
  57353. * Specifies the level of max blur that should be applied when using the depth of field effect
  57354. */
  57355. export enum DepthOfFieldEffectBlurLevel {
  57356. /**
  57357. * Subtle blur
  57358. */
  57359. Low = 0,
  57360. /**
  57361. * Medium blur
  57362. */
  57363. Medium = 1,
  57364. /**
  57365. * Large blur
  57366. */
  57367. High = 2
  57368. }
  57369. /**
  57370. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  57371. */
  57372. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  57373. private _circleOfConfusion;
  57374. /**
  57375. * @hidden Internal, blurs from high to low
  57376. */
  57377. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  57378. private _depthOfFieldBlurY;
  57379. private _dofMerge;
  57380. /**
  57381. * @hidden Internal post processes in depth of field effect
  57382. */
  57383. _effects: Array<PostProcess>;
  57384. /**
  57385. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  57386. */
  57387. focalLength: number;
  57388. /**
  57389. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57390. */
  57391. fStop: number;
  57392. /**
  57393. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57394. */
  57395. focusDistance: number;
  57396. /**
  57397. * 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.
  57398. */
  57399. lensSize: number;
  57400. /**
  57401. * Creates a new instance DepthOfFieldEffect
  57402. * @param scene The scene the effect belongs to.
  57403. * @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.
  57404. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57405. * @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)
  57406. */
  57407. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  57408. /**
  57409. * Get the current class name of the current effet
  57410. * @returns "DepthOfFieldEffect"
  57411. */
  57412. getClassName(): string;
  57413. /**
  57414. * 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.
  57415. */
  57416. depthTexture: RenderTargetTexture;
  57417. /**
  57418. * Disposes each of the internal effects for a given camera.
  57419. * @param camera The camera to dispose the effect on.
  57420. */
  57421. disposeEffects(camera: Camera): void;
  57422. /**
  57423. * @hidden Internal
  57424. */
  57425. _updateEffects(): void;
  57426. /**
  57427. * Internal
  57428. * @returns if all the contained post processes are ready.
  57429. * @hidden
  57430. */
  57431. _isReady(): boolean;
  57432. }
  57433. }
  57434. declare module BABYLON {
  57435. /** @hidden */
  57436. export var displayPassPixelShader: {
  57437. name: string;
  57438. shader: string;
  57439. };
  57440. }
  57441. declare module BABYLON {
  57442. /**
  57443. * DisplayPassPostProcess which produces an output the same as it's input
  57444. */
  57445. export class DisplayPassPostProcess extends PostProcess {
  57446. /**
  57447. * Creates the DisplayPassPostProcess
  57448. * @param name The name of the effect.
  57449. * @param options The required width/height ratio to downsize to before computing the render pass.
  57450. * @param camera The camera to apply the render pass to.
  57451. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57452. * @param engine The engine which the post process will be applied. (default: current engine)
  57453. * @param reusable If the post process can be reused on the same frame. (default: false)
  57454. */
  57455. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57456. }
  57457. }
  57458. declare module BABYLON {
  57459. /** @hidden */
  57460. export var filterPixelShader: {
  57461. name: string;
  57462. shader: string;
  57463. };
  57464. }
  57465. declare module BABYLON {
  57466. /**
  57467. * Applies a kernel filter to the image
  57468. */
  57469. export class FilterPostProcess extends PostProcess {
  57470. /** The matrix to be applied to the image */
  57471. kernelMatrix: Matrix;
  57472. /**
  57473. *
  57474. * @param name The name of the effect.
  57475. * @param kernelMatrix The matrix to be applied to the image
  57476. * @param options The required width/height ratio to downsize to before computing the render pass.
  57477. * @param camera The camera to apply the render pass to.
  57478. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57479. * @param engine The engine which the post process will be applied. (default: current engine)
  57480. * @param reusable If the post process can be reused on the same frame. (default: false)
  57481. */
  57482. constructor(name: string,
  57483. /** The matrix to be applied to the image */
  57484. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57485. }
  57486. }
  57487. declare module BABYLON {
  57488. /** @hidden */
  57489. export var fxaaPixelShader: {
  57490. name: string;
  57491. shader: string;
  57492. };
  57493. }
  57494. declare module BABYLON {
  57495. /** @hidden */
  57496. export var fxaaVertexShader: {
  57497. name: string;
  57498. shader: string;
  57499. };
  57500. }
  57501. declare module BABYLON {
  57502. /**
  57503. * Fxaa post process
  57504. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  57505. */
  57506. export class FxaaPostProcess extends PostProcess {
  57507. /** @hidden */
  57508. texelWidth: number;
  57509. /** @hidden */
  57510. texelHeight: number;
  57511. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57512. private _getDefines;
  57513. }
  57514. }
  57515. declare module BABYLON {
  57516. /** @hidden */
  57517. export var grainPixelShader: {
  57518. name: string;
  57519. shader: string;
  57520. };
  57521. }
  57522. declare module BABYLON {
  57523. /**
  57524. * The GrainPostProcess adds noise to the image at mid luminance levels
  57525. */
  57526. export class GrainPostProcess extends PostProcess {
  57527. /**
  57528. * The intensity of the grain added (default: 30)
  57529. */
  57530. intensity: number;
  57531. /**
  57532. * If the grain should be randomized on every frame
  57533. */
  57534. animated: boolean;
  57535. /**
  57536. * Creates a new instance of @see GrainPostProcess
  57537. * @param name The name of the effect.
  57538. * @param options The required width/height ratio to downsize to before computing the render pass.
  57539. * @param camera The camera to apply the render pass to.
  57540. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57541. * @param engine The engine which the post process will be applied. (default: current engine)
  57542. * @param reusable If the post process can be reused on the same frame. (default: false)
  57543. * @param textureType Type of textures used when performing the post process. (default: 0)
  57544. * @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)
  57545. */
  57546. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57547. }
  57548. }
  57549. declare module BABYLON {
  57550. /** @hidden */
  57551. export var highlightsPixelShader: {
  57552. name: string;
  57553. shader: string;
  57554. };
  57555. }
  57556. declare module BABYLON {
  57557. /**
  57558. * Extracts highlights from the image
  57559. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  57560. */
  57561. export class HighlightsPostProcess extends PostProcess {
  57562. /**
  57563. * Extracts highlights from the image
  57564. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  57565. * @param name The name of the effect.
  57566. * @param options The required width/height ratio to downsize to before computing the render pass.
  57567. * @param camera The camera to apply the render pass to.
  57568. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57569. * @param engine The engine which the post process will be applied. (default: current engine)
  57570. * @param reusable If the post process can be reused on the same frame. (default: false)
  57571. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  57572. */
  57573. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57574. }
  57575. }
  57576. declare module BABYLON {
  57577. /** @hidden */
  57578. export var mrtFragmentDeclaration: {
  57579. name: string;
  57580. shader: string;
  57581. };
  57582. }
  57583. declare module BABYLON {
  57584. /** @hidden */
  57585. export var geometryPixelShader: {
  57586. name: string;
  57587. shader: string;
  57588. };
  57589. }
  57590. declare module BABYLON {
  57591. /** @hidden */
  57592. export var geometryVertexShader: {
  57593. name: string;
  57594. shader: string;
  57595. };
  57596. }
  57597. declare module BABYLON {
  57598. /** @hidden */
  57599. interface ISavedTransformationMatrix {
  57600. world: Matrix;
  57601. viewProjection: Matrix;
  57602. }
  57603. /**
  57604. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  57605. */
  57606. export class GeometryBufferRenderer {
  57607. /**
  57608. * Constant used to retrieve the position texture index in the G-Buffer textures array
  57609. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  57610. */
  57611. static readonly POSITION_TEXTURE_TYPE: number;
  57612. /**
  57613. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  57614. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  57615. */
  57616. static readonly VELOCITY_TEXTURE_TYPE: number;
  57617. /**
  57618. * Dictionary used to store the previous transformation matrices of each rendered mesh
  57619. * in order to compute objects velocities when enableVelocity is set to "true"
  57620. * @hidden
  57621. */
  57622. _previousTransformationMatrices: {
  57623. [index: number]: ISavedTransformationMatrix;
  57624. };
  57625. /**
  57626. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  57627. * in order to compute objects velocities when enableVelocity is set to "true"
  57628. * @hidden
  57629. */
  57630. _previousBonesTransformationMatrices: {
  57631. [index: number]: Float32Array;
  57632. };
  57633. /**
  57634. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  57635. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  57636. */
  57637. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  57638. private _scene;
  57639. private _multiRenderTarget;
  57640. private _ratio;
  57641. private _enablePosition;
  57642. private _enableVelocity;
  57643. private _positionIndex;
  57644. private _velocityIndex;
  57645. protected _effect: Effect;
  57646. protected _cachedDefines: string;
  57647. /**
  57648. * Set the render list (meshes to be rendered) used in the G buffer.
  57649. */
  57650. renderList: Mesh[];
  57651. /**
  57652. * Gets wether or not G buffer are supported by the running hardware.
  57653. * This requires draw buffer supports
  57654. */
  57655. readonly isSupported: boolean;
  57656. /**
  57657. * Returns the index of the given texture type in the G-Buffer textures array
  57658. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  57659. * @returns the index of the given texture type in the G-Buffer textures array
  57660. */
  57661. getTextureIndex(textureType: number): number;
  57662. /**
  57663. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  57664. */
  57665. /**
  57666. * Sets whether or not objects positions are enabled for the G buffer.
  57667. */
  57668. enablePosition: boolean;
  57669. /**
  57670. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  57671. */
  57672. /**
  57673. * Sets wether or not objects velocities are enabled for the G buffer.
  57674. */
  57675. enableVelocity: boolean;
  57676. /**
  57677. * Gets the scene associated with the buffer.
  57678. */
  57679. readonly scene: Scene;
  57680. /**
  57681. * Gets the ratio used by the buffer during its creation.
  57682. * How big is the buffer related to the main canvas.
  57683. */
  57684. readonly ratio: number;
  57685. /** @hidden */
  57686. static _SceneComponentInitialization: (scene: Scene) => void;
  57687. /**
  57688. * Creates a new G Buffer for the scene
  57689. * @param scene The scene the buffer belongs to
  57690. * @param ratio How big is the buffer related to the main canvas.
  57691. */
  57692. constructor(scene: Scene, ratio?: number);
  57693. /**
  57694. * Checks wether everything is ready to render a submesh to the G buffer.
  57695. * @param subMesh the submesh to check readiness for
  57696. * @param useInstances is the mesh drawn using instance or not
  57697. * @returns true if ready otherwise false
  57698. */
  57699. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57700. /**
  57701. * Gets the current underlying G Buffer.
  57702. * @returns the buffer
  57703. */
  57704. getGBuffer(): MultiRenderTarget;
  57705. /**
  57706. * Gets the number of samples used to render the buffer (anti aliasing).
  57707. */
  57708. /**
  57709. * Sets the number of samples used to render the buffer (anti aliasing).
  57710. */
  57711. samples: number;
  57712. /**
  57713. * Disposes the renderer and frees up associated resources.
  57714. */
  57715. dispose(): void;
  57716. protected _createRenderTargets(): void;
  57717. private _copyBonesTransformationMatrices;
  57718. }
  57719. }
  57720. declare module BABYLON {
  57721. interface Scene {
  57722. /** @hidden (Backing field) */
  57723. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  57724. /**
  57725. * Gets or Sets the current geometry buffer associated to the scene.
  57726. */
  57727. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  57728. /**
  57729. * Enables a GeometryBufferRender and associates it with the scene
  57730. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  57731. * @returns the GeometryBufferRenderer
  57732. */
  57733. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  57734. /**
  57735. * Disables the GeometryBufferRender associated with the scene
  57736. */
  57737. disableGeometryBufferRenderer(): void;
  57738. }
  57739. /**
  57740. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  57741. * in several rendering techniques.
  57742. */
  57743. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  57744. /**
  57745. * The component name helpful to identify the component in the list of scene components.
  57746. */
  57747. readonly name: string;
  57748. /**
  57749. * The scene the component belongs to.
  57750. */
  57751. scene: Scene;
  57752. /**
  57753. * Creates a new instance of the component for the given scene
  57754. * @param scene Defines the scene to register the component in
  57755. */
  57756. constructor(scene: Scene);
  57757. /**
  57758. * Registers the component in a given scene
  57759. */
  57760. register(): void;
  57761. /**
  57762. * Rebuilds the elements related to this component in case of
  57763. * context lost for instance.
  57764. */
  57765. rebuild(): void;
  57766. /**
  57767. * Disposes the component and the associated ressources
  57768. */
  57769. dispose(): void;
  57770. private _gatherRenderTargets;
  57771. }
  57772. }
  57773. declare module BABYLON {
  57774. /** @hidden */
  57775. export var motionBlurPixelShader: {
  57776. name: string;
  57777. shader: string;
  57778. };
  57779. }
  57780. declare module BABYLON {
  57781. /**
  57782. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  57783. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  57784. * As an example, all you have to do is to create the post-process:
  57785. * var mb = new BABYLON.MotionBlurPostProcess(
  57786. * 'mb', // The name of the effect.
  57787. * scene, // The scene containing the objects to blur according to their velocity.
  57788. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  57789. * camera // The camera to apply the render pass to.
  57790. * );
  57791. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  57792. */
  57793. export class MotionBlurPostProcess extends PostProcess {
  57794. /**
  57795. * Defines how much the image is blurred by the movement. Default value is equal to 1
  57796. */
  57797. motionStrength: number;
  57798. /**
  57799. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  57800. */
  57801. /**
  57802. * Sets the number of iterations to be used for motion blur quality
  57803. */
  57804. motionBlurSamples: number;
  57805. private _motionBlurSamples;
  57806. private _geometryBufferRenderer;
  57807. /**
  57808. * Creates a new instance MotionBlurPostProcess
  57809. * @param name The name of the effect.
  57810. * @param scene The scene containing the objects to blur according to their velocity.
  57811. * @param options The required width/height ratio to downsize to before computing the render pass.
  57812. * @param camera The camera to apply the render pass to.
  57813. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57814. * @param engine The engine which the post process will be applied. (default: current engine)
  57815. * @param reusable If the post process can be reused on the same frame. (default: false)
  57816. * @param textureType Type of textures used when performing the post process. (default: 0)
  57817. * @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)
  57818. */
  57819. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57820. /**
  57821. * Excludes the given skinned mesh from computing bones velocities.
  57822. * 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.
  57823. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  57824. */
  57825. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  57826. /**
  57827. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  57828. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  57829. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  57830. */
  57831. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  57832. /**
  57833. * Disposes the post process.
  57834. * @param camera The camera to dispose the post process on.
  57835. */
  57836. dispose(camera?: Camera): void;
  57837. }
  57838. }
  57839. declare module BABYLON {
  57840. /** @hidden */
  57841. export var refractionPixelShader: {
  57842. name: string;
  57843. shader: string;
  57844. };
  57845. }
  57846. declare module BABYLON {
  57847. /**
  57848. * Post process which applies a refractin texture
  57849. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  57850. */
  57851. export class RefractionPostProcess extends PostProcess {
  57852. /** the base color of the refraction (used to taint the rendering) */
  57853. color: Color3;
  57854. /** simulated refraction depth */
  57855. depth: number;
  57856. /** the coefficient of the base color (0 to remove base color tainting) */
  57857. colorLevel: number;
  57858. private _refTexture;
  57859. private _ownRefractionTexture;
  57860. /**
  57861. * Gets or sets the refraction texture
  57862. * Please note that you are responsible for disposing the texture if you set it manually
  57863. */
  57864. refractionTexture: Texture;
  57865. /**
  57866. * Initializes the RefractionPostProcess
  57867. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  57868. * @param name The name of the effect.
  57869. * @param refractionTextureUrl Url of the refraction texture to use
  57870. * @param color the base color of the refraction (used to taint the rendering)
  57871. * @param depth simulated refraction depth
  57872. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  57873. * @param camera The camera to apply the render pass to.
  57874. * @param options The required width/height ratio to downsize to before computing the render pass.
  57875. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57876. * @param engine The engine which the post process will be applied. (default: current engine)
  57877. * @param reusable If the post process can be reused on the same frame. (default: false)
  57878. */
  57879. constructor(name: string, refractionTextureUrl: string,
  57880. /** the base color of the refraction (used to taint the rendering) */
  57881. color: Color3,
  57882. /** simulated refraction depth */
  57883. depth: number,
  57884. /** the coefficient of the base color (0 to remove base color tainting) */
  57885. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57886. /**
  57887. * Disposes of the post process
  57888. * @param camera Camera to dispose post process on
  57889. */
  57890. dispose(camera: Camera): void;
  57891. }
  57892. }
  57893. declare module BABYLON {
  57894. /** @hidden */
  57895. export var sharpenPixelShader: {
  57896. name: string;
  57897. shader: string;
  57898. };
  57899. }
  57900. declare module BABYLON {
  57901. /**
  57902. * The SharpenPostProcess applies a sharpen kernel to every pixel
  57903. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  57904. */
  57905. export class SharpenPostProcess extends PostProcess {
  57906. /**
  57907. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  57908. */
  57909. colorAmount: number;
  57910. /**
  57911. * How much sharpness should be applied (default: 0.3)
  57912. */
  57913. edgeAmount: number;
  57914. /**
  57915. * Creates a new instance ConvolutionPostProcess
  57916. * @param name The name of the effect.
  57917. * @param options The required width/height ratio to downsize to before computing the render pass.
  57918. * @param camera The camera to apply the render pass to.
  57919. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57920. * @param engine The engine which the post process will be applied. (default: current engine)
  57921. * @param reusable If the post process can be reused on the same frame. (default: false)
  57922. * @param textureType Type of textures used when performing the post process. (default: 0)
  57923. * @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)
  57924. */
  57925. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57926. }
  57927. }
  57928. declare module BABYLON {
  57929. /**
  57930. * PostProcessRenderPipeline
  57931. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57932. */
  57933. export class PostProcessRenderPipeline {
  57934. private engine;
  57935. private _renderEffects;
  57936. private _renderEffectsForIsolatedPass;
  57937. /**
  57938. * List of inspectable custom properties (used by the Inspector)
  57939. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  57940. */
  57941. inspectableCustomProperties: IInspectable[];
  57942. /**
  57943. * @hidden
  57944. */
  57945. protected _cameras: Camera[];
  57946. /** @hidden */
  57947. _name: string;
  57948. /**
  57949. * Gets pipeline name
  57950. */
  57951. readonly name: string;
  57952. /**
  57953. * Initializes a PostProcessRenderPipeline
  57954. * @param engine engine to add the pipeline to
  57955. * @param name name of the pipeline
  57956. */
  57957. constructor(engine: Engine, name: string);
  57958. /**
  57959. * Gets the class name
  57960. * @returns "PostProcessRenderPipeline"
  57961. */
  57962. getClassName(): string;
  57963. /**
  57964. * If all the render effects in the pipeline are supported
  57965. */
  57966. readonly isSupported: boolean;
  57967. /**
  57968. * Adds an effect to the pipeline
  57969. * @param renderEffect the effect to add
  57970. */
  57971. addEffect(renderEffect: PostProcessRenderEffect): void;
  57972. /** @hidden */
  57973. _rebuild(): void;
  57974. /** @hidden */
  57975. _enableEffect(renderEffectName: string, cameras: Camera): void;
  57976. /** @hidden */
  57977. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  57978. /** @hidden */
  57979. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  57980. /** @hidden */
  57981. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  57982. /** @hidden */
  57983. _attachCameras(cameras: Camera, unique: boolean): void;
  57984. /** @hidden */
  57985. _attachCameras(cameras: Camera[], unique: boolean): void;
  57986. /** @hidden */
  57987. _detachCameras(cameras: Camera): void;
  57988. /** @hidden */
  57989. _detachCameras(cameras: Nullable<Camera[]>): void;
  57990. /** @hidden */
  57991. _update(): void;
  57992. /** @hidden */
  57993. _reset(): void;
  57994. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  57995. /**
  57996. * Disposes of the pipeline
  57997. */
  57998. dispose(): void;
  57999. }
  58000. }
  58001. declare module BABYLON {
  58002. /**
  58003. * PostProcessRenderPipelineManager class
  58004. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58005. */
  58006. export class PostProcessRenderPipelineManager {
  58007. private _renderPipelines;
  58008. /**
  58009. * Initializes a PostProcessRenderPipelineManager
  58010. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58011. */
  58012. constructor();
  58013. /**
  58014. * Gets the list of supported render pipelines
  58015. */
  58016. readonly supportedPipelines: PostProcessRenderPipeline[];
  58017. /**
  58018. * Adds a pipeline to the manager
  58019. * @param renderPipeline The pipeline to add
  58020. */
  58021. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  58022. /**
  58023. * Attaches a camera to the pipeline
  58024. * @param renderPipelineName The name of the pipeline to attach to
  58025. * @param cameras the camera to attach
  58026. * @param unique if the camera can be attached multiple times to the pipeline
  58027. */
  58028. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  58029. /**
  58030. * Detaches a camera from the pipeline
  58031. * @param renderPipelineName The name of the pipeline to detach from
  58032. * @param cameras the camera to detach
  58033. */
  58034. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  58035. /**
  58036. * Enables an effect by name on a pipeline
  58037. * @param renderPipelineName the name of the pipeline to enable the effect in
  58038. * @param renderEffectName the name of the effect to enable
  58039. * @param cameras the cameras that the effect should be enabled on
  58040. */
  58041. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58042. /**
  58043. * Disables an effect by name on a pipeline
  58044. * @param renderPipelineName the name of the pipeline to disable the effect in
  58045. * @param renderEffectName the name of the effect to disable
  58046. * @param cameras the cameras that the effect should be disabled on
  58047. */
  58048. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58049. /**
  58050. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  58051. */
  58052. update(): void;
  58053. /** @hidden */
  58054. _rebuild(): void;
  58055. /**
  58056. * Disposes of the manager and pipelines
  58057. */
  58058. dispose(): void;
  58059. }
  58060. }
  58061. declare module BABYLON {
  58062. interface Scene {
  58063. /** @hidden (Backing field) */
  58064. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58065. /**
  58066. * Gets the postprocess render pipeline manager
  58067. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58068. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58069. */
  58070. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58071. }
  58072. /**
  58073. * Defines the Render Pipeline scene component responsible to rendering pipelines
  58074. */
  58075. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  58076. /**
  58077. * The component name helpfull to identify the component in the list of scene components.
  58078. */
  58079. readonly name: string;
  58080. /**
  58081. * The scene the component belongs to.
  58082. */
  58083. scene: Scene;
  58084. /**
  58085. * Creates a new instance of the component for the given scene
  58086. * @param scene Defines the scene to register the component in
  58087. */
  58088. constructor(scene: Scene);
  58089. /**
  58090. * Registers the component in a given scene
  58091. */
  58092. register(): void;
  58093. /**
  58094. * Rebuilds the elements related to this component in case of
  58095. * context lost for instance.
  58096. */
  58097. rebuild(): void;
  58098. /**
  58099. * Disposes the component and the associated ressources
  58100. */
  58101. dispose(): void;
  58102. private _gatherRenderTargets;
  58103. }
  58104. }
  58105. declare module BABYLON {
  58106. /**
  58107. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  58108. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58109. */
  58110. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  58111. private _scene;
  58112. private _camerasToBeAttached;
  58113. /**
  58114. * ID of the sharpen post process,
  58115. */
  58116. private readonly SharpenPostProcessId;
  58117. /**
  58118. * @ignore
  58119. * ID of the image processing post process;
  58120. */
  58121. readonly ImageProcessingPostProcessId: string;
  58122. /**
  58123. * @ignore
  58124. * ID of the Fast Approximate Anti-Aliasing post process;
  58125. */
  58126. readonly FxaaPostProcessId: string;
  58127. /**
  58128. * ID of the chromatic aberration post process,
  58129. */
  58130. private readonly ChromaticAberrationPostProcessId;
  58131. /**
  58132. * ID of the grain post process
  58133. */
  58134. private readonly GrainPostProcessId;
  58135. /**
  58136. * Sharpen post process which will apply a sharpen convolution to enhance edges
  58137. */
  58138. sharpen: SharpenPostProcess;
  58139. private _sharpenEffect;
  58140. private bloom;
  58141. /**
  58142. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  58143. */
  58144. depthOfField: DepthOfFieldEffect;
  58145. /**
  58146. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  58147. */
  58148. fxaa: FxaaPostProcess;
  58149. /**
  58150. * Image post processing pass used to perform operations such as tone mapping or color grading.
  58151. */
  58152. imageProcessing: ImageProcessingPostProcess;
  58153. /**
  58154. * Chromatic aberration post process which will shift rgb colors in the image
  58155. */
  58156. chromaticAberration: ChromaticAberrationPostProcess;
  58157. private _chromaticAberrationEffect;
  58158. /**
  58159. * Grain post process which add noise to the image
  58160. */
  58161. grain: GrainPostProcess;
  58162. private _grainEffect;
  58163. /**
  58164. * Glow post process which adds a glow to emissive areas of the image
  58165. */
  58166. private _glowLayer;
  58167. /**
  58168. * Animations which can be used to tweak settings over a period of time
  58169. */
  58170. animations: Animation[];
  58171. private _imageProcessingConfigurationObserver;
  58172. private _sharpenEnabled;
  58173. private _bloomEnabled;
  58174. private _depthOfFieldEnabled;
  58175. private _depthOfFieldBlurLevel;
  58176. private _fxaaEnabled;
  58177. private _imageProcessingEnabled;
  58178. private _defaultPipelineTextureType;
  58179. private _bloomScale;
  58180. private _chromaticAberrationEnabled;
  58181. private _grainEnabled;
  58182. private _buildAllowed;
  58183. /**
  58184. * Gets active scene
  58185. */
  58186. readonly scene: Scene;
  58187. /**
  58188. * Enable or disable the sharpen process from the pipeline
  58189. */
  58190. sharpenEnabled: boolean;
  58191. private _resizeObserver;
  58192. private _hardwareScaleLevel;
  58193. private _bloomKernel;
  58194. /**
  58195. * Specifies the size of the bloom blur kernel, relative to the final output size
  58196. */
  58197. bloomKernel: number;
  58198. /**
  58199. * Specifies the weight of the bloom in the final rendering
  58200. */
  58201. private _bloomWeight;
  58202. /**
  58203. * Specifies the luma threshold for the area that will be blurred by the bloom
  58204. */
  58205. private _bloomThreshold;
  58206. private _hdr;
  58207. /**
  58208. * The strength of the bloom.
  58209. */
  58210. bloomWeight: number;
  58211. /**
  58212. * The strength of the bloom.
  58213. */
  58214. bloomThreshold: number;
  58215. /**
  58216. * The scale of the bloom, lower value will provide better performance.
  58217. */
  58218. bloomScale: number;
  58219. /**
  58220. * Enable or disable the bloom from the pipeline
  58221. */
  58222. bloomEnabled: boolean;
  58223. private _rebuildBloom;
  58224. /**
  58225. * If the depth of field is enabled.
  58226. */
  58227. depthOfFieldEnabled: boolean;
  58228. /**
  58229. * Blur level of the depth of field effect. (Higher blur will effect performance)
  58230. */
  58231. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  58232. /**
  58233. * If the anti aliasing is enabled.
  58234. */
  58235. fxaaEnabled: boolean;
  58236. private _samples;
  58237. /**
  58238. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  58239. */
  58240. samples: number;
  58241. /**
  58242. * If image processing is enabled.
  58243. */
  58244. imageProcessingEnabled: boolean;
  58245. /**
  58246. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  58247. */
  58248. glowLayerEnabled: boolean;
  58249. /**
  58250. * Gets the glow layer (or null if not defined)
  58251. */
  58252. readonly glowLayer: Nullable<GlowLayer>;
  58253. /**
  58254. * Enable or disable the chromaticAberration process from the pipeline
  58255. */
  58256. chromaticAberrationEnabled: boolean;
  58257. /**
  58258. * Enable or disable the grain process from the pipeline
  58259. */
  58260. grainEnabled: boolean;
  58261. /**
  58262. * @constructor
  58263. * @param name - The rendering pipeline name (default: "")
  58264. * @param hdr - If high dynamic range textures should be used (default: true)
  58265. * @param scene - The scene linked to this pipeline (default: the last created scene)
  58266. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  58267. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  58268. */
  58269. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  58270. /**
  58271. * Get the class name
  58272. * @returns "DefaultRenderingPipeline"
  58273. */
  58274. getClassName(): string;
  58275. /**
  58276. * Force the compilation of the entire pipeline.
  58277. */
  58278. prepare(): void;
  58279. private _hasCleared;
  58280. private _prevPostProcess;
  58281. private _prevPrevPostProcess;
  58282. private _setAutoClearAndTextureSharing;
  58283. private _depthOfFieldSceneObserver;
  58284. private _buildPipeline;
  58285. private _disposePostProcesses;
  58286. /**
  58287. * Adds a camera to the pipeline
  58288. * @param camera the camera to be added
  58289. */
  58290. addCamera(camera: Camera): void;
  58291. /**
  58292. * Removes a camera from the pipeline
  58293. * @param camera the camera to remove
  58294. */
  58295. removeCamera(camera: Camera): void;
  58296. /**
  58297. * Dispose of the pipeline and stop all post processes
  58298. */
  58299. dispose(): void;
  58300. /**
  58301. * Serialize the rendering pipeline (Used when exporting)
  58302. * @returns the serialized object
  58303. */
  58304. serialize(): any;
  58305. /**
  58306. * Parse the serialized pipeline
  58307. * @param source Source pipeline.
  58308. * @param scene The scene to load the pipeline to.
  58309. * @param rootUrl The URL of the serialized pipeline.
  58310. * @returns An instantiated pipeline from the serialized object.
  58311. */
  58312. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  58313. }
  58314. }
  58315. declare module BABYLON {
  58316. /** @hidden */
  58317. export var lensHighlightsPixelShader: {
  58318. name: string;
  58319. shader: string;
  58320. };
  58321. }
  58322. declare module BABYLON {
  58323. /** @hidden */
  58324. export var depthOfFieldPixelShader: {
  58325. name: string;
  58326. shader: string;
  58327. };
  58328. }
  58329. declare module BABYLON {
  58330. /**
  58331. * BABYLON.JS Chromatic Aberration GLSL Shader
  58332. * Author: Olivier Guyot
  58333. * Separates very slightly R, G and B colors on the edges of the screen
  58334. * Inspired by Francois Tarlier & Martins Upitis
  58335. */
  58336. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  58337. /**
  58338. * @ignore
  58339. * The chromatic aberration PostProcess id in the pipeline
  58340. */
  58341. LensChromaticAberrationEffect: string;
  58342. /**
  58343. * @ignore
  58344. * The highlights enhancing PostProcess id in the pipeline
  58345. */
  58346. HighlightsEnhancingEffect: string;
  58347. /**
  58348. * @ignore
  58349. * The depth-of-field PostProcess id in the pipeline
  58350. */
  58351. LensDepthOfFieldEffect: string;
  58352. private _scene;
  58353. private _depthTexture;
  58354. private _grainTexture;
  58355. private _chromaticAberrationPostProcess;
  58356. private _highlightsPostProcess;
  58357. private _depthOfFieldPostProcess;
  58358. private _edgeBlur;
  58359. private _grainAmount;
  58360. private _chromaticAberration;
  58361. private _distortion;
  58362. private _highlightsGain;
  58363. private _highlightsThreshold;
  58364. private _dofDistance;
  58365. private _dofAperture;
  58366. private _dofDarken;
  58367. private _dofPentagon;
  58368. private _blurNoise;
  58369. /**
  58370. * @constructor
  58371. *
  58372. * Effect parameters are as follow:
  58373. * {
  58374. * chromatic_aberration: number; // from 0 to x (1 for realism)
  58375. * edge_blur: number; // from 0 to x (1 for realism)
  58376. * distortion: number; // from 0 to x (1 for realism)
  58377. * grain_amount: number; // from 0 to 1
  58378. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  58379. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  58380. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  58381. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  58382. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  58383. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  58384. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  58385. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  58386. * }
  58387. * Note: if an effect parameter is unset, effect is disabled
  58388. *
  58389. * @param name The rendering pipeline name
  58390. * @param parameters - An object containing all parameters (see above)
  58391. * @param scene The scene linked to this pipeline
  58392. * @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)
  58393. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58394. */
  58395. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  58396. /**
  58397. * Get the class name
  58398. * @returns "LensRenderingPipeline"
  58399. */
  58400. getClassName(): string;
  58401. /**
  58402. * Gets associated scene
  58403. */
  58404. readonly scene: Scene;
  58405. /**
  58406. * Gets or sets the edge blur
  58407. */
  58408. edgeBlur: number;
  58409. /**
  58410. * Gets or sets the grain amount
  58411. */
  58412. grainAmount: number;
  58413. /**
  58414. * Gets or sets the chromatic aberration amount
  58415. */
  58416. chromaticAberration: number;
  58417. /**
  58418. * Gets or sets the depth of field aperture
  58419. */
  58420. dofAperture: number;
  58421. /**
  58422. * Gets or sets the edge distortion
  58423. */
  58424. edgeDistortion: number;
  58425. /**
  58426. * Gets or sets the depth of field distortion
  58427. */
  58428. dofDistortion: number;
  58429. /**
  58430. * Gets or sets the darken out of focus amount
  58431. */
  58432. darkenOutOfFocus: number;
  58433. /**
  58434. * Gets or sets a boolean indicating if blur noise is enabled
  58435. */
  58436. blurNoise: boolean;
  58437. /**
  58438. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  58439. */
  58440. pentagonBokeh: boolean;
  58441. /**
  58442. * Gets or sets the highlight grain amount
  58443. */
  58444. highlightsGain: number;
  58445. /**
  58446. * Gets or sets the highlight threshold
  58447. */
  58448. highlightsThreshold: number;
  58449. /**
  58450. * Sets the amount of blur at the edges
  58451. * @param amount blur amount
  58452. */
  58453. setEdgeBlur(amount: number): void;
  58454. /**
  58455. * Sets edge blur to 0
  58456. */
  58457. disableEdgeBlur(): void;
  58458. /**
  58459. * Sets the amout of grain
  58460. * @param amount Amount of grain
  58461. */
  58462. setGrainAmount(amount: number): void;
  58463. /**
  58464. * Set grain amount to 0
  58465. */
  58466. disableGrain(): void;
  58467. /**
  58468. * Sets the chromatic aberration amount
  58469. * @param amount amount of chromatic aberration
  58470. */
  58471. setChromaticAberration(amount: number): void;
  58472. /**
  58473. * Sets chromatic aberration amount to 0
  58474. */
  58475. disableChromaticAberration(): void;
  58476. /**
  58477. * Sets the EdgeDistortion amount
  58478. * @param amount amount of EdgeDistortion
  58479. */
  58480. setEdgeDistortion(amount: number): void;
  58481. /**
  58482. * Sets edge distortion to 0
  58483. */
  58484. disableEdgeDistortion(): void;
  58485. /**
  58486. * Sets the FocusDistance amount
  58487. * @param amount amount of FocusDistance
  58488. */
  58489. setFocusDistance(amount: number): void;
  58490. /**
  58491. * Disables depth of field
  58492. */
  58493. disableDepthOfField(): void;
  58494. /**
  58495. * Sets the Aperture amount
  58496. * @param amount amount of Aperture
  58497. */
  58498. setAperture(amount: number): void;
  58499. /**
  58500. * Sets the DarkenOutOfFocus amount
  58501. * @param amount amount of DarkenOutOfFocus
  58502. */
  58503. setDarkenOutOfFocus(amount: number): void;
  58504. private _pentagonBokehIsEnabled;
  58505. /**
  58506. * Creates a pentagon bokeh effect
  58507. */
  58508. enablePentagonBokeh(): void;
  58509. /**
  58510. * Disables the pentagon bokeh effect
  58511. */
  58512. disablePentagonBokeh(): void;
  58513. /**
  58514. * Enables noise blur
  58515. */
  58516. enableNoiseBlur(): void;
  58517. /**
  58518. * Disables noise blur
  58519. */
  58520. disableNoiseBlur(): void;
  58521. /**
  58522. * Sets the HighlightsGain amount
  58523. * @param amount amount of HighlightsGain
  58524. */
  58525. setHighlightsGain(amount: number): void;
  58526. /**
  58527. * Sets the HighlightsThreshold amount
  58528. * @param amount amount of HighlightsThreshold
  58529. */
  58530. setHighlightsThreshold(amount: number): void;
  58531. /**
  58532. * Disables highlights
  58533. */
  58534. disableHighlights(): void;
  58535. /**
  58536. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  58537. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  58538. */
  58539. dispose(disableDepthRender?: boolean): void;
  58540. private _createChromaticAberrationPostProcess;
  58541. private _createHighlightsPostProcess;
  58542. private _createDepthOfFieldPostProcess;
  58543. private _createGrainTexture;
  58544. }
  58545. }
  58546. declare module BABYLON {
  58547. /** @hidden */
  58548. export var ssao2PixelShader: {
  58549. name: string;
  58550. shader: string;
  58551. };
  58552. }
  58553. declare module BABYLON {
  58554. /** @hidden */
  58555. export var ssaoCombinePixelShader: {
  58556. name: string;
  58557. shader: string;
  58558. };
  58559. }
  58560. declare module BABYLON {
  58561. /**
  58562. * Render pipeline to produce ssao effect
  58563. */
  58564. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  58565. /**
  58566. * @ignore
  58567. * The PassPostProcess id in the pipeline that contains the original scene color
  58568. */
  58569. SSAOOriginalSceneColorEffect: string;
  58570. /**
  58571. * @ignore
  58572. * The SSAO PostProcess id in the pipeline
  58573. */
  58574. SSAORenderEffect: string;
  58575. /**
  58576. * @ignore
  58577. * The horizontal blur PostProcess id in the pipeline
  58578. */
  58579. SSAOBlurHRenderEffect: string;
  58580. /**
  58581. * @ignore
  58582. * The vertical blur PostProcess id in the pipeline
  58583. */
  58584. SSAOBlurVRenderEffect: string;
  58585. /**
  58586. * @ignore
  58587. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  58588. */
  58589. SSAOCombineRenderEffect: string;
  58590. /**
  58591. * The output strength of the SSAO post-process. Default value is 1.0.
  58592. */
  58593. totalStrength: number;
  58594. /**
  58595. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  58596. */
  58597. maxZ: number;
  58598. /**
  58599. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  58600. */
  58601. minZAspect: number;
  58602. private _samples;
  58603. /**
  58604. * Number of samples used for the SSAO calculations. Default value is 8
  58605. */
  58606. samples: number;
  58607. private _textureSamples;
  58608. /**
  58609. * Number of samples to use for antialiasing
  58610. */
  58611. textureSamples: number;
  58612. /**
  58613. * Ratio object used for SSAO ratio and blur ratio
  58614. */
  58615. private _ratio;
  58616. /**
  58617. * Dynamically generated sphere sampler.
  58618. */
  58619. private _sampleSphere;
  58620. /**
  58621. * Blur filter offsets
  58622. */
  58623. private _samplerOffsets;
  58624. private _expensiveBlur;
  58625. /**
  58626. * If bilateral blur should be used
  58627. */
  58628. expensiveBlur: boolean;
  58629. /**
  58630. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  58631. */
  58632. radius: number;
  58633. /**
  58634. * The base color of the SSAO post-process
  58635. * The final result is "base + ssao" between [0, 1]
  58636. */
  58637. base: number;
  58638. /**
  58639. * Support test.
  58640. */
  58641. static readonly IsSupported: boolean;
  58642. private _scene;
  58643. private _depthTexture;
  58644. private _normalTexture;
  58645. private _randomTexture;
  58646. private _originalColorPostProcess;
  58647. private _ssaoPostProcess;
  58648. private _blurHPostProcess;
  58649. private _blurVPostProcess;
  58650. private _ssaoCombinePostProcess;
  58651. private _firstUpdate;
  58652. /**
  58653. * Gets active scene
  58654. */
  58655. readonly scene: Scene;
  58656. /**
  58657. * @constructor
  58658. * @param name The rendering pipeline name
  58659. * @param scene The scene linked to this pipeline
  58660. * @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 }
  58661. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58662. */
  58663. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  58664. /**
  58665. * Get the class name
  58666. * @returns "SSAO2RenderingPipeline"
  58667. */
  58668. getClassName(): string;
  58669. /**
  58670. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  58671. */
  58672. dispose(disableGeometryBufferRenderer?: boolean): void;
  58673. private _createBlurPostProcess;
  58674. /** @hidden */
  58675. _rebuild(): void;
  58676. private _bits;
  58677. private _radicalInverse_VdC;
  58678. private _hammersley;
  58679. private _hemisphereSample_uniform;
  58680. private _generateHemisphere;
  58681. private _createSSAOPostProcess;
  58682. private _createSSAOCombinePostProcess;
  58683. private _createRandomTexture;
  58684. /**
  58685. * Serialize the rendering pipeline (Used when exporting)
  58686. * @returns the serialized object
  58687. */
  58688. serialize(): any;
  58689. /**
  58690. * Parse the serialized pipeline
  58691. * @param source Source pipeline.
  58692. * @param scene The scene to load the pipeline to.
  58693. * @param rootUrl The URL of the serialized pipeline.
  58694. * @returns An instantiated pipeline from the serialized object.
  58695. */
  58696. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  58697. }
  58698. }
  58699. declare module BABYLON {
  58700. /** @hidden */
  58701. export var ssaoPixelShader: {
  58702. name: string;
  58703. shader: string;
  58704. };
  58705. }
  58706. declare module BABYLON {
  58707. /**
  58708. * Render pipeline to produce ssao effect
  58709. */
  58710. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  58711. /**
  58712. * @ignore
  58713. * The PassPostProcess id in the pipeline that contains the original scene color
  58714. */
  58715. SSAOOriginalSceneColorEffect: string;
  58716. /**
  58717. * @ignore
  58718. * The SSAO PostProcess id in the pipeline
  58719. */
  58720. SSAORenderEffect: string;
  58721. /**
  58722. * @ignore
  58723. * The horizontal blur PostProcess id in the pipeline
  58724. */
  58725. SSAOBlurHRenderEffect: string;
  58726. /**
  58727. * @ignore
  58728. * The vertical blur PostProcess id in the pipeline
  58729. */
  58730. SSAOBlurVRenderEffect: string;
  58731. /**
  58732. * @ignore
  58733. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  58734. */
  58735. SSAOCombineRenderEffect: string;
  58736. /**
  58737. * The output strength of the SSAO post-process. Default value is 1.0.
  58738. */
  58739. totalStrength: number;
  58740. /**
  58741. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  58742. */
  58743. radius: number;
  58744. /**
  58745. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  58746. * Must not be equal to fallOff and superior to fallOff.
  58747. * Default value is 0.0075
  58748. */
  58749. area: number;
  58750. /**
  58751. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  58752. * Must not be equal to area and inferior to area.
  58753. * Default value is 0.000001
  58754. */
  58755. fallOff: number;
  58756. /**
  58757. * The base color of the SSAO post-process
  58758. * The final result is "base + ssao" between [0, 1]
  58759. */
  58760. base: number;
  58761. private _scene;
  58762. private _depthTexture;
  58763. private _randomTexture;
  58764. private _originalColorPostProcess;
  58765. private _ssaoPostProcess;
  58766. private _blurHPostProcess;
  58767. private _blurVPostProcess;
  58768. private _ssaoCombinePostProcess;
  58769. private _firstUpdate;
  58770. /**
  58771. * Gets active scene
  58772. */
  58773. readonly scene: Scene;
  58774. /**
  58775. * @constructor
  58776. * @param name - The rendering pipeline name
  58777. * @param scene - The scene linked to this pipeline
  58778. * @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 }
  58779. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  58780. */
  58781. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  58782. /**
  58783. * Get the class name
  58784. * @returns "SSAORenderingPipeline"
  58785. */
  58786. getClassName(): string;
  58787. /**
  58788. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  58789. */
  58790. dispose(disableDepthRender?: boolean): void;
  58791. private _createBlurPostProcess;
  58792. /** @hidden */
  58793. _rebuild(): void;
  58794. private _createSSAOPostProcess;
  58795. private _createSSAOCombinePostProcess;
  58796. private _createRandomTexture;
  58797. }
  58798. }
  58799. declare module BABYLON {
  58800. /** @hidden */
  58801. export var standardPixelShader: {
  58802. name: string;
  58803. shader: string;
  58804. };
  58805. }
  58806. declare module BABYLON {
  58807. /**
  58808. * Standard rendering pipeline
  58809. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  58810. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  58811. */
  58812. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  58813. /**
  58814. * Public members
  58815. */
  58816. /**
  58817. * Post-process which contains the original scene color before the pipeline applies all the effects
  58818. */
  58819. originalPostProcess: Nullable<PostProcess>;
  58820. /**
  58821. * Post-process used to down scale an image x4
  58822. */
  58823. downSampleX4PostProcess: Nullable<PostProcess>;
  58824. /**
  58825. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  58826. */
  58827. brightPassPostProcess: Nullable<PostProcess>;
  58828. /**
  58829. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  58830. */
  58831. blurHPostProcesses: PostProcess[];
  58832. /**
  58833. * Post-process array storing all the vertical blur post-processes used by the pipeline
  58834. */
  58835. blurVPostProcesses: PostProcess[];
  58836. /**
  58837. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  58838. */
  58839. textureAdderPostProcess: Nullable<PostProcess>;
  58840. /**
  58841. * Post-process used to create volumetric lighting effect
  58842. */
  58843. volumetricLightPostProcess: Nullable<PostProcess>;
  58844. /**
  58845. * Post-process used to smooth the previous volumetric light post-process on the X axis
  58846. */
  58847. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  58848. /**
  58849. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  58850. */
  58851. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  58852. /**
  58853. * Post-process used to merge the volumetric light effect and the real scene color
  58854. */
  58855. volumetricLightMergePostProces: Nullable<PostProcess>;
  58856. /**
  58857. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  58858. */
  58859. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  58860. /**
  58861. * Base post-process used to calculate the average luminance of the final image for HDR
  58862. */
  58863. luminancePostProcess: Nullable<PostProcess>;
  58864. /**
  58865. * Post-processes used to create down sample post-processes in order to get
  58866. * the average luminance of the final image for HDR
  58867. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  58868. */
  58869. luminanceDownSamplePostProcesses: PostProcess[];
  58870. /**
  58871. * Post-process used to create a HDR effect (light adaptation)
  58872. */
  58873. hdrPostProcess: Nullable<PostProcess>;
  58874. /**
  58875. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  58876. */
  58877. textureAdderFinalPostProcess: Nullable<PostProcess>;
  58878. /**
  58879. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  58880. */
  58881. lensFlareFinalPostProcess: Nullable<PostProcess>;
  58882. /**
  58883. * Post-process used to merge the final HDR post-process and the real scene color
  58884. */
  58885. hdrFinalPostProcess: Nullable<PostProcess>;
  58886. /**
  58887. * Post-process used to create a lens flare effect
  58888. */
  58889. lensFlarePostProcess: Nullable<PostProcess>;
  58890. /**
  58891. * Post-process that merges the result of the lens flare post-process and the real scene color
  58892. */
  58893. lensFlareComposePostProcess: Nullable<PostProcess>;
  58894. /**
  58895. * Post-process used to create a motion blur effect
  58896. */
  58897. motionBlurPostProcess: Nullable<PostProcess>;
  58898. /**
  58899. * Post-process used to create a depth of field effect
  58900. */
  58901. depthOfFieldPostProcess: Nullable<PostProcess>;
  58902. /**
  58903. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  58904. */
  58905. fxaaPostProcess: Nullable<FxaaPostProcess>;
  58906. /**
  58907. * Represents the brightness threshold in order to configure the illuminated surfaces
  58908. */
  58909. brightThreshold: number;
  58910. /**
  58911. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  58912. */
  58913. blurWidth: number;
  58914. /**
  58915. * Sets if the blur for highlighted surfaces must be only horizontal
  58916. */
  58917. horizontalBlur: boolean;
  58918. /**
  58919. * Gets the overall exposure used by the pipeline
  58920. */
  58921. /**
  58922. * Sets the overall exposure used by the pipeline
  58923. */
  58924. exposure: number;
  58925. /**
  58926. * Texture used typically to simulate "dirty" on camera lens
  58927. */
  58928. lensTexture: Nullable<Texture>;
  58929. /**
  58930. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  58931. */
  58932. volumetricLightCoefficient: number;
  58933. /**
  58934. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  58935. */
  58936. volumetricLightPower: number;
  58937. /**
  58938. * Used the set the blur intensity to smooth the volumetric lights
  58939. */
  58940. volumetricLightBlurScale: number;
  58941. /**
  58942. * Light (spot or directional) used to generate the volumetric lights rays
  58943. * The source light must have a shadow generate so the pipeline can get its
  58944. * depth map
  58945. */
  58946. sourceLight: Nullable<SpotLight | DirectionalLight>;
  58947. /**
  58948. * For eye adaptation, represents the minimum luminance the eye can see
  58949. */
  58950. hdrMinimumLuminance: number;
  58951. /**
  58952. * For eye adaptation, represents the decrease luminance speed
  58953. */
  58954. hdrDecreaseRate: number;
  58955. /**
  58956. * For eye adaptation, represents the increase luminance speed
  58957. */
  58958. hdrIncreaseRate: number;
  58959. /**
  58960. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  58961. */
  58962. /**
  58963. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  58964. */
  58965. hdrAutoExposure: boolean;
  58966. /**
  58967. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  58968. */
  58969. lensColorTexture: Nullable<Texture>;
  58970. /**
  58971. * The overall strengh for the lens flare effect
  58972. */
  58973. lensFlareStrength: number;
  58974. /**
  58975. * Dispersion coefficient for lens flare ghosts
  58976. */
  58977. lensFlareGhostDispersal: number;
  58978. /**
  58979. * Main lens flare halo width
  58980. */
  58981. lensFlareHaloWidth: number;
  58982. /**
  58983. * Based on the lens distortion effect, defines how much the lens flare result
  58984. * is distorted
  58985. */
  58986. lensFlareDistortionStrength: number;
  58987. /**
  58988. * Lens star texture must be used to simulate rays on the flares and is available
  58989. * in the documentation
  58990. */
  58991. lensStarTexture: Nullable<Texture>;
  58992. /**
  58993. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  58994. * flare effect by taking account of the dirt texture
  58995. */
  58996. lensFlareDirtTexture: Nullable<Texture>;
  58997. /**
  58998. * Represents the focal length for the depth of field effect
  58999. */
  59000. depthOfFieldDistance: number;
  59001. /**
  59002. * Represents the blur intensity for the blurred part of the depth of field effect
  59003. */
  59004. depthOfFieldBlurWidth: number;
  59005. /**
  59006. * Gets how much the image is blurred by the movement while using the motion blur post-process
  59007. */
  59008. /**
  59009. * Sets how much the image is blurred by the movement while using the motion blur post-process
  59010. */
  59011. motionStrength: number;
  59012. /**
  59013. * Gets wether or not the motion blur post-process is object based or screen based.
  59014. */
  59015. /**
  59016. * Sets wether or not the motion blur post-process should be object based or screen based
  59017. */
  59018. objectBasedMotionBlur: boolean;
  59019. /**
  59020. * List of animations for the pipeline (IAnimatable implementation)
  59021. */
  59022. animations: Animation[];
  59023. /**
  59024. * Private members
  59025. */
  59026. private _scene;
  59027. private _currentDepthOfFieldSource;
  59028. private _basePostProcess;
  59029. private _fixedExposure;
  59030. private _currentExposure;
  59031. private _hdrAutoExposure;
  59032. private _hdrCurrentLuminance;
  59033. private _motionStrength;
  59034. private _isObjectBasedMotionBlur;
  59035. private _floatTextureType;
  59036. private _camerasToBeAttached;
  59037. private _ratio;
  59038. private _bloomEnabled;
  59039. private _depthOfFieldEnabled;
  59040. private _vlsEnabled;
  59041. private _lensFlareEnabled;
  59042. private _hdrEnabled;
  59043. private _motionBlurEnabled;
  59044. private _fxaaEnabled;
  59045. private _motionBlurSamples;
  59046. private _volumetricLightStepsCount;
  59047. private _samples;
  59048. /**
  59049. * @ignore
  59050. * Specifies if the bloom pipeline is enabled
  59051. */
  59052. BloomEnabled: boolean;
  59053. /**
  59054. * @ignore
  59055. * Specifies if the depth of field pipeline is enabed
  59056. */
  59057. DepthOfFieldEnabled: boolean;
  59058. /**
  59059. * @ignore
  59060. * Specifies if the lens flare pipeline is enabed
  59061. */
  59062. LensFlareEnabled: boolean;
  59063. /**
  59064. * @ignore
  59065. * Specifies if the HDR pipeline is enabled
  59066. */
  59067. HDREnabled: boolean;
  59068. /**
  59069. * @ignore
  59070. * Specifies if the volumetric lights scattering effect is enabled
  59071. */
  59072. VLSEnabled: boolean;
  59073. /**
  59074. * @ignore
  59075. * Specifies if the motion blur effect is enabled
  59076. */
  59077. MotionBlurEnabled: boolean;
  59078. /**
  59079. * Specifies if anti-aliasing is enabled
  59080. */
  59081. fxaaEnabled: boolean;
  59082. /**
  59083. * Specifies the number of steps used to calculate the volumetric lights
  59084. * Typically in interval [50, 200]
  59085. */
  59086. volumetricLightStepsCount: number;
  59087. /**
  59088. * Specifies the number of samples used for the motion blur effect
  59089. * Typically in interval [16, 64]
  59090. */
  59091. motionBlurSamples: number;
  59092. /**
  59093. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59094. */
  59095. samples: number;
  59096. /**
  59097. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59098. * @constructor
  59099. * @param name The rendering pipeline name
  59100. * @param scene The scene linked to this pipeline
  59101. * @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)
  59102. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  59103. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59104. */
  59105. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  59106. private _buildPipeline;
  59107. private _createDownSampleX4PostProcess;
  59108. private _createBrightPassPostProcess;
  59109. private _createBlurPostProcesses;
  59110. private _createTextureAdderPostProcess;
  59111. private _createVolumetricLightPostProcess;
  59112. private _createLuminancePostProcesses;
  59113. private _createHdrPostProcess;
  59114. private _createLensFlarePostProcess;
  59115. private _createDepthOfFieldPostProcess;
  59116. private _createMotionBlurPostProcess;
  59117. private _getDepthTexture;
  59118. private _disposePostProcesses;
  59119. /**
  59120. * Dispose of the pipeline and stop all post processes
  59121. */
  59122. dispose(): void;
  59123. /**
  59124. * Serialize the rendering pipeline (Used when exporting)
  59125. * @returns the serialized object
  59126. */
  59127. serialize(): any;
  59128. /**
  59129. * Parse the serialized pipeline
  59130. * @param source Source pipeline.
  59131. * @param scene The scene to load the pipeline to.
  59132. * @param rootUrl The URL of the serialized pipeline.
  59133. * @returns An instantiated pipeline from the serialized object.
  59134. */
  59135. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  59136. /**
  59137. * Luminance steps
  59138. */
  59139. static LuminanceSteps: number;
  59140. }
  59141. }
  59142. declare module BABYLON {
  59143. /** @hidden */
  59144. export var tonemapPixelShader: {
  59145. name: string;
  59146. shader: string;
  59147. };
  59148. }
  59149. declare module BABYLON {
  59150. /** Defines operator used for tonemapping */
  59151. export enum TonemappingOperator {
  59152. /** Hable */
  59153. Hable = 0,
  59154. /** Reinhard */
  59155. Reinhard = 1,
  59156. /** HejiDawson */
  59157. HejiDawson = 2,
  59158. /** Photographic */
  59159. Photographic = 3
  59160. }
  59161. /**
  59162. * Defines a post process to apply tone mapping
  59163. */
  59164. export class TonemapPostProcess extends PostProcess {
  59165. private _operator;
  59166. /** Defines the required exposure adjustement */
  59167. exposureAdjustment: number;
  59168. /**
  59169. * Creates a new TonemapPostProcess
  59170. * @param name defines the name of the postprocess
  59171. * @param _operator defines the operator to use
  59172. * @param exposureAdjustment defines the required exposure adjustement
  59173. * @param camera defines the camera to use (can be null)
  59174. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  59175. * @param engine defines the hosting engine (can be ignore if camera is set)
  59176. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59177. */
  59178. constructor(name: string, _operator: TonemappingOperator,
  59179. /** Defines the required exposure adjustement */
  59180. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  59181. }
  59182. }
  59183. declare module BABYLON {
  59184. /** @hidden */
  59185. export var depthVertexShader: {
  59186. name: string;
  59187. shader: string;
  59188. };
  59189. }
  59190. declare module BABYLON {
  59191. /** @hidden */
  59192. export var volumetricLightScatteringPixelShader: {
  59193. name: string;
  59194. shader: string;
  59195. };
  59196. }
  59197. declare module BABYLON {
  59198. /** @hidden */
  59199. export var volumetricLightScatteringPassVertexShader: {
  59200. name: string;
  59201. shader: string;
  59202. };
  59203. }
  59204. declare module BABYLON {
  59205. /** @hidden */
  59206. export var volumetricLightScatteringPassPixelShader: {
  59207. name: string;
  59208. shader: string;
  59209. };
  59210. }
  59211. declare module BABYLON {
  59212. /**
  59213. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  59214. */
  59215. export class VolumetricLightScatteringPostProcess extends PostProcess {
  59216. private _volumetricLightScatteringPass;
  59217. private _volumetricLightScatteringRTT;
  59218. private _viewPort;
  59219. private _screenCoordinates;
  59220. private _cachedDefines;
  59221. /**
  59222. * If not undefined, the mesh position is computed from the attached node position
  59223. */
  59224. attachedNode: {
  59225. position: Vector3;
  59226. };
  59227. /**
  59228. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  59229. */
  59230. customMeshPosition: Vector3;
  59231. /**
  59232. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  59233. */
  59234. useCustomMeshPosition: boolean;
  59235. /**
  59236. * If the post-process should inverse the light scattering direction
  59237. */
  59238. invert: boolean;
  59239. /**
  59240. * The internal mesh used by the post-process
  59241. */
  59242. mesh: Mesh;
  59243. /**
  59244. * @hidden
  59245. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  59246. */
  59247. useDiffuseColor: boolean;
  59248. /**
  59249. * Array containing the excluded meshes not rendered in the internal pass
  59250. */
  59251. excludedMeshes: AbstractMesh[];
  59252. /**
  59253. * Controls the overall intensity of the post-process
  59254. */
  59255. exposure: number;
  59256. /**
  59257. * Dissipates each sample's contribution in range [0, 1]
  59258. */
  59259. decay: number;
  59260. /**
  59261. * Controls the overall intensity of each sample
  59262. */
  59263. weight: number;
  59264. /**
  59265. * Controls the density of each sample
  59266. */
  59267. density: number;
  59268. /**
  59269. * @constructor
  59270. * @param name The post-process name
  59271. * @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)
  59272. * @param camera The camera that the post-process will be attached to
  59273. * @param mesh The mesh used to create the light scattering
  59274. * @param samples The post-process quality, default 100
  59275. * @param samplingModeThe post-process filtering mode
  59276. * @param engine The babylon engine
  59277. * @param reusable If the post-process is reusable
  59278. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  59279. */
  59280. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  59281. /**
  59282. * Returns the string "VolumetricLightScatteringPostProcess"
  59283. * @returns "VolumetricLightScatteringPostProcess"
  59284. */
  59285. getClassName(): string;
  59286. private _isReady;
  59287. /**
  59288. * Sets the new light position for light scattering effect
  59289. * @param position The new custom light position
  59290. */
  59291. setCustomMeshPosition(position: Vector3): void;
  59292. /**
  59293. * Returns the light position for light scattering effect
  59294. * @return Vector3 The custom light position
  59295. */
  59296. getCustomMeshPosition(): Vector3;
  59297. /**
  59298. * Disposes the internal assets and detaches the post-process from the camera
  59299. */
  59300. dispose(camera: Camera): void;
  59301. /**
  59302. * Returns the render target texture used by the post-process
  59303. * @return the render target texture used by the post-process
  59304. */
  59305. getPass(): RenderTargetTexture;
  59306. private _meshExcluded;
  59307. private _createPass;
  59308. private _updateMeshScreenCoordinates;
  59309. /**
  59310. * Creates a default mesh for the Volumeric Light Scattering post-process
  59311. * @param name The mesh name
  59312. * @param scene The scene where to create the mesh
  59313. * @return the default mesh
  59314. */
  59315. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  59316. }
  59317. }
  59318. declare module BABYLON {
  59319. interface Scene {
  59320. /** @hidden (Backing field) */
  59321. _boundingBoxRenderer: BoundingBoxRenderer;
  59322. /** @hidden (Backing field) */
  59323. _forceShowBoundingBoxes: boolean;
  59324. /**
  59325. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  59326. */
  59327. forceShowBoundingBoxes: boolean;
  59328. /**
  59329. * Gets the bounding box renderer associated with the scene
  59330. * @returns a BoundingBoxRenderer
  59331. */
  59332. getBoundingBoxRenderer(): BoundingBoxRenderer;
  59333. }
  59334. interface AbstractMesh {
  59335. /** @hidden (Backing field) */
  59336. _showBoundingBox: boolean;
  59337. /**
  59338. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  59339. */
  59340. showBoundingBox: boolean;
  59341. }
  59342. /**
  59343. * Component responsible of rendering the bounding box of the meshes in a scene.
  59344. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  59345. */
  59346. export class BoundingBoxRenderer implements ISceneComponent {
  59347. /**
  59348. * The component name helpfull to identify the component in the list of scene components.
  59349. */
  59350. readonly name: string;
  59351. /**
  59352. * The scene the component belongs to.
  59353. */
  59354. scene: Scene;
  59355. /**
  59356. * Color of the bounding box lines placed in front of an object
  59357. */
  59358. frontColor: Color3;
  59359. /**
  59360. * Color of the bounding box lines placed behind an object
  59361. */
  59362. backColor: Color3;
  59363. /**
  59364. * Defines if the renderer should show the back lines or not
  59365. */
  59366. showBackLines: boolean;
  59367. /**
  59368. * @hidden
  59369. */
  59370. renderList: SmartArray<BoundingBox>;
  59371. private _colorShader;
  59372. private _vertexBuffers;
  59373. private _indexBuffer;
  59374. private _fillIndexBuffer;
  59375. private _fillIndexData;
  59376. /**
  59377. * Instantiates a new bounding box renderer in a scene.
  59378. * @param scene the scene the renderer renders in
  59379. */
  59380. constructor(scene: Scene);
  59381. /**
  59382. * Registers the component in a given scene
  59383. */
  59384. register(): void;
  59385. private _evaluateSubMesh;
  59386. private _activeMesh;
  59387. private _prepareRessources;
  59388. private _createIndexBuffer;
  59389. /**
  59390. * Rebuilds the elements related to this component in case of
  59391. * context lost for instance.
  59392. */
  59393. rebuild(): void;
  59394. /**
  59395. * @hidden
  59396. */
  59397. reset(): void;
  59398. /**
  59399. * Render the bounding boxes of a specific rendering group
  59400. * @param renderingGroupId defines the rendering group to render
  59401. */
  59402. render(renderingGroupId: number): void;
  59403. /**
  59404. * In case of occlusion queries, we can render the occlusion bounding box through this method
  59405. * @param mesh Define the mesh to render the occlusion bounding box for
  59406. */
  59407. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  59408. /**
  59409. * Dispose and release the resources attached to this renderer.
  59410. */
  59411. dispose(): void;
  59412. }
  59413. }
  59414. declare module BABYLON {
  59415. /** @hidden */
  59416. export var depthPixelShader: {
  59417. name: string;
  59418. shader: string;
  59419. };
  59420. }
  59421. declare module BABYLON {
  59422. /**
  59423. * This represents a depth renderer in Babylon.
  59424. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59425. */
  59426. export class DepthRenderer {
  59427. private _scene;
  59428. private _depthMap;
  59429. private _effect;
  59430. private readonly _storeNonLinearDepth;
  59431. private readonly _clearColor;
  59432. /** Get if the depth renderer is using packed depth or not */
  59433. readonly isPacked: boolean;
  59434. private _cachedDefines;
  59435. private _camera;
  59436. /**
  59437. * Specifiess that the depth renderer will only be used within
  59438. * the camera it is created for.
  59439. * This can help forcing its rendering during the camera processing.
  59440. */
  59441. useOnlyInActiveCamera: boolean;
  59442. /** @hidden */
  59443. static _SceneComponentInitialization: (scene: Scene) => void;
  59444. /**
  59445. * Instantiates a depth renderer
  59446. * @param scene The scene the renderer belongs to
  59447. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59448. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59449. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59450. */
  59451. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  59452. /**
  59453. * Creates the depth rendering effect and checks if the effect is ready.
  59454. * @param subMesh The submesh to be used to render the depth map of
  59455. * @param useInstances If multiple world instances should be used
  59456. * @returns if the depth renderer is ready to render the depth map
  59457. */
  59458. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59459. /**
  59460. * Gets the texture which the depth map will be written to.
  59461. * @returns The depth map texture
  59462. */
  59463. getDepthMap(): RenderTargetTexture;
  59464. /**
  59465. * Disposes of the depth renderer.
  59466. */
  59467. dispose(): void;
  59468. }
  59469. }
  59470. declare module BABYLON {
  59471. interface Scene {
  59472. /** @hidden (Backing field) */
  59473. _depthRenderer: {
  59474. [id: string]: DepthRenderer;
  59475. };
  59476. /**
  59477. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  59478. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  59479. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59480. * @returns the created depth renderer
  59481. */
  59482. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  59483. /**
  59484. * Disables a depth renderer for a given camera
  59485. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  59486. */
  59487. disableDepthRenderer(camera?: Nullable<Camera>): void;
  59488. }
  59489. /**
  59490. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  59491. * in several rendering techniques.
  59492. */
  59493. export class DepthRendererSceneComponent implements ISceneComponent {
  59494. /**
  59495. * The component name helpfull to identify the component in the list of scene components.
  59496. */
  59497. readonly name: string;
  59498. /**
  59499. * The scene the component belongs to.
  59500. */
  59501. scene: Scene;
  59502. /**
  59503. * Creates a new instance of the component for the given scene
  59504. * @param scene Defines the scene to register the component in
  59505. */
  59506. constructor(scene: Scene);
  59507. /**
  59508. * Registers the component in a given scene
  59509. */
  59510. register(): void;
  59511. /**
  59512. * Rebuilds the elements related to this component in case of
  59513. * context lost for instance.
  59514. */
  59515. rebuild(): void;
  59516. /**
  59517. * Disposes the component and the associated ressources
  59518. */
  59519. dispose(): void;
  59520. private _gatherRenderTargets;
  59521. private _gatherActiveCameraRenderTargets;
  59522. }
  59523. }
  59524. declare module BABYLON {
  59525. /** @hidden */
  59526. export var outlinePixelShader: {
  59527. name: string;
  59528. shader: string;
  59529. };
  59530. }
  59531. declare module BABYLON {
  59532. /** @hidden */
  59533. export var outlineVertexShader: {
  59534. name: string;
  59535. shader: string;
  59536. };
  59537. }
  59538. declare module BABYLON {
  59539. interface Scene {
  59540. /** @hidden */
  59541. _outlineRenderer: OutlineRenderer;
  59542. /**
  59543. * Gets the outline renderer associated with the scene
  59544. * @returns a OutlineRenderer
  59545. */
  59546. getOutlineRenderer(): OutlineRenderer;
  59547. }
  59548. interface AbstractMesh {
  59549. /** @hidden (Backing field) */
  59550. _renderOutline: boolean;
  59551. /**
  59552. * Gets or sets a boolean indicating if the outline must be rendered as well
  59553. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  59554. */
  59555. renderOutline: boolean;
  59556. /** @hidden (Backing field) */
  59557. _renderOverlay: boolean;
  59558. /**
  59559. * Gets or sets a boolean indicating if the overlay must be rendered as well
  59560. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  59561. */
  59562. renderOverlay: boolean;
  59563. }
  59564. /**
  59565. * This class is responsible to draw bothe outline/overlay of meshes.
  59566. * It should not be used directly but through the available method on mesh.
  59567. */
  59568. export class OutlineRenderer implements ISceneComponent {
  59569. /**
  59570. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  59571. */
  59572. private static _StencilReference;
  59573. /**
  59574. * The name of the component. Each component must have a unique name.
  59575. */
  59576. name: string;
  59577. /**
  59578. * The scene the component belongs to.
  59579. */
  59580. scene: Scene;
  59581. /**
  59582. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  59583. */
  59584. zOffset: number;
  59585. private _engine;
  59586. private _effect;
  59587. private _cachedDefines;
  59588. private _savedDepthWrite;
  59589. /**
  59590. * Instantiates a new outline renderer. (There could be only one per scene).
  59591. * @param scene Defines the scene it belongs to
  59592. */
  59593. constructor(scene: Scene);
  59594. /**
  59595. * Register the component to one instance of a scene.
  59596. */
  59597. register(): void;
  59598. /**
  59599. * Rebuilds the elements related to this component in case of
  59600. * context lost for instance.
  59601. */
  59602. rebuild(): void;
  59603. /**
  59604. * Disposes the component and the associated ressources.
  59605. */
  59606. dispose(): void;
  59607. /**
  59608. * Renders the outline in the canvas.
  59609. * @param subMesh Defines the sumesh to render
  59610. * @param batch Defines the batch of meshes in case of instances
  59611. * @param useOverlay Defines if the rendering is for the overlay or the outline
  59612. */
  59613. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  59614. /**
  59615. * Returns whether or not the outline renderer is ready for a given submesh.
  59616. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  59617. * @param subMesh Defines the submesh to check readyness for
  59618. * @param useInstances Defines wheter wee are trying to render instances or not
  59619. * @returns true if ready otherwise false
  59620. */
  59621. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59622. private _beforeRenderingMesh;
  59623. private _afterRenderingMesh;
  59624. }
  59625. }
  59626. declare module BABYLON {
  59627. /**
  59628. * Class used to manage multiple sprites of different sizes on the same spritesheet
  59629. * @see http://doc.babylonjs.com/babylon101/sprites
  59630. */
  59631. export class SpritePackedManager extends SpriteManager {
  59632. /** defines the packed manager's name */
  59633. name: string;
  59634. /**
  59635. * Creates a new sprite manager from a packed sprite sheet
  59636. * @param name defines the manager's name
  59637. * @param imgUrl defines the sprite sheet url
  59638. * @param capacity defines the maximum allowed number of sprites
  59639. * @param scene defines the hosting scene
  59640. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  59641. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  59642. * @param samplingMode defines the smapling mode to use with spritesheet
  59643. * @param fromPacked set to true; do not alter
  59644. */
  59645. constructor(
  59646. /** defines the packed manager's name */
  59647. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  59648. }
  59649. }
  59650. declare module BABYLON {
  59651. /**
  59652. * Defines the list of states available for a task inside a AssetsManager
  59653. */
  59654. export enum AssetTaskState {
  59655. /**
  59656. * Initialization
  59657. */
  59658. INIT = 0,
  59659. /**
  59660. * Running
  59661. */
  59662. RUNNING = 1,
  59663. /**
  59664. * Done
  59665. */
  59666. DONE = 2,
  59667. /**
  59668. * Error
  59669. */
  59670. ERROR = 3
  59671. }
  59672. /**
  59673. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  59674. */
  59675. export abstract class AbstractAssetTask {
  59676. /**
  59677. * Task name
  59678. */ name: string;
  59679. /**
  59680. * Callback called when the task is successful
  59681. */
  59682. onSuccess: (task: any) => void;
  59683. /**
  59684. * Callback called when the task is not successful
  59685. */
  59686. onError: (task: any, message?: string, exception?: any) => void;
  59687. /**
  59688. * Creates a new AssetsManager
  59689. * @param name defines the name of the task
  59690. */
  59691. constructor(
  59692. /**
  59693. * Task name
  59694. */ name: string);
  59695. private _isCompleted;
  59696. private _taskState;
  59697. private _errorObject;
  59698. /**
  59699. * Get if the task is completed
  59700. */
  59701. readonly isCompleted: boolean;
  59702. /**
  59703. * Gets the current state of the task
  59704. */
  59705. readonly taskState: AssetTaskState;
  59706. /**
  59707. * Gets the current error object (if task is in error)
  59708. */
  59709. readonly errorObject: {
  59710. message?: string;
  59711. exception?: any;
  59712. };
  59713. /**
  59714. * Internal only
  59715. * @hidden
  59716. */
  59717. _setErrorObject(message?: string, exception?: any): void;
  59718. /**
  59719. * Execute the current task
  59720. * @param scene defines the scene where you want your assets to be loaded
  59721. * @param onSuccess is a callback called when the task is successfully executed
  59722. * @param onError is a callback called if an error occurs
  59723. */
  59724. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59725. /**
  59726. * Execute the current task
  59727. * @param scene defines the scene where you want your assets to be loaded
  59728. * @param onSuccess is a callback called when the task is successfully executed
  59729. * @param onError is a callback called if an error occurs
  59730. */
  59731. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59732. /**
  59733. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  59734. * This can be used with failed tasks that have the reason for failure fixed.
  59735. */
  59736. reset(): void;
  59737. private onErrorCallback;
  59738. private onDoneCallback;
  59739. }
  59740. /**
  59741. * Define the interface used by progress events raised during assets loading
  59742. */
  59743. export interface IAssetsProgressEvent {
  59744. /**
  59745. * Defines the number of remaining tasks to process
  59746. */
  59747. remainingCount: number;
  59748. /**
  59749. * Defines the total number of tasks
  59750. */
  59751. totalCount: number;
  59752. /**
  59753. * Defines the task that was just processed
  59754. */
  59755. task: AbstractAssetTask;
  59756. }
  59757. /**
  59758. * Class used to share progress information about assets loading
  59759. */
  59760. export class AssetsProgressEvent implements IAssetsProgressEvent {
  59761. /**
  59762. * Defines the number of remaining tasks to process
  59763. */
  59764. remainingCount: number;
  59765. /**
  59766. * Defines the total number of tasks
  59767. */
  59768. totalCount: number;
  59769. /**
  59770. * Defines the task that was just processed
  59771. */
  59772. task: AbstractAssetTask;
  59773. /**
  59774. * Creates a AssetsProgressEvent
  59775. * @param remainingCount defines the number of remaining tasks to process
  59776. * @param totalCount defines the total number of tasks
  59777. * @param task defines the task that was just processed
  59778. */
  59779. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  59780. }
  59781. /**
  59782. * Define a task used by AssetsManager to load meshes
  59783. */
  59784. export class MeshAssetTask extends AbstractAssetTask {
  59785. /**
  59786. * Defines the name of the task
  59787. */
  59788. name: string;
  59789. /**
  59790. * Defines the list of mesh's names you want to load
  59791. */
  59792. meshesNames: any;
  59793. /**
  59794. * Defines the root url to use as a base to load your meshes and associated resources
  59795. */
  59796. rootUrl: string;
  59797. /**
  59798. * Defines the filename of the scene to load from
  59799. */
  59800. sceneFilename: string;
  59801. /**
  59802. * Gets the list of loaded meshes
  59803. */
  59804. loadedMeshes: Array<AbstractMesh>;
  59805. /**
  59806. * Gets the list of loaded particle systems
  59807. */
  59808. loadedParticleSystems: Array<IParticleSystem>;
  59809. /**
  59810. * Gets the list of loaded skeletons
  59811. */
  59812. loadedSkeletons: Array<Skeleton>;
  59813. /**
  59814. * Gets the list of loaded animation groups
  59815. */
  59816. loadedAnimationGroups: Array<AnimationGroup>;
  59817. /**
  59818. * Callback called when the task is successful
  59819. */
  59820. onSuccess: (task: MeshAssetTask) => void;
  59821. /**
  59822. * Callback called when the task is successful
  59823. */
  59824. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  59825. /**
  59826. * Creates a new MeshAssetTask
  59827. * @param name defines the name of the task
  59828. * @param meshesNames defines the list of mesh's names you want to load
  59829. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  59830. * @param sceneFilename defines the filename of the scene to load from
  59831. */
  59832. constructor(
  59833. /**
  59834. * Defines the name of the task
  59835. */
  59836. name: string,
  59837. /**
  59838. * Defines the list of mesh's names you want to load
  59839. */
  59840. meshesNames: any,
  59841. /**
  59842. * Defines the root url to use as a base to load your meshes and associated resources
  59843. */
  59844. rootUrl: string,
  59845. /**
  59846. * Defines the filename of the scene to load from
  59847. */
  59848. sceneFilename: string);
  59849. /**
  59850. * Execute the current task
  59851. * @param scene defines the scene where you want your assets to be loaded
  59852. * @param onSuccess is a callback called when the task is successfully executed
  59853. * @param onError is a callback called if an error occurs
  59854. */
  59855. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59856. }
  59857. /**
  59858. * Define a task used by AssetsManager to load text content
  59859. */
  59860. export class TextFileAssetTask extends AbstractAssetTask {
  59861. /**
  59862. * Defines the name of the task
  59863. */
  59864. name: string;
  59865. /**
  59866. * Defines the location of the file to load
  59867. */
  59868. url: string;
  59869. /**
  59870. * Gets the loaded text string
  59871. */
  59872. text: string;
  59873. /**
  59874. * Callback called when the task is successful
  59875. */
  59876. onSuccess: (task: TextFileAssetTask) => void;
  59877. /**
  59878. * Callback called when the task is successful
  59879. */
  59880. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  59881. /**
  59882. * Creates a new TextFileAssetTask object
  59883. * @param name defines the name of the task
  59884. * @param url defines the location of the file to load
  59885. */
  59886. constructor(
  59887. /**
  59888. * Defines the name of the task
  59889. */
  59890. name: string,
  59891. /**
  59892. * Defines the location of the file to load
  59893. */
  59894. url: string);
  59895. /**
  59896. * Execute the current task
  59897. * @param scene defines the scene where you want your assets to be loaded
  59898. * @param onSuccess is a callback called when the task is successfully executed
  59899. * @param onError is a callback called if an error occurs
  59900. */
  59901. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59902. }
  59903. /**
  59904. * Define a task used by AssetsManager to load binary data
  59905. */
  59906. export class BinaryFileAssetTask extends AbstractAssetTask {
  59907. /**
  59908. * Defines the name of the task
  59909. */
  59910. name: string;
  59911. /**
  59912. * Defines the location of the file to load
  59913. */
  59914. url: string;
  59915. /**
  59916. * Gets the lodaded data (as an array buffer)
  59917. */
  59918. data: ArrayBuffer;
  59919. /**
  59920. * Callback called when the task is successful
  59921. */
  59922. onSuccess: (task: BinaryFileAssetTask) => void;
  59923. /**
  59924. * Callback called when the task is successful
  59925. */
  59926. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  59927. /**
  59928. * Creates a new BinaryFileAssetTask object
  59929. * @param name defines the name of the new task
  59930. * @param url defines the location of the file to load
  59931. */
  59932. constructor(
  59933. /**
  59934. * Defines the name of the task
  59935. */
  59936. name: string,
  59937. /**
  59938. * Defines the location of the file to load
  59939. */
  59940. url: string);
  59941. /**
  59942. * Execute the current task
  59943. * @param scene defines the scene where you want your assets to be loaded
  59944. * @param onSuccess is a callback called when the task is successfully executed
  59945. * @param onError is a callback called if an error occurs
  59946. */
  59947. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59948. }
  59949. /**
  59950. * Define a task used by AssetsManager to load images
  59951. */
  59952. export class ImageAssetTask extends AbstractAssetTask {
  59953. /**
  59954. * Defines the name of the task
  59955. */
  59956. name: string;
  59957. /**
  59958. * Defines the location of the image to load
  59959. */
  59960. url: string;
  59961. /**
  59962. * Gets the loaded images
  59963. */
  59964. image: HTMLImageElement;
  59965. /**
  59966. * Callback called when the task is successful
  59967. */
  59968. onSuccess: (task: ImageAssetTask) => void;
  59969. /**
  59970. * Callback called when the task is successful
  59971. */
  59972. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  59973. /**
  59974. * Creates a new ImageAssetTask
  59975. * @param name defines the name of the task
  59976. * @param url defines the location of the image to load
  59977. */
  59978. constructor(
  59979. /**
  59980. * Defines the name of the task
  59981. */
  59982. name: string,
  59983. /**
  59984. * Defines the location of the image to load
  59985. */
  59986. url: string);
  59987. /**
  59988. * Execute the current task
  59989. * @param scene defines the scene where you want your assets to be loaded
  59990. * @param onSuccess is a callback called when the task is successfully executed
  59991. * @param onError is a callback called if an error occurs
  59992. */
  59993. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59994. }
  59995. /**
  59996. * Defines the interface used by texture loading tasks
  59997. */
  59998. export interface ITextureAssetTask<TEX extends BaseTexture> {
  59999. /**
  60000. * Gets the loaded texture
  60001. */
  60002. texture: TEX;
  60003. }
  60004. /**
  60005. * Define a task used by AssetsManager to load 2D textures
  60006. */
  60007. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  60008. /**
  60009. * Defines the name of the task
  60010. */
  60011. name: string;
  60012. /**
  60013. * Defines the location of the file to load
  60014. */
  60015. url: string;
  60016. /**
  60017. * Defines if mipmap should not be generated (default is false)
  60018. */
  60019. noMipmap?: boolean | undefined;
  60020. /**
  60021. * Defines if texture must be inverted on Y axis (default is false)
  60022. */
  60023. invertY?: boolean | undefined;
  60024. /**
  60025. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60026. */
  60027. samplingMode: number;
  60028. /**
  60029. * Gets the loaded texture
  60030. */
  60031. texture: Texture;
  60032. /**
  60033. * Callback called when the task is successful
  60034. */
  60035. onSuccess: (task: TextureAssetTask) => void;
  60036. /**
  60037. * Callback called when the task is successful
  60038. */
  60039. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  60040. /**
  60041. * Creates a new TextureAssetTask object
  60042. * @param name defines the name of the task
  60043. * @param url defines the location of the file to load
  60044. * @param noMipmap defines if mipmap should not be generated (default is false)
  60045. * @param invertY defines if texture must be inverted on Y axis (default is false)
  60046. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60047. */
  60048. constructor(
  60049. /**
  60050. * Defines the name of the task
  60051. */
  60052. name: string,
  60053. /**
  60054. * Defines the location of the file to load
  60055. */
  60056. url: string,
  60057. /**
  60058. * Defines if mipmap should not be generated (default is false)
  60059. */
  60060. noMipmap?: boolean | undefined,
  60061. /**
  60062. * Defines if texture must be inverted on Y axis (default is false)
  60063. */
  60064. invertY?: boolean | undefined,
  60065. /**
  60066. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60067. */
  60068. samplingMode?: number);
  60069. /**
  60070. * Execute the current task
  60071. * @param scene defines the scene where you want your assets to be loaded
  60072. * @param onSuccess is a callback called when the task is successfully executed
  60073. * @param onError is a callback called if an error occurs
  60074. */
  60075. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60076. }
  60077. /**
  60078. * Define a task used by AssetsManager to load cube textures
  60079. */
  60080. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  60081. /**
  60082. * Defines the name of the task
  60083. */
  60084. name: string;
  60085. /**
  60086. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60087. */
  60088. url: string;
  60089. /**
  60090. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60091. */
  60092. extensions?: string[] | undefined;
  60093. /**
  60094. * Defines if mipmaps should not be generated (default is false)
  60095. */
  60096. noMipmap?: boolean | undefined;
  60097. /**
  60098. * Defines the explicit list of files (undefined by default)
  60099. */
  60100. files?: string[] | undefined;
  60101. /**
  60102. * Gets the loaded texture
  60103. */
  60104. texture: CubeTexture;
  60105. /**
  60106. * Callback called when the task is successful
  60107. */
  60108. onSuccess: (task: CubeTextureAssetTask) => void;
  60109. /**
  60110. * Callback called when the task is successful
  60111. */
  60112. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  60113. /**
  60114. * Creates a new CubeTextureAssetTask
  60115. * @param name defines the name of the task
  60116. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60117. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60118. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60119. * @param files defines the explicit list of files (undefined by default)
  60120. */
  60121. constructor(
  60122. /**
  60123. * Defines the name of the task
  60124. */
  60125. name: string,
  60126. /**
  60127. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60128. */
  60129. url: string,
  60130. /**
  60131. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60132. */
  60133. extensions?: string[] | undefined,
  60134. /**
  60135. * Defines if mipmaps should not be generated (default is false)
  60136. */
  60137. noMipmap?: boolean | undefined,
  60138. /**
  60139. * Defines the explicit list of files (undefined by default)
  60140. */
  60141. files?: string[] | undefined);
  60142. /**
  60143. * Execute the current task
  60144. * @param scene defines the scene where you want your assets to be loaded
  60145. * @param onSuccess is a callback called when the task is successfully executed
  60146. * @param onError is a callback called if an error occurs
  60147. */
  60148. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60149. }
  60150. /**
  60151. * Define a task used by AssetsManager to load HDR cube textures
  60152. */
  60153. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  60154. /**
  60155. * Defines the name of the task
  60156. */
  60157. name: string;
  60158. /**
  60159. * Defines the location of the file to load
  60160. */
  60161. url: string;
  60162. /**
  60163. * Defines the desired size (the more it increases the longer the generation will be)
  60164. */
  60165. size: number;
  60166. /**
  60167. * Defines if mipmaps should not be generated (default is false)
  60168. */
  60169. noMipmap: boolean;
  60170. /**
  60171. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60172. */
  60173. generateHarmonics: boolean;
  60174. /**
  60175. * 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)
  60176. */
  60177. gammaSpace: boolean;
  60178. /**
  60179. * Internal Use Only
  60180. */
  60181. reserved: boolean;
  60182. /**
  60183. * Gets the loaded texture
  60184. */
  60185. texture: HDRCubeTexture;
  60186. /**
  60187. * Callback called when the task is successful
  60188. */
  60189. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  60190. /**
  60191. * Callback called when the task is successful
  60192. */
  60193. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  60194. /**
  60195. * Creates a new HDRCubeTextureAssetTask object
  60196. * @param name defines the name of the task
  60197. * @param url defines the location of the file to load
  60198. * @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.
  60199. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60200. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60201. * @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)
  60202. * @param reserved Internal use only
  60203. */
  60204. constructor(
  60205. /**
  60206. * Defines the name of the task
  60207. */
  60208. name: string,
  60209. /**
  60210. * Defines the location of the file to load
  60211. */
  60212. url: string,
  60213. /**
  60214. * Defines the desired size (the more it increases the longer the generation will be)
  60215. */
  60216. size: number,
  60217. /**
  60218. * Defines if mipmaps should not be generated (default is false)
  60219. */
  60220. noMipmap?: boolean,
  60221. /**
  60222. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60223. */
  60224. generateHarmonics?: boolean,
  60225. /**
  60226. * 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)
  60227. */
  60228. gammaSpace?: boolean,
  60229. /**
  60230. * Internal Use Only
  60231. */
  60232. reserved?: boolean);
  60233. /**
  60234. * Execute the current task
  60235. * @param scene defines the scene where you want your assets to be loaded
  60236. * @param onSuccess is a callback called when the task is successfully executed
  60237. * @param onError is a callback called if an error occurs
  60238. */
  60239. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60240. }
  60241. /**
  60242. * Define a task used by AssetsManager to load Equirectangular cube textures
  60243. */
  60244. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  60245. /**
  60246. * Defines the name of the task
  60247. */
  60248. name: string;
  60249. /**
  60250. * Defines the location of the file to load
  60251. */
  60252. url: string;
  60253. /**
  60254. * Defines the desired size (the more it increases the longer the generation will be)
  60255. */
  60256. size: number;
  60257. /**
  60258. * Defines if mipmaps should not be generated (default is false)
  60259. */
  60260. noMipmap: boolean;
  60261. /**
  60262. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60263. * but the standard material would require them in Gamma space) (default is true)
  60264. */
  60265. gammaSpace: boolean;
  60266. /**
  60267. * Gets the loaded texture
  60268. */
  60269. texture: EquiRectangularCubeTexture;
  60270. /**
  60271. * Callback called when the task is successful
  60272. */
  60273. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  60274. /**
  60275. * Callback called when the task is successful
  60276. */
  60277. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  60278. /**
  60279. * Creates a new EquiRectangularCubeTextureAssetTask object
  60280. * @param name defines the name of the task
  60281. * @param url defines the location of the file to load
  60282. * @param size defines the desired size (the more it increases the longer the generation will be)
  60283. * If the size is omitted this implies you are using a preprocessed cubemap.
  60284. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60285. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  60286. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  60287. * (default is true)
  60288. */
  60289. constructor(
  60290. /**
  60291. * Defines the name of the task
  60292. */
  60293. name: string,
  60294. /**
  60295. * Defines the location of the file to load
  60296. */
  60297. url: string,
  60298. /**
  60299. * Defines the desired size (the more it increases the longer the generation will be)
  60300. */
  60301. size: number,
  60302. /**
  60303. * Defines if mipmaps should not be generated (default is false)
  60304. */
  60305. noMipmap?: boolean,
  60306. /**
  60307. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60308. * but the standard material would require them in Gamma space) (default is true)
  60309. */
  60310. gammaSpace?: boolean);
  60311. /**
  60312. * Execute the current task
  60313. * @param scene defines the scene where you want your assets to be loaded
  60314. * @param onSuccess is a callback called when the task is successfully executed
  60315. * @param onError is a callback called if an error occurs
  60316. */
  60317. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60318. }
  60319. /**
  60320. * This class can be used to easily import assets into a scene
  60321. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  60322. */
  60323. export class AssetsManager {
  60324. private _scene;
  60325. private _isLoading;
  60326. protected _tasks: AbstractAssetTask[];
  60327. protected _waitingTasksCount: number;
  60328. protected _totalTasksCount: number;
  60329. /**
  60330. * Callback called when all tasks are processed
  60331. */
  60332. onFinish: (tasks: AbstractAssetTask[]) => void;
  60333. /**
  60334. * Callback called when a task is successful
  60335. */
  60336. onTaskSuccess: (task: AbstractAssetTask) => void;
  60337. /**
  60338. * Callback called when a task had an error
  60339. */
  60340. onTaskError: (task: AbstractAssetTask) => void;
  60341. /**
  60342. * Callback called when a task is done (whatever the result is)
  60343. */
  60344. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  60345. /**
  60346. * Observable called when all tasks are processed
  60347. */
  60348. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  60349. /**
  60350. * Observable called when a task had an error
  60351. */
  60352. onTaskErrorObservable: Observable<AbstractAssetTask>;
  60353. /**
  60354. * Observable called when all tasks were executed
  60355. */
  60356. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  60357. /**
  60358. * Observable called when a task is done (whatever the result is)
  60359. */
  60360. onProgressObservable: Observable<IAssetsProgressEvent>;
  60361. /**
  60362. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  60363. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  60364. */
  60365. useDefaultLoadingScreen: boolean;
  60366. /**
  60367. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  60368. * when all assets have been downloaded.
  60369. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  60370. */
  60371. autoHideLoadingUI: boolean;
  60372. /**
  60373. * Creates a new AssetsManager
  60374. * @param scene defines the scene to work on
  60375. */
  60376. constructor(scene: Scene);
  60377. /**
  60378. * Add a MeshAssetTask to the list of active tasks
  60379. * @param taskName defines the name of the new task
  60380. * @param meshesNames defines the name of meshes to load
  60381. * @param rootUrl defines the root url to use to locate files
  60382. * @param sceneFilename defines the filename of the scene file
  60383. * @returns a new MeshAssetTask object
  60384. */
  60385. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  60386. /**
  60387. * Add a TextFileAssetTask to the list of active tasks
  60388. * @param taskName defines the name of the new task
  60389. * @param url defines the url of the file to load
  60390. * @returns a new TextFileAssetTask object
  60391. */
  60392. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  60393. /**
  60394. * Add a BinaryFileAssetTask to the list of active tasks
  60395. * @param taskName defines the name of the new task
  60396. * @param url defines the url of the file to load
  60397. * @returns a new BinaryFileAssetTask object
  60398. */
  60399. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  60400. /**
  60401. * Add a ImageAssetTask to the list of active tasks
  60402. * @param taskName defines the name of the new task
  60403. * @param url defines the url of the file to load
  60404. * @returns a new ImageAssetTask object
  60405. */
  60406. addImageTask(taskName: string, url: string): ImageAssetTask;
  60407. /**
  60408. * Add a TextureAssetTask to the list of active tasks
  60409. * @param taskName defines the name of the new task
  60410. * @param url defines the url of the file to load
  60411. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60412. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  60413. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60414. * @returns a new TextureAssetTask object
  60415. */
  60416. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  60417. /**
  60418. * Add a CubeTextureAssetTask to the list of active tasks
  60419. * @param taskName defines the name of the new task
  60420. * @param url defines the url of the file to load
  60421. * @param extensions defines the extension to use to load the cube map (can be null)
  60422. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60423. * @param files defines the list of files to load (can be null)
  60424. * @returns a new CubeTextureAssetTask object
  60425. */
  60426. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  60427. /**
  60428. *
  60429. * Add a HDRCubeTextureAssetTask to the list of active tasks
  60430. * @param taskName defines the name of the new task
  60431. * @param url defines the url of the file to load
  60432. * @param size defines the size you want for the cubemap (can be null)
  60433. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60434. * @param generateHarmonics defines if you want to automatically generate (true by default)
  60435. * @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)
  60436. * @param reserved Internal use only
  60437. * @returns a new HDRCubeTextureAssetTask object
  60438. */
  60439. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  60440. /**
  60441. *
  60442. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  60443. * @param taskName defines the name of the new task
  60444. * @param url defines the url of the file to load
  60445. * @param size defines the size you want for the cubemap (can be null)
  60446. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60447. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60448. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60449. * @returns a new EquiRectangularCubeTextureAssetTask object
  60450. */
  60451. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  60452. /**
  60453. * Remove a task from the assets manager.
  60454. * @param task the task to remove
  60455. */
  60456. removeTask(task: AbstractAssetTask): void;
  60457. private _decreaseWaitingTasksCount;
  60458. private _runTask;
  60459. /**
  60460. * Reset the AssetsManager and remove all tasks
  60461. * @return the current instance of the AssetsManager
  60462. */
  60463. reset(): AssetsManager;
  60464. /**
  60465. * Start the loading process
  60466. * @return the current instance of the AssetsManager
  60467. */
  60468. load(): AssetsManager;
  60469. /**
  60470. * Start the loading process as an async operation
  60471. * @return a promise returning the list of failed tasks
  60472. */
  60473. loadAsync(): Promise<void>;
  60474. }
  60475. }
  60476. declare module BABYLON {
  60477. /**
  60478. * Wrapper class for promise with external resolve and reject.
  60479. */
  60480. export class Deferred<T> {
  60481. /**
  60482. * The promise associated with this deferred object.
  60483. */
  60484. readonly promise: Promise<T>;
  60485. private _resolve;
  60486. private _reject;
  60487. /**
  60488. * The resolve method of the promise associated with this deferred object.
  60489. */
  60490. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  60491. /**
  60492. * The reject method of the promise associated with this deferred object.
  60493. */
  60494. readonly reject: (reason?: any) => void;
  60495. /**
  60496. * Constructor for this deferred object.
  60497. */
  60498. constructor();
  60499. }
  60500. }
  60501. declare module BABYLON {
  60502. /**
  60503. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  60504. */
  60505. export class MeshExploder {
  60506. private _centerMesh;
  60507. private _meshes;
  60508. private _meshesOrigins;
  60509. private _toCenterVectors;
  60510. private _scaledDirection;
  60511. private _newPosition;
  60512. private _centerPosition;
  60513. /**
  60514. * Explodes meshes from a center mesh.
  60515. * @param meshes The meshes to explode.
  60516. * @param centerMesh The mesh to be center of explosion.
  60517. */
  60518. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  60519. private _setCenterMesh;
  60520. /**
  60521. * Get class name
  60522. * @returns "MeshExploder"
  60523. */
  60524. getClassName(): string;
  60525. /**
  60526. * "Exploded meshes"
  60527. * @returns Array of meshes with the centerMesh at index 0.
  60528. */
  60529. getMeshes(): Array<Mesh>;
  60530. /**
  60531. * Explodes meshes giving a specific direction
  60532. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  60533. */
  60534. explode(direction?: number): void;
  60535. }
  60536. }
  60537. declare module BABYLON {
  60538. /**
  60539. * Class used to help managing file picking and drag'n'drop
  60540. */
  60541. export class FilesInput {
  60542. /**
  60543. * List of files ready to be loaded
  60544. */
  60545. static readonly FilesToLoad: {
  60546. [key: string]: File;
  60547. };
  60548. /**
  60549. * Callback called when a file is processed
  60550. */
  60551. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  60552. private _engine;
  60553. private _currentScene;
  60554. private _sceneLoadedCallback;
  60555. private _progressCallback;
  60556. private _additionalRenderLoopLogicCallback;
  60557. private _textureLoadingCallback;
  60558. private _startingProcessingFilesCallback;
  60559. private _onReloadCallback;
  60560. private _errorCallback;
  60561. private _elementToMonitor;
  60562. private _sceneFileToLoad;
  60563. private _filesToLoad;
  60564. /**
  60565. * Creates a new FilesInput
  60566. * @param engine defines the rendering engine
  60567. * @param scene defines the hosting scene
  60568. * @param sceneLoadedCallback callback called when scene is loaded
  60569. * @param progressCallback callback called to track progress
  60570. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  60571. * @param textureLoadingCallback callback called when a texture is loading
  60572. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  60573. * @param onReloadCallback callback called when a reload is requested
  60574. * @param errorCallback callback call if an error occurs
  60575. */
  60576. 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);
  60577. private _dragEnterHandler;
  60578. private _dragOverHandler;
  60579. private _dropHandler;
  60580. /**
  60581. * Calls this function to listen to drag'n'drop events on a specific DOM element
  60582. * @param elementToMonitor defines the DOM element to track
  60583. */
  60584. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  60585. /**
  60586. * Release all associated resources
  60587. */
  60588. dispose(): void;
  60589. private renderFunction;
  60590. private drag;
  60591. private drop;
  60592. private _traverseFolder;
  60593. private _processFiles;
  60594. /**
  60595. * Load files from a drop event
  60596. * @param event defines the drop event to use as source
  60597. */
  60598. loadFiles(event: any): void;
  60599. private _processReload;
  60600. /**
  60601. * Reload the current scene from the loaded files
  60602. */
  60603. reload(): void;
  60604. }
  60605. }
  60606. declare module BABYLON {
  60607. /**
  60608. * Defines the root class used to create scene optimization to use with SceneOptimizer
  60609. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60610. */
  60611. export class SceneOptimization {
  60612. /**
  60613. * Defines the priority of this optimization (0 by default which means first in the list)
  60614. */
  60615. priority: number;
  60616. /**
  60617. * Gets a string describing the action executed by the current optimization
  60618. * @returns description string
  60619. */
  60620. getDescription(): string;
  60621. /**
  60622. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60623. * @param scene defines the current scene where to apply this optimization
  60624. * @param optimizer defines the current optimizer
  60625. * @returns true if everything that can be done was applied
  60626. */
  60627. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60628. /**
  60629. * Creates the SceneOptimization object
  60630. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60631. * @param desc defines the description associated with the optimization
  60632. */
  60633. constructor(
  60634. /**
  60635. * Defines the priority of this optimization (0 by default which means first in the list)
  60636. */
  60637. priority?: number);
  60638. }
  60639. /**
  60640. * Defines an optimization used to reduce the size of render target textures
  60641. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60642. */
  60643. export class TextureOptimization extends SceneOptimization {
  60644. /**
  60645. * Defines the priority of this optimization (0 by default which means first in the list)
  60646. */
  60647. priority: number;
  60648. /**
  60649. * 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
  60650. */
  60651. maximumSize: number;
  60652. /**
  60653. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  60654. */
  60655. step: number;
  60656. /**
  60657. * Gets a string describing the action executed by the current optimization
  60658. * @returns description string
  60659. */
  60660. getDescription(): string;
  60661. /**
  60662. * Creates the TextureOptimization object
  60663. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60664. * @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
  60665. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  60666. */
  60667. constructor(
  60668. /**
  60669. * Defines the priority of this optimization (0 by default which means first in the list)
  60670. */
  60671. priority?: number,
  60672. /**
  60673. * 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
  60674. */
  60675. maximumSize?: number,
  60676. /**
  60677. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  60678. */
  60679. step?: number);
  60680. /**
  60681. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60682. * @param scene defines the current scene where to apply this optimization
  60683. * @param optimizer defines the current optimizer
  60684. * @returns true if everything that can be done was applied
  60685. */
  60686. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60687. }
  60688. /**
  60689. * Defines an optimization used to increase or decrease the rendering resolution
  60690. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60691. */
  60692. export class HardwareScalingOptimization extends SceneOptimization {
  60693. /**
  60694. * Defines the priority of this optimization (0 by default which means first in the list)
  60695. */
  60696. priority: number;
  60697. /**
  60698. * Defines the maximum scale to use (2 by default)
  60699. */
  60700. maximumScale: number;
  60701. /**
  60702. * Defines the step to use between two passes (0.5 by default)
  60703. */
  60704. step: number;
  60705. private _currentScale;
  60706. private _directionOffset;
  60707. /**
  60708. * Gets a string describing the action executed by the current optimization
  60709. * @return description string
  60710. */
  60711. getDescription(): string;
  60712. /**
  60713. * Creates the HardwareScalingOptimization object
  60714. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60715. * @param maximumScale defines the maximum scale to use (2 by default)
  60716. * @param step defines the step to use between two passes (0.5 by default)
  60717. */
  60718. constructor(
  60719. /**
  60720. * Defines the priority of this optimization (0 by default which means first in the list)
  60721. */
  60722. priority?: number,
  60723. /**
  60724. * Defines the maximum scale to use (2 by default)
  60725. */
  60726. maximumScale?: number,
  60727. /**
  60728. * Defines the step to use between two passes (0.5 by default)
  60729. */
  60730. step?: number);
  60731. /**
  60732. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60733. * @param scene defines the current scene where to apply this optimization
  60734. * @param optimizer defines the current optimizer
  60735. * @returns true if everything that can be done was applied
  60736. */
  60737. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60738. }
  60739. /**
  60740. * Defines an optimization used to remove shadows
  60741. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60742. */
  60743. export class ShadowsOptimization extends SceneOptimization {
  60744. /**
  60745. * Gets a string describing the action executed by the current optimization
  60746. * @return description string
  60747. */
  60748. getDescription(): string;
  60749. /**
  60750. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60751. * @param scene defines the current scene where to apply this optimization
  60752. * @param optimizer defines the current optimizer
  60753. * @returns true if everything that can be done was applied
  60754. */
  60755. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60756. }
  60757. /**
  60758. * Defines an optimization used to turn post-processes off
  60759. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60760. */
  60761. export class PostProcessesOptimization extends SceneOptimization {
  60762. /**
  60763. * Gets a string describing the action executed by the current optimization
  60764. * @return description string
  60765. */
  60766. getDescription(): string;
  60767. /**
  60768. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60769. * @param scene defines the current scene where to apply this optimization
  60770. * @param optimizer defines the current optimizer
  60771. * @returns true if everything that can be done was applied
  60772. */
  60773. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60774. }
  60775. /**
  60776. * Defines an optimization used to turn lens flares off
  60777. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60778. */
  60779. export class LensFlaresOptimization extends SceneOptimization {
  60780. /**
  60781. * Gets a string describing the action executed by the current optimization
  60782. * @return description string
  60783. */
  60784. getDescription(): string;
  60785. /**
  60786. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60787. * @param scene defines the current scene where to apply this optimization
  60788. * @param optimizer defines the current optimizer
  60789. * @returns true if everything that can be done was applied
  60790. */
  60791. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60792. }
  60793. /**
  60794. * Defines an optimization based on user defined callback.
  60795. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60796. */
  60797. export class CustomOptimization extends SceneOptimization {
  60798. /**
  60799. * Callback called to apply the custom optimization.
  60800. */
  60801. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  60802. /**
  60803. * Callback called to get custom description
  60804. */
  60805. onGetDescription: () => string;
  60806. /**
  60807. * Gets a string describing the action executed by the current optimization
  60808. * @returns description string
  60809. */
  60810. getDescription(): string;
  60811. /**
  60812. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60813. * @param scene defines the current scene where to apply this optimization
  60814. * @param optimizer defines the current optimizer
  60815. * @returns true if everything that can be done was applied
  60816. */
  60817. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60818. }
  60819. /**
  60820. * Defines an optimization used to turn particles off
  60821. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60822. */
  60823. export class ParticlesOptimization extends SceneOptimization {
  60824. /**
  60825. * Gets a string describing the action executed by the current optimization
  60826. * @return description string
  60827. */
  60828. getDescription(): string;
  60829. /**
  60830. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60831. * @param scene defines the current scene where to apply this optimization
  60832. * @param optimizer defines the current optimizer
  60833. * @returns true if everything that can be done was applied
  60834. */
  60835. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60836. }
  60837. /**
  60838. * Defines an optimization used to turn render targets off
  60839. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60840. */
  60841. export class RenderTargetsOptimization extends SceneOptimization {
  60842. /**
  60843. * Gets a string describing the action executed by the current optimization
  60844. * @return description string
  60845. */
  60846. getDescription(): string;
  60847. /**
  60848. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60849. * @param scene defines the current scene where to apply this optimization
  60850. * @param optimizer defines the current optimizer
  60851. * @returns true if everything that can be done was applied
  60852. */
  60853. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60854. }
  60855. /**
  60856. * Defines an optimization used to merge meshes with compatible materials
  60857. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60858. */
  60859. export class MergeMeshesOptimization extends SceneOptimization {
  60860. private static _UpdateSelectionTree;
  60861. /**
  60862. * Gets or sets a boolean which defines if optimization octree has to be updated
  60863. */
  60864. /**
  60865. * Gets or sets a boolean which defines if optimization octree has to be updated
  60866. */
  60867. static UpdateSelectionTree: boolean;
  60868. /**
  60869. * Gets a string describing the action executed by the current optimization
  60870. * @return description string
  60871. */
  60872. getDescription(): string;
  60873. private _canBeMerged;
  60874. /**
  60875. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60876. * @param scene defines the current scene where to apply this optimization
  60877. * @param optimizer defines the current optimizer
  60878. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  60879. * @returns true if everything that can be done was applied
  60880. */
  60881. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  60882. }
  60883. /**
  60884. * Defines a list of options used by SceneOptimizer
  60885. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60886. */
  60887. export class SceneOptimizerOptions {
  60888. /**
  60889. * Defines the target frame rate to reach (60 by default)
  60890. */
  60891. targetFrameRate: number;
  60892. /**
  60893. * Defines the interval between two checkes (2000ms by default)
  60894. */
  60895. trackerDuration: number;
  60896. /**
  60897. * Gets the list of optimizations to apply
  60898. */
  60899. optimizations: SceneOptimization[];
  60900. /**
  60901. * Creates a new list of options used by SceneOptimizer
  60902. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  60903. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  60904. */
  60905. constructor(
  60906. /**
  60907. * Defines the target frame rate to reach (60 by default)
  60908. */
  60909. targetFrameRate?: number,
  60910. /**
  60911. * Defines the interval between two checkes (2000ms by default)
  60912. */
  60913. trackerDuration?: number);
  60914. /**
  60915. * Add a new optimization
  60916. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  60917. * @returns the current SceneOptimizerOptions
  60918. */
  60919. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  60920. /**
  60921. * Add a new custom optimization
  60922. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  60923. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  60924. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60925. * @returns the current SceneOptimizerOptions
  60926. */
  60927. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  60928. /**
  60929. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  60930. * @param targetFrameRate defines the target frame rate (60 by default)
  60931. * @returns a SceneOptimizerOptions object
  60932. */
  60933. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  60934. /**
  60935. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  60936. * @param targetFrameRate defines the target frame rate (60 by default)
  60937. * @returns a SceneOptimizerOptions object
  60938. */
  60939. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  60940. /**
  60941. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  60942. * @param targetFrameRate defines the target frame rate (60 by default)
  60943. * @returns a SceneOptimizerOptions object
  60944. */
  60945. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  60946. }
  60947. /**
  60948. * Class used to run optimizations in order to reach a target frame rate
  60949. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60950. */
  60951. export class SceneOptimizer implements IDisposable {
  60952. private _isRunning;
  60953. private _options;
  60954. private _scene;
  60955. private _currentPriorityLevel;
  60956. private _targetFrameRate;
  60957. private _trackerDuration;
  60958. private _currentFrameRate;
  60959. private _sceneDisposeObserver;
  60960. private _improvementMode;
  60961. /**
  60962. * Defines an observable called when the optimizer reaches the target frame rate
  60963. */
  60964. onSuccessObservable: Observable<SceneOptimizer>;
  60965. /**
  60966. * Defines an observable called when the optimizer enables an optimization
  60967. */
  60968. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  60969. /**
  60970. * Defines an observable called when the optimizer is not able to reach the target frame rate
  60971. */
  60972. onFailureObservable: Observable<SceneOptimizer>;
  60973. /**
  60974. * Gets a boolean indicating if the optimizer is in improvement mode
  60975. */
  60976. readonly isInImprovementMode: boolean;
  60977. /**
  60978. * Gets the current priority level (0 at start)
  60979. */
  60980. readonly currentPriorityLevel: number;
  60981. /**
  60982. * Gets the current frame rate checked by the SceneOptimizer
  60983. */
  60984. readonly currentFrameRate: number;
  60985. /**
  60986. * Gets or sets the current target frame rate (60 by default)
  60987. */
  60988. /**
  60989. * Gets or sets the current target frame rate (60 by default)
  60990. */
  60991. targetFrameRate: number;
  60992. /**
  60993. * Gets or sets the current interval between two checks (every 2000ms by default)
  60994. */
  60995. /**
  60996. * Gets or sets the current interval between two checks (every 2000ms by default)
  60997. */
  60998. trackerDuration: number;
  60999. /**
  61000. * Gets the list of active optimizations
  61001. */
  61002. readonly optimizations: SceneOptimization[];
  61003. /**
  61004. * Creates a new SceneOptimizer
  61005. * @param scene defines the scene to work on
  61006. * @param options defines the options to use with the SceneOptimizer
  61007. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  61008. * @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)
  61009. */
  61010. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  61011. /**
  61012. * Stops the current optimizer
  61013. */
  61014. stop(): void;
  61015. /**
  61016. * Reset the optimizer to initial step (current priority level = 0)
  61017. */
  61018. reset(): void;
  61019. /**
  61020. * Start the optimizer. By default it will try to reach a specific framerate
  61021. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  61022. */
  61023. start(): void;
  61024. private _checkCurrentState;
  61025. /**
  61026. * Release all resources
  61027. */
  61028. dispose(): void;
  61029. /**
  61030. * Helper function to create a SceneOptimizer with one single line of code
  61031. * @param scene defines the scene to work on
  61032. * @param options defines the options to use with the SceneOptimizer
  61033. * @param onSuccess defines a callback to call on success
  61034. * @param onFailure defines a callback to call on failure
  61035. * @returns the new SceneOptimizer object
  61036. */
  61037. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  61038. }
  61039. }
  61040. declare module BABYLON {
  61041. /**
  61042. * Class used to serialize a scene into a string
  61043. */
  61044. export class SceneSerializer {
  61045. /**
  61046. * Clear cache used by a previous serialization
  61047. */
  61048. static ClearCache(): void;
  61049. /**
  61050. * Serialize a scene into a JSON compatible object
  61051. * @param scene defines the scene to serialize
  61052. * @returns a JSON compatible object
  61053. */
  61054. static Serialize(scene: Scene): any;
  61055. /**
  61056. * Serialize a mesh into a JSON compatible object
  61057. * @param toSerialize defines the mesh to serialize
  61058. * @param withParents defines if parents must be serialized as well
  61059. * @param withChildren defines if children must be serialized as well
  61060. * @returns a JSON compatible object
  61061. */
  61062. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  61063. }
  61064. }
  61065. declare module BABYLON {
  61066. /**
  61067. * Class used to host texture specific utilities
  61068. */
  61069. export class TextureTools {
  61070. /**
  61071. * Uses the GPU to create a copy texture rescaled at a given size
  61072. * @param texture Texture to copy from
  61073. * @param width defines the desired width
  61074. * @param height defines the desired height
  61075. * @param useBilinearMode defines if bilinear mode has to be used
  61076. * @return the generated texture
  61077. */
  61078. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  61079. }
  61080. }
  61081. declare module BABYLON {
  61082. /**
  61083. * This represents the different options available for the video capture.
  61084. */
  61085. export interface VideoRecorderOptions {
  61086. /** Defines the mime type of the video. */
  61087. mimeType: string;
  61088. /** Defines the FPS the video should be recorded at. */
  61089. fps: number;
  61090. /** Defines the chunk size for the recording data. */
  61091. recordChunckSize: number;
  61092. /** The audio tracks to attach to the recording. */
  61093. audioTracks?: MediaStreamTrack[];
  61094. }
  61095. /**
  61096. * This can help with recording videos from BabylonJS.
  61097. * This is based on the available WebRTC functionalities of the browser.
  61098. *
  61099. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  61100. */
  61101. export class VideoRecorder {
  61102. private static readonly _defaultOptions;
  61103. /**
  61104. * Returns whether or not the VideoRecorder is available in your browser.
  61105. * @param engine Defines the Babylon Engine.
  61106. * @returns true if supported otherwise false.
  61107. */
  61108. static IsSupported(engine: Engine): boolean;
  61109. private readonly _options;
  61110. private _canvas;
  61111. private _mediaRecorder;
  61112. private _recordedChunks;
  61113. private _fileName;
  61114. private _resolve;
  61115. private _reject;
  61116. /**
  61117. * True when a recording is already in progress.
  61118. */
  61119. readonly isRecording: boolean;
  61120. /**
  61121. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  61122. * @param engine Defines the BabylonJS Engine you wish to record.
  61123. * @param options Defines options that can be used to customize the capture.
  61124. */
  61125. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  61126. /**
  61127. * Stops the current recording before the default capture timeout passed in the startRecording function.
  61128. */
  61129. stopRecording(): void;
  61130. /**
  61131. * Starts recording the canvas for a max duration specified in parameters.
  61132. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  61133. * If null no automatic download will start and you can rely on the promise to get the data back.
  61134. * @param maxDuration Defines the maximum recording time in seconds.
  61135. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  61136. * @return A promise callback at the end of the recording with the video data in Blob.
  61137. */
  61138. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  61139. /**
  61140. * Releases internal resources used during the recording.
  61141. */
  61142. dispose(): void;
  61143. private _handleDataAvailable;
  61144. private _handleError;
  61145. private _handleStop;
  61146. }
  61147. }
  61148. declare module BABYLON {
  61149. /**
  61150. * Class containing a set of static utilities functions for screenshots
  61151. */
  61152. export class ScreenshotTools {
  61153. /**
  61154. * Captures a screenshot of the current rendering
  61155. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61156. * @param engine defines the rendering engine
  61157. * @param camera defines the source camera
  61158. * @param size This parameter can be set to a single number or to an object with the
  61159. * following (optional) properties: precision, width, height. If a single number is passed,
  61160. * it will be used for both width and height. If an object is passed, the screenshot size
  61161. * will be derived from the parameters. The precision property is a multiplier allowing
  61162. * rendering at a higher or lower resolution
  61163. * @param successCallback defines the callback receives a single parameter which contains the
  61164. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61165. * src parameter of an <img> to display it
  61166. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61167. * Check your browser for supported MIME types
  61168. */
  61169. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  61170. /**
  61171. * Captures a screenshot of the current rendering
  61172. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61173. * @param engine defines the rendering engine
  61174. * @param camera defines the source camera
  61175. * @param size This parameter can be set to a single number or to an object with the
  61176. * following (optional) properties: precision, width, height. If a single number is passed,
  61177. * it will be used for both width and height. If an object is passed, the screenshot size
  61178. * will be derived from the parameters. The precision property is a multiplier allowing
  61179. * rendering at a higher or lower resolution
  61180. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61181. * Check your browser for supported MIME types
  61182. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  61183. * to the src parameter of an <img> to display it
  61184. */
  61185. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  61186. /**
  61187. * Generates an image screenshot from the specified camera.
  61188. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61189. * @param engine The engine to use for rendering
  61190. * @param camera The camera to use for rendering
  61191. * @param size This parameter can be set to a single number or to an object with the
  61192. * following (optional) properties: precision, width, height. If a single number is passed,
  61193. * it will be used for both width and height. If an object is passed, the screenshot size
  61194. * will be derived from the parameters. The precision property is a multiplier allowing
  61195. * rendering at a higher or lower resolution
  61196. * @param successCallback The callback receives a single parameter which contains the
  61197. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61198. * src parameter of an <img> to display it
  61199. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61200. * Check your browser for supported MIME types
  61201. * @param samples Texture samples (default: 1)
  61202. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61203. * @param fileName A name for for the downloaded file.
  61204. */
  61205. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  61206. /**
  61207. * Generates an image screenshot from the specified camera.
  61208. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61209. * @param engine The engine to use for rendering
  61210. * @param camera The camera to use for rendering
  61211. * @param size This parameter can be set to a single number or to an object with the
  61212. * following (optional) properties: precision, width, height. If a single number is passed,
  61213. * it will be used for both width and height. If an object is passed, the screenshot size
  61214. * will be derived from the parameters. The precision property is a multiplier allowing
  61215. * rendering at a higher or lower resolution
  61216. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61217. * Check your browser for supported MIME types
  61218. * @param samples Texture samples (default: 1)
  61219. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61220. * @param fileName A name for for the downloaded file.
  61221. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  61222. * to the src parameter of an <img> to display it
  61223. */
  61224. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  61225. /**
  61226. * Gets height and width for screenshot size
  61227. * @private
  61228. */
  61229. private static _getScreenshotSize;
  61230. }
  61231. }
  61232. declare module BABYLON {
  61233. /**
  61234. * A cursor which tracks a point on a path
  61235. */
  61236. export class PathCursor {
  61237. private path;
  61238. /**
  61239. * Stores path cursor callbacks for when an onchange event is triggered
  61240. */
  61241. private _onchange;
  61242. /**
  61243. * The value of the path cursor
  61244. */
  61245. value: number;
  61246. /**
  61247. * The animation array of the path cursor
  61248. */
  61249. animations: Animation[];
  61250. /**
  61251. * Initializes the path cursor
  61252. * @param path The path to track
  61253. */
  61254. constructor(path: Path2);
  61255. /**
  61256. * Gets the cursor point on the path
  61257. * @returns A point on the path cursor at the cursor location
  61258. */
  61259. getPoint(): Vector3;
  61260. /**
  61261. * Moves the cursor ahead by the step amount
  61262. * @param step The amount to move the cursor forward
  61263. * @returns This path cursor
  61264. */
  61265. moveAhead(step?: number): PathCursor;
  61266. /**
  61267. * Moves the cursor behind by the step amount
  61268. * @param step The amount to move the cursor back
  61269. * @returns This path cursor
  61270. */
  61271. moveBack(step?: number): PathCursor;
  61272. /**
  61273. * Moves the cursor by the step amount
  61274. * If the step amount is greater than one, an exception is thrown
  61275. * @param step The amount to move the cursor
  61276. * @returns This path cursor
  61277. */
  61278. move(step: number): PathCursor;
  61279. /**
  61280. * Ensures that the value is limited between zero and one
  61281. * @returns This path cursor
  61282. */
  61283. private ensureLimits;
  61284. /**
  61285. * Runs onchange callbacks on change (used by the animation engine)
  61286. * @returns This path cursor
  61287. */
  61288. private raiseOnChange;
  61289. /**
  61290. * Executes a function on change
  61291. * @param f A path cursor onchange callback
  61292. * @returns This path cursor
  61293. */
  61294. onchange(f: (cursor: PathCursor) => void): PathCursor;
  61295. }
  61296. }
  61297. declare module BABYLON {
  61298. /** @hidden */
  61299. export var blurPixelShader: {
  61300. name: string;
  61301. shader: string;
  61302. };
  61303. }
  61304. declare module BABYLON {
  61305. /** @hidden */
  61306. export var pointCloudVertexDeclaration: {
  61307. name: string;
  61308. shader: string;
  61309. };
  61310. }
  61311. // Mixins
  61312. interface Window {
  61313. mozIndexedDB: IDBFactory;
  61314. webkitIndexedDB: IDBFactory;
  61315. msIndexedDB: IDBFactory;
  61316. webkitURL: typeof URL;
  61317. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  61318. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  61319. WebGLRenderingContext: WebGLRenderingContext;
  61320. MSGesture: MSGesture;
  61321. CANNON: any;
  61322. AudioContext: AudioContext;
  61323. webkitAudioContext: AudioContext;
  61324. PointerEvent: any;
  61325. Math: Math;
  61326. Uint8Array: Uint8ArrayConstructor;
  61327. Float32Array: Float32ArrayConstructor;
  61328. mozURL: typeof URL;
  61329. msURL: typeof URL;
  61330. VRFrameData: any; // WebVR, from specs 1.1
  61331. DracoDecoderModule: any;
  61332. setImmediate(handler: (...args: any[]) => void): number;
  61333. }
  61334. interface HTMLCanvasElement {
  61335. requestPointerLock(): void;
  61336. msRequestPointerLock?(): void;
  61337. mozRequestPointerLock?(): void;
  61338. webkitRequestPointerLock?(): void;
  61339. /** Track wether a record is in progress */
  61340. isRecording: boolean;
  61341. /** Capture Stream method defined by some browsers */
  61342. captureStream(fps?: number): MediaStream;
  61343. }
  61344. interface CanvasRenderingContext2D {
  61345. msImageSmoothingEnabled: boolean;
  61346. }
  61347. interface MouseEvent {
  61348. mozMovementX: number;
  61349. mozMovementY: number;
  61350. webkitMovementX: number;
  61351. webkitMovementY: number;
  61352. msMovementX: number;
  61353. msMovementY: number;
  61354. }
  61355. interface Navigator {
  61356. mozGetVRDevices: (any: any) => any;
  61357. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61358. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61359. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61360. webkitGetGamepads(): Gamepad[];
  61361. msGetGamepads(): Gamepad[];
  61362. webkitGamepads(): Gamepad[];
  61363. }
  61364. interface HTMLVideoElement {
  61365. mozSrcObject: any;
  61366. }
  61367. interface Math {
  61368. fround(x: number): number;
  61369. imul(a: number, b: number): number;
  61370. }
  61371. interface WebGLRenderingContext {
  61372. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  61373. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  61374. vertexAttribDivisor(index: number, divisor: number): void;
  61375. createVertexArray(): any;
  61376. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  61377. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  61378. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  61379. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  61380. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  61381. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  61382. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  61383. // Queries
  61384. createQuery(): WebGLQuery;
  61385. deleteQuery(query: WebGLQuery): void;
  61386. beginQuery(target: number, query: WebGLQuery): void;
  61387. endQuery(target: number): void;
  61388. getQueryParameter(query: WebGLQuery, pname: number): any;
  61389. getQuery(target: number, pname: number): any;
  61390. MAX_SAMPLES: number;
  61391. RGBA8: number;
  61392. READ_FRAMEBUFFER: number;
  61393. DRAW_FRAMEBUFFER: number;
  61394. UNIFORM_BUFFER: number;
  61395. HALF_FLOAT_OES: number;
  61396. RGBA16F: number;
  61397. RGBA32F: number;
  61398. R32F: number;
  61399. RG32F: number;
  61400. RGB32F: number;
  61401. R16F: number;
  61402. RG16F: number;
  61403. RGB16F: number;
  61404. RED: number;
  61405. RG: number;
  61406. R8: number;
  61407. RG8: number;
  61408. UNSIGNED_INT_24_8: number;
  61409. DEPTH24_STENCIL8: number;
  61410. /* Multiple Render Targets */
  61411. drawBuffers(buffers: number[]): void;
  61412. readBuffer(src: number): void;
  61413. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  61414. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  61415. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  61416. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  61417. // Occlusion Query
  61418. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  61419. ANY_SAMPLES_PASSED: number;
  61420. QUERY_RESULT_AVAILABLE: number;
  61421. QUERY_RESULT: number;
  61422. }
  61423. interface WebGLProgram {
  61424. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  61425. }
  61426. interface EXT_disjoint_timer_query {
  61427. QUERY_COUNTER_BITS_EXT: number;
  61428. TIME_ELAPSED_EXT: number;
  61429. TIMESTAMP_EXT: number;
  61430. GPU_DISJOINT_EXT: number;
  61431. QUERY_RESULT_EXT: number;
  61432. QUERY_RESULT_AVAILABLE_EXT: number;
  61433. queryCounterEXT(query: WebGLQuery, target: number): void;
  61434. createQueryEXT(): WebGLQuery;
  61435. beginQueryEXT(target: number, query: WebGLQuery): void;
  61436. endQueryEXT(target: number): void;
  61437. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  61438. deleteQueryEXT(query: WebGLQuery): void;
  61439. }
  61440. interface WebGLUniformLocation {
  61441. _currentState: any;
  61442. }
  61443. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  61444. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  61445. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  61446. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  61447. interface WebGLRenderingContext {
  61448. readonly RASTERIZER_DISCARD: number;
  61449. readonly DEPTH_COMPONENT24: number;
  61450. readonly TEXTURE_3D: number;
  61451. readonly TEXTURE_2D_ARRAY: number;
  61452. readonly TEXTURE_COMPARE_FUNC: number;
  61453. readonly TEXTURE_COMPARE_MODE: number;
  61454. readonly COMPARE_REF_TO_TEXTURE: number;
  61455. readonly TEXTURE_WRAP_R: number;
  61456. readonly HALF_FLOAT: number;
  61457. readonly RGB8: number;
  61458. readonly RED_INTEGER: number;
  61459. readonly RG_INTEGER: number;
  61460. readonly RGB_INTEGER: number;
  61461. readonly RGBA_INTEGER: number;
  61462. readonly R8_SNORM: number;
  61463. readonly RG8_SNORM: number;
  61464. readonly RGB8_SNORM: number;
  61465. readonly RGBA8_SNORM: number;
  61466. readonly R8I: number;
  61467. readonly RG8I: number;
  61468. readonly RGB8I: number;
  61469. readonly RGBA8I: number;
  61470. readonly R8UI: number;
  61471. readonly RG8UI: number;
  61472. readonly RGB8UI: number;
  61473. readonly RGBA8UI: number;
  61474. readonly R16I: number;
  61475. readonly RG16I: number;
  61476. readonly RGB16I: number;
  61477. readonly RGBA16I: number;
  61478. readonly R16UI: number;
  61479. readonly RG16UI: number;
  61480. readonly RGB16UI: number;
  61481. readonly RGBA16UI: number;
  61482. readonly R32I: number;
  61483. readonly RG32I: number;
  61484. readonly RGB32I: number;
  61485. readonly RGBA32I: number;
  61486. readonly R32UI: number;
  61487. readonly RG32UI: number;
  61488. readonly RGB32UI: number;
  61489. readonly RGBA32UI: number;
  61490. readonly RGB10_A2UI: number;
  61491. readonly R11F_G11F_B10F: number;
  61492. readonly RGB9_E5: number;
  61493. readonly RGB10_A2: number;
  61494. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  61495. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  61496. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  61497. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  61498. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  61499. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  61500. 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;
  61501. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  61502. readonly TRANSFORM_FEEDBACK: number;
  61503. readonly INTERLEAVED_ATTRIBS: number;
  61504. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  61505. createTransformFeedback(): WebGLTransformFeedback;
  61506. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  61507. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  61508. beginTransformFeedback(primitiveMode: number): void;
  61509. endTransformFeedback(): void;
  61510. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  61511. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61512. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61513. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61514. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  61515. }
  61516. interface ImageBitmap {
  61517. readonly width: number;
  61518. readonly height: number;
  61519. close(): void;
  61520. }
  61521. interface WebGLQuery extends WebGLObject {
  61522. }
  61523. declare var WebGLQuery: {
  61524. prototype: WebGLQuery;
  61525. new(): WebGLQuery;
  61526. };
  61527. interface WebGLSampler extends WebGLObject {
  61528. }
  61529. declare var WebGLSampler: {
  61530. prototype: WebGLSampler;
  61531. new(): WebGLSampler;
  61532. };
  61533. interface WebGLSync extends WebGLObject {
  61534. }
  61535. declare var WebGLSync: {
  61536. prototype: WebGLSync;
  61537. new(): WebGLSync;
  61538. };
  61539. interface WebGLTransformFeedback extends WebGLObject {
  61540. }
  61541. declare var WebGLTransformFeedback: {
  61542. prototype: WebGLTransformFeedback;
  61543. new(): WebGLTransformFeedback;
  61544. };
  61545. interface WebGLVertexArrayObject extends WebGLObject {
  61546. }
  61547. declare var WebGLVertexArrayObject: {
  61548. prototype: WebGLVertexArrayObject;
  61549. new(): WebGLVertexArrayObject;
  61550. };
  61551. // Type definitions for WebVR API
  61552. // Project: https://w3c.github.io/webvr/
  61553. // Definitions by: six a <https://github.com/lostfictions>
  61554. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  61555. interface VRDisplay extends EventTarget {
  61556. /**
  61557. * Dictionary of capabilities describing the VRDisplay.
  61558. */
  61559. readonly capabilities: VRDisplayCapabilities;
  61560. /**
  61561. * z-depth defining the far plane of the eye view frustum
  61562. * enables mapping of values in the render target depth
  61563. * attachment to scene coordinates. Initially set to 10000.0.
  61564. */
  61565. depthFar: number;
  61566. /**
  61567. * z-depth defining the near plane of the eye view frustum
  61568. * enables mapping of values in the render target depth
  61569. * attachment to scene coordinates. Initially set to 0.01.
  61570. */
  61571. depthNear: number;
  61572. /**
  61573. * An identifier for this distinct VRDisplay. Used as an
  61574. * association point in the Gamepad API.
  61575. */
  61576. readonly displayId: number;
  61577. /**
  61578. * A display name, a user-readable name identifying it.
  61579. */
  61580. readonly displayName: string;
  61581. readonly isConnected: boolean;
  61582. readonly isPresenting: boolean;
  61583. /**
  61584. * If this VRDisplay supports room-scale experiences, the optional
  61585. * stage attribute contains details on the room-scale parameters.
  61586. */
  61587. readonly stageParameters: VRStageParameters | null;
  61588. /**
  61589. * Passing the value returned by `requestAnimationFrame` to
  61590. * `cancelAnimationFrame` will unregister the callback.
  61591. * @param handle Define the hanle of the request to cancel
  61592. */
  61593. cancelAnimationFrame(handle: number): void;
  61594. /**
  61595. * Stops presenting to the VRDisplay.
  61596. * @returns a promise to know when it stopped
  61597. */
  61598. exitPresent(): Promise<void>;
  61599. /**
  61600. * Return the current VREyeParameters for the given eye.
  61601. * @param whichEye Define the eye we want the parameter for
  61602. * @returns the eye parameters
  61603. */
  61604. getEyeParameters(whichEye: string): VREyeParameters;
  61605. /**
  61606. * Populates the passed VRFrameData with the information required to render
  61607. * the current frame.
  61608. * @param frameData Define the data structure to populate
  61609. * @returns true if ok otherwise false
  61610. */
  61611. getFrameData(frameData: VRFrameData): boolean;
  61612. /**
  61613. * Get the layers currently being presented.
  61614. * @returns the list of VR layers
  61615. */
  61616. getLayers(): VRLayer[];
  61617. /**
  61618. * Return a VRPose containing the future predicted pose of the VRDisplay
  61619. * when the current frame will be presented. The value returned will not
  61620. * change until JavaScript has returned control to the browser.
  61621. *
  61622. * The VRPose will contain the position, orientation, velocity,
  61623. * and acceleration of each of these properties.
  61624. * @returns the pose object
  61625. */
  61626. getPose(): VRPose;
  61627. /**
  61628. * Return the current instantaneous pose of the VRDisplay, with no
  61629. * prediction applied.
  61630. * @returns the current instantaneous pose
  61631. */
  61632. getImmediatePose(): VRPose;
  61633. /**
  61634. * The callback passed to `requestAnimationFrame` will be called
  61635. * any time a new frame should be rendered. When the VRDisplay is
  61636. * presenting the callback will be called at the native refresh
  61637. * rate of the HMD. When not presenting this function acts
  61638. * identically to how window.requestAnimationFrame acts. Content should
  61639. * make no assumptions of frame rate or vsync behavior as the HMD runs
  61640. * asynchronously from other displays and at differing refresh rates.
  61641. * @param callback Define the eaction to run next frame
  61642. * @returns the request handle it
  61643. */
  61644. requestAnimationFrame(callback: FrameRequestCallback): number;
  61645. /**
  61646. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  61647. * Repeat calls while already presenting will update the VRLayers being displayed.
  61648. * @param layers Define the list of layer to present
  61649. * @returns a promise to know when the request has been fulfilled
  61650. */
  61651. requestPresent(layers: VRLayer[]): Promise<void>;
  61652. /**
  61653. * Reset the pose for this display, treating its current position and
  61654. * orientation as the "origin/zero" values. VRPose.position,
  61655. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  61656. * updated when calling resetPose(). This should be called in only
  61657. * sitting-space experiences.
  61658. */
  61659. resetPose(): void;
  61660. /**
  61661. * The VRLayer provided to the VRDisplay will be captured and presented
  61662. * in the HMD. Calling this function has the same effect on the source
  61663. * canvas as any other operation that uses its source image, and canvases
  61664. * created without preserveDrawingBuffer set to true will be cleared.
  61665. * @param pose Define the pose to submit
  61666. */
  61667. submitFrame(pose?: VRPose): void;
  61668. }
  61669. declare var VRDisplay: {
  61670. prototype: VRDisplay;
  61671. new(): VRDisplay;
  61672. };
  61673. interface VRLayer {
  61674. leftBounds?: number[] | Float32Array | null;
  61675. rightBounds?: number[] | Float32Array | null;
  61676. source?: HTMLCanvasElement | null;
  61677. }
  61678. interface VRDisplayCapabilities {
  61679. readonly canPresent: boolean;
  61680. readonly hasExternalDisplay: boolean;
  61681. readonly hasOrientation: boolean;
  61682. readonly hasPosition: boolean;
  61683. readonly maxLayers: number;
  61684. }
  61685. interface VREyeParameters {
  61686. /** @deprecated */
  61687. readonly fieldOfView: VRFieldOfView;
  61688. readonly offset: Float32Array;
  61689. readonly renderHeight: number;
  61690. readonly renderWidth: number;
  61691. }
  61692. interface VRFieldOfView {
  61693. readonly downDegrees: number;
  61694. readonly leftDegrees: number;
  61695. readonly rightDegrees: number;
  61696. readonly upDegrees: number;
  61697. }
  61698. interface VRFrameData {
  61699. readonly leftProjectionMatrix: Float32Array;
  61700. readonly leftViewMatrix: Float32Array;
  61701. readonly pose: VRPose;
  61702. readonly rightProjectionMatrix: Float32Array;
  61703. readonly rightViewMatrix: Float32Array;
  61704. readonly timestamp: number;
  61705. }
  61706. interface VRPose {
  61707. readonly angularAcceleration: Float32Array | null;
  61708. readonly angularVelocity: Float32Array | null;
  61709. readonly linearAcceleration: Float32Array | null;
  61710. readonly linearVelocity: Float32Array | null;
  61711. readonly orientation: Float32Array | null;
  61712. readonly position: Float32Array | null;
  61713. readonly timestamp: number;
  61714. }
  61715. interface VRStageParameters {
  61716. sittingToStandingTransform?: Float32Array;
  61717. sizeX?: number;
  61718. sizeY?: number;
  61719. }
  61720. interface Navigator {
  61721. getVRDisplays(): Promise<VRDisplay[]>;
  61722. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  61723. }
  61724. interface Window {
  61725. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  61726. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  61727. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  61728. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  61729. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  61730. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  61731. }
  61732. interface Gamepad {
  61733. readonly displayId: number;
  61734. }
  61735. type XRSessionMode =
  61736. | "inline"
  61737. | "immersive-vr"
  61738. | "immersive-ar";
  61739. type XRReferenceSpaceType =
  61740. | "viewer"
  61741. | "local"
  61742. | "local-floor"
  61743. | "bounded-floor"
  61744. | "unbounded";
  61745. type XREnvironmentBlendMode =
  61746. | "opaque"
  61747. | "additive"
  61748. | "alpha-blend";
  61749. type XRVisibilityState =
  61750. | "visible"
  61751. | "visible-blurred"
  61752. | "hidden";
  61753. type XRHandedness =
  61754. | "none"
  61755. | "left"
  61756. | "right";
  61757. type XRTargetRayMode =
  61758. | "gaze"
  61759. | "tracked-pointer"
  61760. | "screen";
  61761. type XREye =
  61762. | "none"
  61763. | "left"
  61764. | "right";
  61765. interface XRSpace extends EventTarget {
  61766. }
  61767. interface XRRenderState {
  61768. depthNear?: number;
  61769. depthFar?: number;
  61770. inlineVerticalFieldOfView?: number;
  61771. baseLayer?: XRWebGLLayer;
  61772. }
  61773. interface XRInputSource {
  61774. handedness: XRHandedness;
  61775. targetRayMode: XRTargetRayMode;
  61776. targetRaySpace: XRSpace;
  61777. gripSpace: XRSpace | undefined;
  61778. gamepad: Gamepad | undefined;
  61779. profiles: Array<string>;
  61780. }
  61781. interface XRSession {
  61782. addEventListener: Function;
  61783. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  61784. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  61785. requestAnimationFrame: Function;
  61786. end(): Promise<void>;
  61787. renderState: XRRenderState;
  61788. inputSources: Array<XRInputSource>;
  61789. }
  61790. interface XRReferenceSpace extends XRSpace {
  61791. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  61792. onreset: any;
  61793. }
  61794. interface XRFrame {
  61795. session: XRSession;
  61796. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  61797. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  61798. }
  61799. interface XRViewerPose extends XRPose {
  61800. views: Array<XRView>;
  61801. }
  61802. interface XRPose {
  61803. transform: XRRigidTransform;
  61804. emulatedPosition: boolean;
  61805. }
  61806. declare var XRWebGLLayer: {
  61807. prototype: XRWebGLLayer;
  61808. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  61809. };
  61810. interface XRWebGLLayer {
  61811. framebuffer: WebGLFramebuffer;
  61812. framebufferWidth: number;
  61813. framebufferHeight: number;
  61814. getViewport: Function;
  61815. }
  61816. interface XRRigidTransform {
  61817. position: DOMPointReadOnly;
  61818. orientation: DOMPointReadOnly;
  61819. matrix: Float32Array;
  61820. inverse: XRRigidTransform;
  61821. }
  61822. interface XRView {
  61823. eye: XREye;
  61824. projectionMatrix: Float32Array;
  61825. transform: XRRigidTransform;
  61826. }
  61827. interface XRInputSourceChangeEvent {
  61828. session: XRSession;
  61829. removed: Array<XRInputSource>;
  61830. added: Array<XRInputSource>;
  61831. }
  61832. declare module BABYLON.GUI {
  61833. /**
  61834. * Class used to specific a value and its associated unit
  61835. */
  61836. export class ValueAndUnit {
  61837. /** defines the unit to store */
  61838. unit: number;
  61839. /** defines a boolean indicating if the value can be negative */
  61840. negativeValueAllowed: boolean;
  61841. private _value;
  61842. private _originalUnit;
  61843. /**
  61844. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  61845. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61846. */
  61847. ignoreAdaptiveScaling: boolean;
  61848. /**
  61849. * Creates a new ValueAndUnit
  61850. * @param value defines the value to store
  61851. * @param unit defines the unit to store
  61852. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  61853. */
  61854. constructor(value: number,
  61855. /** defines the unit to store */
  61856. unit?: number,
  61857. /** defines a boolean indicating if the value can be negative */
  61858. negativeValueAllowed?: boolean);
  61859. /** Gets a boolean indicating if the value is a percentage */
  61860. readonly isPercentage: boolean;
  61861. /** Gets a boolean indicating if the value is store as pixel */
  61862. readonly isPixel: boolean;
  61863. /** Gets direct internal value */
  61864. readonly internalValue: number;
  61865. /**
  61866. * Gets value as pixel
  61867. * @param host defines the root host
  61868. * @param refValue defines the reference value for percentages
  61869. * @returns the value as pixel
  61870. */
  61871. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  61872. /**
  61873. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  61874. * @param value defines the value to store
  61875. * @param unit defines the unit to store
  61876. * @returns the current ValueAndUnit
  61877. */
  61878. updateInPlace(value: number, unit?: number): ValueAndUnit;
  61879. /**
  61880. * Gets the value accordingly to its unit
  61881. * @param host defines the root host
  61882. * @returns the value
  61883. */
  61884. getValue(host: AdvancedDynamicTexture): number;
  61885. /**
  61886. * Gets a string representation of the value
  61887. * @param host defines the root host
  61888. * @param decimals defines an optional number of decimals to display
  61889. * @returns a string
  61890. */
  61891. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  61892. /**
  61893. * Store a value parsed from a string
  61894. * @param source defines the source string
  61895. * @returns true if the value was successfully parsed
  61896. */
  61897. fromString(source: string | number): boolean;
  61898. private static _Regex;
  61899. private static _UNITMODE_PERCENTAGE;
  61900. private static _UNITMODE_PIXEL;
  61901. /** UNITMODE_PERCENTAGE */
  61902. static readonly UNITMODE_PERCENTAGE: number;
  61903. /** UNITMODE_PIXEL */
  61904. static readonly UNITMODE_PIXEL: number;
  61905. }
  61906. }
  61907. declare module BABYLON.GUI {
  61908. /**
  61909. * Define a style used by control to automatically setup properties based on a template.
  61910. * Only support font related properties so far
  61911. */
  61912. export class Style implements BABYLON.IDisposable {
  61913. private _fontFamily;
  61914. private _fontStyle;
  61915. private _fontWeight;
  61916. /** @hidden */
  61917. _host: AdvancedDynamicTexture;
  61918. /** @hidden */
  61919. _fontSize: ValueAndUnit;
  61920. /**
  61921. * BABYLON.Observable raised when the style values are changed
  61922. */
  61923. onChangedObservable: BABYLON.Observable<Style>;
  61924. /**
  61925. * Creates a new style object
  61926. * @param host defines the AdvancedDynamicTexture which hosts this style
  61927. */
  61928. constructor(host: AdvancedDynamicTexture);
  61929. /**
  61930. * Gets or sets the font size
  61931. */
  61932. fontSize: string | number;
  61933. /**
  61934. * Gets or sets the font family
  61935. */
  61936. fontFamily: string;
  61937. /**
  61938. * Gets or sets the font style
  61939. */
  61940. fontStyle: string;
  61941. /** Gets or sets font weight */
  61942. fontWeight: string;
  61943. /** Dispose all associated resources */
  61944. dispose(): void;
  61945. }
  61946. }
  61947. declare module BABYLON.GUI {
  61948. /**
  61949. * Class used to transport BABYLON.Vector2 information for pointer events
  61950. */
  61951. export class Vector2WithInfo extends BABYLON.Vector2 {
  61952. /** defines the current mouse button index */
  61953. buttonIndex: number;
  61954. /**
  61955. * Creates a new Vector2WithInfo
  61956. * @param source defines the vector2 data to transport
  61957. * @param buttonIndex defines the current mouse button index
  61958. */
  61959. constructor(source: BABYLON.Vector2,
  61960. /** defines the current mouse button index */
  61961. buttonIndex?: number);
  61962. }
  61963. /** Class used to provide 2D matrix features */
  61964. export class Matrix2D {
  61965. /** Gets the internal array of 6 floats used to store matrix data */
  61966. m: Float32Array;
  61967. /**
  61968. * Creates a new matrix
  61969. * @param m00 defines value for (0, 0)
  61970. * @param m01 defines value for (0, 1)
  61971. * @param m10 defines value for (1, 0)
  61972. * @param m11 defines value for (1, 1)
  61973. * @param m20 defines value for (2, 0)
  61974. * @param m21 defines value for (2, 1)
  61975. */
  61976. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  61977. /**
  61978. * Fills the matrix from direct values
  61979. * @param m00 defines value for (0, 0)
  61980. * @param m01 defines value for (0, 1)
  61981. * @param m10 defines value for (1, 0)
  61982. * @param m11 defines value for (1, 1)
  61983. * @param m20 defines value for (2, 0)
  61984. * @param m21 defines value for (2, 1)
  61985. * @returns the current modified matrix
  61986. */
  61987. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  61988. /**
  61989. * Gets matrix determinant
  61990. * @returns the determinant
  61991. */
  61992. determinant(): number;
  61993. /**
  61994. * Inverses the matrix and stores it in a target matrix
  61995. * @param result defines the target matrix
  61996. * @returns the current matrix
  61997. */
  61998. invertToRef(result: Matrix2D): Matrix2D;
  61999. /**
  62000. * Multiplies the current matrix with another one
  62001. * @param other defines the second operand
  62002. * @param result defines the target matrix
  62003. * @returns the current matrix
  62004. */
  62005. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  62006. /**
  62007. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  62008. * @param x defines the x coordinate to transform
  62009. * @param y defines the x coordinate to transform
  62010. * @param result defines the target vector2
  62011. * @returns the current matrix
  62012. */
  62013. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  62014. /**
  62015. * Creates an identity matrix
  62016. * @returns a new matrix
  62017. */
  62018. static Identity(): Matrix2D;
  62019. /**
  62020. * Creates a translation matrix and stores it in a target matrix
  62021. * @param x defines the x coordinate of the translation
  62022. * @param y defines the y coordinate of the translation
  62023. * @param result defines the target matrix
  62024. */
  62025. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  62026. /**
  62027. * Creates a scaling matrix and stores it in a target matrix
  62028. * @param x defines the x coordinate of the scaling
  62029. * @param y defines the y coordinate of the scaling
  62030. * @param result defines the target matrix
  62031. */
  62032. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  62033. /**
  62034. * Creates a rotation matrix and stores it in a target matrix
  62035. * @param angle defines the rotation angle
  62036. * @param result defines the target matrix
  62037. */
  62038. static RotationToRef(angle: number, result: Matrix2D): void;
  62039. private static _TempPreTranslationMatrix;
  62040. private static _TempPostTranslationMatrix;
  62041. private static _TempRotationMatrix;
  62042. private static _TempScalingMatrix;
  62043. private static _TempCompose0;
  62044. private static _TempCompose1;
  62045. private static _TempCompose2;
  62046. /**
  62047. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  62048. * @param tx defines the x coordinate of the translation
  62049. * @param ty defines the y coordinate of the translation
  62050. * @param angle defines the rotation angle
  62051. * @param scaleX defines the x coordinate of the scaling
  62052. * @param scaleY defines the y coordinate of the scaling
  62053. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  62054. * @param result defines the target matrix
  62055. */
  62056. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  62057. }
  62058. }
  62059. declare module BABYLON.GUI {
  62060. /**
  62061. * Class used to store 2D control sizes
  62062. */
  62063. export class Measure {
  62064. /** defines left coordinate */
  62065. left: number;
  62066. /** defines top coordinate */
  62067. top: number;
  62068. /** defines width dimension */
  62069. width: number;
  62070. /** defines height dimension */
  62071. height: number;
  62072. /**
  62073. * Creates a new measure
  62074. * @param left defines left coordinate
  62075. * @param top defines top coordinate
  62076. * @param width defines width dimension
  62077. * @param height defines height dimension
  62078. */
  62079. constructor(
  62080. /** defines left coordinate */
  62081. left: number,
  62082. /** defines top coordinate */
  62083. top: number,
  62084. /** defines width dimension */
  62085. width: number,
  62086. /** defines height dimension */
  62087. height: number);
  62088. /**
  62089. * Copy from another measure
  62090. * @param other defines the other measure to copy from
  62091. */
  62092. copyFrom(other: Measure): void;
  62093. /**
  62094. * Copy from a group of 4 floats
  62095. * @param left defines left coordinate
  62096. * @param top defines top coordinate
  62097. * @param width defines width dimension
  62098. * @param height defines height dimension
  62099. */
  62100. copyFromFloats(left: number, top: number, width: number, height: number): void;
  62101. /**
  62102. * Computes the axis aligned bounding box measure for two given measures
  62103. * @param a Input measure
  62104. * @param b Input measure
  62105. * @param result the resulting bounding measure
  62106. */
  62107. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  62108. /**
  62109. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  62110. * @param transform the matrix to transform the measure before computing the AABB
  62111. * @param result the resulting AABB
  62112. */
  62113. transformToRef(transform: Matrix2D, result: Measure): void;
  62114. /**
  62115. * Check equality between this measure and another one
  62116. * @param other defines the other measures
  62117. * @returns true if both measures are equals
  62118. */
  62119. isEqualsTo(other: Measure): boolean;
  62120. /**
  62121. * Creates an empty measure
  62122. * @returns a new measure
  62123. */
  62124. static Empty(): Measure;
  62125. }
  62126. }
  62127. declare module BABYLON.GUI {
  62128. /**
  62129. * Interface used to define a control that can receive focus
  62130. */
  62131. export interface IFocusableControl {
  62132. /**
  62133. * Function called when the control receives the focus
  62134. */
  62135. onFocus(): void;
  62136. /**
  62137. * Function called when the control loses the focus
  62138. */
  62139. onBlur(): void;
  62140. /**
  62141. * Function called to let the control handle keyboard events
  62142. * @param evt defines the current keyboard event
  62143. */
  62144. processKeyboard(evt: KeyboardEvent): void;
  62145. /**
  62146. * Function called to get the list of controls that should not steal the focus from this control
  62147. * @returns an array of controls
  62148. */
  62149. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  62150. }
  62151. /**
  62152. * Class used to create texture to support 2D GUI elements
  62153. * @see http://doc.babylonjs.com/how_to/gui
  62154. */
  62155. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  62156. private _isDirty;
  62157. private _renderObserver;
  62158. private _resizeObserver;
  62159. private _preKeyboardObserver;
  62160. private _pointerMoveObserver;
  62161. private _pointerObserver;
  62162. private _canvasPointerOutObserver;
  62163. private _background;
  62164. /** @hidden */
  62165. _rootContainer: Container;
  62166. /** @hidden */
  62167. _lastPickedControl: Control;
  62168. /** @hidden */
  62169. _lastControlOver: {
  62170. [pointerId: number]: Control;
  62171. };
  62172. /** @hidden */
  62173. _lastControlDown: {
  62174. [pointerId: number]: Control;
  62175. };
  62176. /** @hidden */
  62177. _capturingControl: {
  62178. [pointerId: number]: Control;
  62179. };
  62180. /** @hidden */
  62181. _shouldBlockPointer: boolean;
  62182. /** @hidden */
  62183. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  62184. /** @hidden */
  62185. _linkedControls: Control[];
  62186. private _isFullscreen;
  62187. private _fullscreenViewport;
  62188. private _idealWidth;
  62189. private _idealHeight;
  62190. private _useSmallestIdeal;
  62191. private _renderAtIdealSize;
  62192. private _focusedControl;
  62193. private _blockNextFocusCheck;
  62194. private _renderScale;
  62195. private _rootCanvas;
  62196. private _cursorChanged;
  62197. /**
  62198. * Define type to string to ensure compatibility across browsers
  62199. * Safari doesn't support DataTransfer constructor
  62200. */
  62201. private _clipboardData;
  62202. /**
  62203. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  62204. */
  62205. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  62206. /**
  62207. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  62208. */
  62209. onControlPickedObservable: BABYLON.Observable<Control>;
  62210. /**
  62211. * BABYLON.Observable event triggered before layout is evaluated
  62212. */
  62213. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62214. /**
  62215. * BABYLON.Observable event triggered after the layout was evaluated
  62216. */
  62217. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62218. /**
  62219. * BABYLON.Observable event triggered before the texture is rendered
  62220. */
  62221. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62222. /**
  62223. * BABYLON.Observable event triggered after the texture was rendered
  62224. */
  62225. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62226. /**
  62227. * Gets or sets a boolean defining if alpha is stored as premultiplied
  62228. */
  62229. premulAlpha: boolean;
  62230. /**
  62231. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  62232. * Useful when you want more antialiasing
  62233. */
  62234. renderScale: number;
  62235. /** Gets or sets the background color */
  62236. background: string;
  62237. /**
  62238. * Gets or sets the ideal width used to design controls.
  62239. * The GUI will then rescale everything accordingly
  62240. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62241. */
  62242. idealWidth: number;
  62243. /**
  62244. * Gets or sets the ideal height used to design controls.
  62245. * The GUI will then rescale everything accordingly
  62246. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62247. */
  62248. idealHeight: number;
  62249. /**
  62250. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  62251. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62252. */
  62253. useSmallestIdeal: boolean;
  62254. /**
  62255. * Gets or sets a boolean indicating if adaptive scaling must be used
  62256. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62257. */
  62258. renderAtIdealSize: boolean;
  62259. /**
  62260. * Gets the underlying layer used to render the texture when in fullscreen mode
  62261. */
  62262. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  62263. /**
  62264. * Gets the root container control
  62265. */
  62266. readonly rootContainer: Container;
  62267. /**
  62268. * Returns an array containing the root container.
  62269. * This is mostly used to let the Inspector introspects the ADT
  62270. * @returns an array containing the rootContainer
  62271. */
  62272. getChildren(): Array<Container>;
  62273. /**
  62274. * Will return all controls that are inside this texture
  62275. * @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
  62276. * @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
  62277. * @return all child controls
  62278. */
  62279. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  62280. /**
  62281. * Gets or sets the current focused control
  62282. */
  62283. focusedControl: BABYLON.Nullable<IFocusableControl>;
  62284. /**
  62285. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  62286. */
  62287. isForeground: boolean;
  62288. /**
  62289. * Gets or set information about clipboardData
  62290. */
  62291. clipboardData: string;
  62292. /**
  62293. * Creates a new AdvancedDynamicTexture
  62294. * @param name defines the name of the texture
  62295. * @param width defines the width of the texture
  62296. * @param height defines the height of the texture
  62297. * @param scene defines the hosting scene
  62298. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  62299. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  62300. */
  62301. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  62302. /**
  62303. * Get the current class name of the texture useful for serialization or dynamic coding.
  62304. * @returns "AdvancedDynamicTexture"
  62305. */
  62306. getClassName(): string;
  62307. /**
  62308. * Function used to execute a function on all controls
  62309. * @param func defines the function to execute
  62310. * @param container defines the container where controls belong. If null the root container will be used
  62311. */
  62312. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  62313. private _useInvalidateRectOptimization;
  62314. /**
  62315. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  62316. */
  62317. useInvalidateRectOptimization: boolean;
  62318. private _invalidatedRectangle;
  62319. /**
  62320. * Invalidates a rectangle area on the gui texture
  62321. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  62322. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  62323. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  62324. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  62325. */
  62326. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  62327. /**
  62328. * Marks the texture as dirty forcing a complete update
  62329. */
  62330. markAsDirty(): void;
  62331. /**
  62332. * Helper function used to create a new style
  62333. * @returns a new style
  62334. * @see http://doc.babylonjs.com/how_to/gui#styles
  62335. */
  62336. createStyle(): Style;
  62337. /**
  62338. * Adds a new control to the root container
  62339. * @param control defines the control to add
  62340. * @returns the current texture
  62341. */
  62342. addControl(control: Control): AdvancedDynamicTexture;
  62343. /**
  62344. * Removes a control from the root container
  62345. * @param control defines the control to remove
  62346. * @returns the current texture
  62347. */
  62348. removeControl(control: Control): AdvancedDynamicTexture;
  62349. /**
  62350. * Release all resources
  62351. */
  62352. dispose(): void;
  62353. private _onResize;
  62354. /** @hidden */
  62355. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  62356. /**
  62357. * Get screen coordinates for a vector3
  62358. * @param position defines the position to project
  62359. * @param worldMatrix defines the world matrix to use
  62360. * @returns the projected position
  62361. */
  62362. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  62363. private _checkUpdate;
  62364. private _clearMeasure;
  62365. private _render;
  62366. /** @hidden */
  62367. _changeCursor(cursor: string): void;
  62368. /** @hidden */
  62369. _registerLastControlDown(control: Control, pointerId: number): void;
  62370. private _doPicking;
  62371. /** @hidden */
  62372. _cleanControlAfterRemovalFromList(list: {
  62373. [pointerId: number]: Control;
  62374. }, control: Control): void;
  62375. /** @hidden */
  62376. _cleanControlAfterRemoval(control: Control): void;
  62377. /** Attach to all scene events required to support pointer events */
  62378. attach(): void;
  62379. /** @hidden */
  62380. private onClipboardCopy;
  62381. /** @hidden */
  62382. private onClipboardCut;
  62383. /** @hidden */
  62384. private onClipboardPaste;
  62385. /**
  62386. * Register the clipboard Events onto the canvas
  62387. */
  62388. registerClipboardEvents(): void;
  62389. /**
  62390. * Unregister the clipboard Events from the canvas
  62391. */
  62392. unRegisterClipboardEvents(): void;
  62393. /**
  62394. * Connect the texture to a hosting mesh to enable interactions
  62395. * @param mesh defines the mesh to attach to
  62396. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  62397. */
  62398. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  62399. /**
  62400. * Move the focus to a specific control
  62401. * @param control defines the control which will receive the focus
  62402. */
  62403. moveFocusToControl(control: IFocusableControl): void;
  62404. private _manageFocus;
  62405. private _attachToOnPointerOut;
  62406. /**
  62407. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  62408. * @param mesh defines the mesh which will receive the texture
  62409. * @param width defines the texture width (1024 by default)
  62410. * @param height defines the texture height (1024 by default)
  62411. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  62412. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  62413. * @returns a new AdvancedDynamicTexture
  62414. */
  62415. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  62416. /**
  62417. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  62418. * In this mode the texture will rely on a layer for its rendering.
  62419. * This allows it to be treated like any other layer.
  62420. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  62421. * LayerMask is set through advancedTexture.layer.layerMask
  62422. * @param name defines name for the texture
  62423. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  62424. * @param scene defines the hsoting scene
  62425. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  62426. * @returns a new AdvancedDynamicTexture
  62427. */
  62428. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  62429. }
  62430. }
  62431. declare module BABYLON.GUI {
  62432. /**
  62433. * Root class used for all 2D controls
  62434. * @see http://doc.babylonjs.com/how_to/gui#controls
  62435. */
  62436. export class Control {
  62437. /** defines the name of the control */
  62438. name?: string | undefined;
  62439. /**
  62440. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  62441. */
  62442. static AllowAlphaInheritance: boolean;
  62443. private _alpha;
  62444. private _alphaSet;
  62445. private _zIndex;
  62446. /** @hidden */
  62447. _host: AdvancedDynamicTexture;
  62448. /** Gets or sets the control parent */
  62449. parent: BABYLON.Nullable<Container>;
  62450. /** @hidden */
  62451. _currentMeasure: Measure;
  62452. private _fontFamily;
  62453. private _fontStyle;
  62454. private _fontWeight;
  62455. private _fontSize;
  62456. private _font;
  62457. /** @hidden */
  62458. _width: ValueAndUnit;
  62459. /** @hidden */
  62460. _height: ValueAndUnit;
  62461. /** @hidden */
  62462. protected _fontOffset: {
  62463. ascent: number;
  62464. height: number;
  62465. descent: number;
  62466. };
  62467. private _color;
  62468. private _style;
  62469. private _styleObserver;
  62470. /** @hidden */
  62471. protected _horizontalAlignment: number;
  62472. /** @hidden */
  62473. protected _verticalAlignment: number;
  62474. /** @hidden */
  62475. protected _isDirty: boolean;
  62476. /** @hidden */
  62477. protected _wasDirty: boolean;
  62478. /** @hidden */
  62479. _tempParentMeasure: Measure;
  62480. /** @hidden */
  62481. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  62482. /** @hidden */
  62483. protected _cachedParentMeasure: Measure;
  62484. private _paddingLeft;
  62485. private _paddingRight;
  62486. private _paddingTop;
  62487. private _paddingBottom;
  62488. /** @hidden */
  62489. _left: ValueAndUnit;
  62490. /** @hidden */
  62491. _top: ValueAndUnit;
  62492. private _scaleX;
  62493. private _scaleY;
  62494. private _rotation;
  62495. private _transformCenterX;
  62496. private _transformCenterY;
  62497. /** @hidden */
  62498. _transformMatrix: Matrix2D;
  62499. /** @hidden */
  62500. protected _invertTransformMatrix: Matrix2D;
  62501. /** @hidden */
  62502. protected _transformedPosition: BABYLON.Vector2;
  62503. private _isMatrixDirty;
  62504. private _cachedOffsetX;
  62505. private _cachedOffsetY;
  62506. private _isVisible;
  62507. private _isHighlighted;
  62508. /** @hidden */
  62509. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62510. private _fontSet;
  62511. private _dummyVector2;
  62512. private _downCount;
  62513. private _enterCount;
  62514. private _doNotRender;
  62515. private _downPointerIds;
  62516. protected _isEnabled: boolean;
  62517. protected _disabledColor: string;
  62518. /** @hidden */
  62519. protected _rebuildLayout: boolean;
  62520. /** @hidden */
  62521. _isClipped: boolean;
  62522. /** @hidden */
  62523. _tag: any;
  62524. /**
  62525. * 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
  62526. */
  62527. uniqueId: number;
  62528. /**
  62529. * Gets or sets an object used to store user defined information for the node
  62530. */
  62531. metadata: any;
  62532. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  62533. isHitTestVisible: boolean;
  62534. /** Gets or sets a boolean indicating if the control can block pointer events */
  62535. isPointerBlocker: boolean;
  62536. /** Gets or sets a boolean indicating if the control can be focusable */
  62537. isFocusInvisible: boolean;
  62538. /**
  62539. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  62540. * 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
  62541. */
  62542. clipChildren: boolean;
  62543. /**
  62544. * Gets or sets a boolean indicating that control content must be clipped
  62545. * 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
  62546. */
  62547. clipContent: boolean;
  62548. /**
  62549. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  62550. */
  62551. useBitmapCache: boolean;
  62552. private _cacheData;
  62553. private _shadowOffsetX;
  62554. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  62555. shadowOffsetX: number;
  62556. private _shadowOffsetY;
  62557. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  62558. shadowOffsetY: number;
  62559. private _shadowBlur;
  62560. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  62561. shadowBlur: number;
  62562. private _shadowColor;
  62563. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  62564. shadowColor: string;
  62565. /** Gets or sets the cursor to use when the control is hovered */
  62566. hoverCursor: string;
  62567. /** @hidden */
  62568. protected _linkOffsetX: ValueAndUnit;
  62569. /** @hidden */
  62570. protected _linkOffsetY: ValueAndUnit;
  62571. /** Gets the control type name */
  62572. readonly typeName: string;
  62573. /**
  62574. * Get the current class name of the control.
  62575. * @returns current class name
  62576. */
  62577. getClassName(): string;
  62578. /**
  62579. * An event triggered when the pointer move over the control.
  62580. */
  62581. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  62582. /**
  62583. * An event triggered when the pointer move out of the control.
  62584. */
  62585. onPointerOutObservable: BABYLON.Observable<Control>;
  62586. /**
  62587. * An event triggered when the pointer taps the control
  62588. */
  62589. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  62590. /**
  62591. * An event triggered when pointer up
  62592. */
  62593. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  62594. /**
  62595. * An event triggered when a control is clicked on
  62596. */
  62597. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  62598. /**
  62599. * An event triggered when pointer enters the control
  62600. */
  62601. onPointerEnterObservable: BABYLON.Observable<Control>;
  62602. /**
  62603. * An event triggered when the control is marked as dirty
  62604. */
  62605. onDirtyObservable: BABYLON.Observable<Control>;
  62606. /**
  62607. * An event triggered before drawing the control
  62608. */
  62609. onBeforeDrawObservable: BABYLON.Observable<Control>;
  62610. /**
  62611. * An event triggered after the control was drawn
  62612. */
  62613. onAfterDrawObservable: BABYLON.Observable<Control>;
  62614. /**
  62615. * Get the hosting AdvancedDynamicTexture
  62616. */
  62617. readonly host: AdvancedDynamicTexture;
  62618. /** Gets or set information about font offsets (used to render and align text) */
  62619. fontOffset: {
  62620. ascent: number;
  62621. height: number;
  62622. descent: number;
  62623. };
  62624. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  62625. alpha: number;
  62626. /**
  62627. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  62628. */
  62629. isHighlighted: boolean;
  62630. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  62631. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62632. */
  62633. scaleX: number;
  62634. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  62635. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62636. */
  62637. scaleY: number;
  62638. /** Gets or sets the rotation angle (0 by default)
  62639. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62640. */
  62641. rotation: number;
  62642. /** Gets or sets the transformation center on Y axis (0 by default)
  62643. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62644. */
  62645. transformCenterY: number;
  62646. /** Gets or sets the transformation center on X axis (0 by default)
  62647. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62648. */
  62649. transformCenterX: number;
  62650. /**
  62651. * Gets or sets the horizontal alignment
  62652. * @see http://doc.babylonjs.com/how_to/gui#alignments
  62653. */
  62654. horizontalAlignment: number;
  62655. /**
  62656. * Gets or sets the vertical alignment
  62657. * @see http://doc.babylonjs.com/how_to/gui#alignments
  62658. */
  62659. verticalAlignment: number;
  62660. /**
  62661. * Gets or sets control width
  62662. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62663. */
  62664. width: string | number;
  62665. /**
  62666. * Gets or sets the control width in pixel
  62667. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62668. */
  62669. widthInPixels: number;
  62670. /**
  62671. * Gets or sets control height
  62672. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62673. */
  62674. height: string | number;
  62675. /**
  62676. * Gets or sets control height in pixel
  62677. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62678. */
  62679. heightInPixels: number;
  62680. /** Gets or set font family */
  62681. fontFamily: string;
  62682. /** Gets or sets font style */
  62683. fontStyle: string;
  62684. /** Gets or sets font weight */
  62685. fontWeight: string;
  62686. /**
  62687. * Gets or sets style
  62688. * @see http://doc.babylonjs.com/how_to/gui#styles
  62689. */
  62690. style: BABYLON.Nullable<Style>;
  62691. /** @hidden */
  62692. readonly _isFontSizeInPercentage: boolean;
  62693. /** Gets or sets font size in pixels */
  62694. fontSizeInPixels: number;
  62695. /** Gets or sets font size */
  62696. fontSize: string | number;
  62697. /** Gets or sets foreground color */
  62698. color: string;
  62699. /** Gets or sets z index which is used to reorder controls on the z axis */
  62700. zIndex: number;
  62701. /** Gets or sets a boolean indicating if the control can be rendered */
  62702. notRenderable: boolean;
  62703. /** Gets or sets a boolean indicating if the control is visible */
  62704. isVisible: boolean;
  62705. /** Gets a boolean indicating that the control needs to update its rendering */
  62706. readonly isDirty: boolean;
  62707. /**
  62708. * Gets the current linked mesh (or null if none)
  62709. */
  62710. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62711. /**
  62712. * Gets or sets a value indicating the padding to use on the left of the control
  62713. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62714. */
  62715. paddingLeft: string | number;
  62716. /**
  62717. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  62718. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62719. */
  62720. paddingLeftInPixels: number;
  62721. /**
  62722. * Gets or sets a value indicating the padding to use on the right of the control
  62723. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62724. */
  62725. paddingRight: string | number;
  62726. /**
  62727. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  62728. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62729. */
  62730. paddingRightInPixels: number;
  62731. /**
  62732. * Gets or sets a value indicating the padding to use on the top of the control
  62733. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62734. */
  62735. paddingTop: string | number;
  62736. /**
  62737. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  62738. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62739. */
  62740. paddingTopInPixels: number;
  62741. /**
  62742. * Gets or sets a value indicating the padding to use on the bottom of the control
  62743. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62744. */
  62745. paddingBottom: string | number;
  62746. /**
  62747. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  62748. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62749. */
  62750. paddingBottomInPixels: number;
  62751. /**
  62752. * Gets or sets a value indicating the left coordinate of the control
  62753. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62754. */
  62755. left: string | number;
  62756. /**
  62757. * Gets or sets a value indicating the left coordinate in pixels of the control
  62758. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62759. */
  62760. leftInPixels: number;
  62761. /**
  62762. * Gets or sets a value indicating the top coordinate of the control
  62763. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62764. */
  62765. top: string | number;
  62766. /**
  62767. * Gets or sets a value indicating the top coordinate in pixels of the control
  62768. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62769. */
  62770. topInPixels: number;
  62771. /**
  62772. * Gets or sets a value indicating the offset on X axis to the linked mesh
  62773. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62774. */
  62775. linkOffsetX: string | number;
  62776. /**
  62777. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  62778. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62779. */
  62780. linkOffsetXInPixels: number;
  62781. /**
  62782. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  62783. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62784. */
  62785. linkOffsetY: string | number;
  62786. /**
  62787. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  62788. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62789. */
  62790. linkOffsetYInPixels: number;
  62791. /** Gets the center coordinate on X axis */
  62792. readonly centerX: number;
  62793. /** Gets the center coordinate on Y axis */
  62794. readonly centerY: number;
  62795. /** Gets or sets if control is Enabled*/
  62796. isEnabled: boolean;
  62797. /** Gets or sets background color of control if it's disabled*/
  62798. disabledColor: string;
  62799. /**
  62800. * Creates a new control
  62801. * @param name defines the name of the control
  62802. */
  62803. constructor(
  62804. /** defines the name of the control */
  62805. name?: string | undefined);
  62806. /** @hidden */
  62807. protected _getTypeName(): string;
  62808. /**
  62809. * Gets the first ascendant in the hierarchy of the given type
  62810. * @param className defines the required type
  62811. * @returns the ascendant or null if not found
  62812. */
  62813. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  62814. /** @hidden */
  62815. _resetFontCache(): void;
  62816. /**
  62817. * Determines if a container is an ascendant of the current control
  62818. * @param container defines the container to look for
  62819. * @returns true if the container is one of the ascendant of the control
  62820. */
  62821. isAscendant(container: Control): boolean;
  62822. /**
  62823. * Gets coordinates in local control space
  62824. * @param globalCoordinates defines the coordinates to transform
  62825. * @returns the new coordinates in local space
  62826. */
  62827. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  62828. /**
  62829. * Gets coordinates in local control space
  62830. * @param globalCoordinates defines the coordinates to transform
  62831. * @param result defines the target vector2 where to store the result
  62832. * @returns the current control
  62833. */
  62834. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  62835. /**
  62836. * Gets coordinates in parent local control space
  62837. * @param globalCoordinates defines the coordinates to transform
  62838. * @returns the new coordinates in parent local space
  62839. */
  62840. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  62841. /**
  62842. * Move the current control to a vector3 position projected onto the screen.
  62843. * @param position defines the target position
  62844. * @param scene defines the hosting scene
  62845. */
  62846. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  62847. /** @hidden */
  62848. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  62849. /**
  62850. * Will return all controls that have this control as ascendant
  62851. * @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
  62852. * @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
  62853. * @return all child controls
  62854. */
  62855. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  62856. /**
  62857. * Link current control with a target mesh
  62858. * @param mesh defines the mesh to link with
  62859. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62860. */
  62861. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  62862. /** @hidden */
  62863. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  62864. /** @hidden */
  62865. _offsetLeft(offset: number): void;
  62866. /** @hidden */
  62867. _offsetTop(offset: number): void;
  62868. /** @hidden */
  62869. _markMatrixAsDirty(): void;
  62870. /** @hidden */
  62871. _flagDescendantsAsMatrixDirty(): void;
  62872. /** @hidden */
  62873. _intersectsRect(rect: Measure): boolean;
  62874. /** @hidden */
  62875. protected invalidateRect(): void;
  62876. /** @hidden */
  62877. _markAsDirty(force?: boolean): void;
  62878. /** @hidden */
  62879. _markAllAsDirty(): void;
  62880. /** @hidden */
  62881. _link(host: AdvancedDynamicTexture): void;
  62882. /** @hidden */
  62883. protected _transform(context?: CanvasRenderingContext2D): void;
  62884. /** @hidden */
  62885. _renderHighlight(context: CanvasRenderingContext2D): void;
  62886. /** @hidden */
  62887. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  62888. /** @hidden */
  62889. protected _applyStates(context: CanvasRenderingContext2D): void;
  62890. /** @hidden */
  62891. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  62892. /** @hidden */
  62893. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62894. protected _evaluateClippingState(parentMeasure: Measure): void;
  62895. /** @hidden */
  62896. _measure(): void;
  62897. /** @hidden */
  62898. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62899. /** @hidden */
  62900. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62901. /** @hidden */
  62902. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62903. /** @hidden */
  62904. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  62905. private static _ClipMeasure;
  62906. private _tmpMeasureA;
  62907. private _clip;
  62908. /** @hidden */
  62909. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  62910. /** @hidden */
  62911. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  62912. /**
  62913. * Tests if a given coordinates belong to the current control
  62914. * @param x defines x coordinate to test
  62915. * @param y defines y coordinate to test
  62916. * @returns true if the coordinates are inside the control
  62917. */
  62918. contains(x: number, y: number): boolean;
  62919. /** @hidden */
  62920. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  62921. /** @hidden */
  62922. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  62923. /** @hidden */
  62924. _onPointerEnter(target: Control): boolean;
  62925. /** @hidden */
  62926. _onPointerOut(target: Control, force?: boolean): void;
  62927. /** @hidden */
  62928. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62929. /** @hidden */
  62930. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62931. /** @hidden */
  62932. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  62933. /** @hidden */
  62934. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  62935. private _prepareFont;
  62936. /** Releases associated resources */
  62937. dispose(): void;
  62938. private static _HORIZONTAL_ALIGNMENT_LEFT;
  62939. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  62940. private static _HORIZONTAL_ALIGNMENT_CENTER;
  62941. private static _VERTICAL_ALIGNMENT_TOP;
  62942. private static _VERTICAL_ALIGNMENT_BOTTOM;
  62943. private static _VERTICAL_ALIGNMENT_CENTER;
  62944. /** HORIZONTAL_ALIGNMENT_LEFT */
  62945. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  62946. /** HORIZONTAL_ALIGNMENT_RIGHT */
  62947. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  62948. /** HORIZONTAL_ALIGNMENT_CENTER */
  62949. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  62950. /** VERTICAL_ALIGNMENT_TOP */
  62951. static readonly VERTICAL_ALIGNMENT_TOP: number;
  62952. /** VERTICAL_ALIGNMENT_BOTTOM */
  62953. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  62954. /** VERTICAL_ALIGNMENT_CENTER */
  62955. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  62956. private static _FontHeightSizes;
  62957. /** @hidden */
  62958. static _GetFontOffset(font: string): {
  62959. ascent: number;
  62960. height: number;
  62961. descent: number;
  62962. };
  62963. /**
  62964. * Creates a stack panel that can be used to render headers
  62965. * @param control defines the control to associate with the header
  62966. * @param text defines the text of the header
  62967. * @param size defines the size of the header
  62968. * @param options defines options used to configure the header
  62969. * @returns a new StackPanel
  62970. * @ignore
  62971. * @hidden
  62972. */
  62973. static AddHeader: (control: Control, text: string, size: string | number, options: {
  62974. isHorizontal: boolean;
  62975. controlFirst: boolean;
  62976. }) => any;
  62977. /** @hidden */
  62978. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  62979. }
  62980. }
  62981. declare module BABYLON.GUI {
  62982. /**
  62983. * Root class for 2D containers
  62984. * @see http://doc.babylonjs.com/how_to/gui#containers
  62985. */
  62986. export class Container extends Control {
  62987. name?: string | undefined;
  62988. /** @hidden */
  62989. protected _children: Control[];
  62990. /** @hidden */
  62991. protected _measureForChildren: Measure;
  62992. /** @hidden */
  62993. protected _background: string;
  62994. /** @hidden */
  62995. protected _adaptWidthToChildren: boolean;
  62996. /** @hidden */
  62997. protected _adaptHeightToChildren: boolean;
  62998. /**
  62999. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  63000. */
  63001. logLayoutCycleErrors: boolean;
  63002. /**
  63003. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  63004. */
  63005. maxLayoutCycle: number;
  63006. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  63007. adaptHeightToChildren: boolean;
  63008. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  63009. adaptWidthToChildren: boolean;
  63010. /** Gets or sets background color */
  63011. background: string;
  63012. /** Gets the list of children */
  63013. readonly children: Control[];
  63014. /**
  63015. * Creates a new Container
  63016. * @param name defines the name of the container
  63017. */
  63018. constructor(name?: string | undefined);
  63019. protected _getTypeName(): string;
  63020. _flagDescendantsAsMatrixDirty(): void;
  63021. /**
  63022. * Gets a child using its name
  63023. * @param name defines the child name to look for
  63024. * @returns the child control if found
  63025. */
  63026. getChildByName(name: string): BABYLON.Nullable<Control>;
  63027. /**
  63028. * Gets a child using its type and its name
  63029. * @param name defines the child name to look for
  63030. * @param type defines the child type to look for
  63031. * @returns the child control if found
  63032. */
  63033. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  63034. /**
  63035. * Search for a specific control in children
  63036. * @param control defines the control to look for
  63037. * @returns true if the control is in child list
  63038. */
  63039. containsControl(control: Control): boolean;
  63040. /**
  63041. * Adds a new control to the current container
  63042. * @param control defines the control to add
  63043. * @returns the current container
  63044. */
  63045. addControl(control: BABYLON.Nullable<Control>): Container;
  63046. /**
  63047. * Removes all controls from the current container
  63048. * @returns the current container
  63049. */
  63050. clearControls(): Container;
  63051. /**
  63052. * Removes a control from the current container
  63053. * @param control defines the control to remove
  63054. * @returns the current container
  63055. */
  63056. removeControl(control: Control): Container;
  63057. /** @hidden */
  63058. _reOrderControl(control: Control): void;
  63059. /** @hidden */
  63060. _offsetLeft(offset: number): void;
  63061. /** @hidden */
  63062. _offsetTop(offset: number): void;
  63063. /** @hidden */
  63064. _markAllAsDirty(): void;
  63065. /** @hidden */
  63066. protected _localDraw(context: CanvasRenderingContext2D): void;
  63067. /** @hidden */
  63068. _link(host: AdvancedDynamicTexture): void;
  63069. /** @hidden */
  63070. protected _beforeLayout(): void;
  63071. /** @hidden */
  63072. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63073. /** @hidden */
  63074. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  63075. protected _postMeasure(): void;
  63076. /** @hidden */
  63077. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  63078. /** @hidden */
  63079. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  63080. /** @hidden */
  63081. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63082. /** @hidden */
  63083. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63084. /** Releases associated resources */
  63085. dispose(): void;
  63086. }
  63087. }
  63088. declare module BABYLON.GUI {
  63089. /** Class used to create rectangle container */
  63090. export class Rectangle extends Container {
  63091. name?: string | undefined;
  63092. private _thickness;
  63093. private _cornerRadius;
  63094. /** Gets or sets border thickness */
  63095. thickness: number;
  63096. /** Gets or sets the corner radius angle */
  63097. cornerRadius: number;
  63098. /**
  63099. * Creates a new Rectangle
  63100. * @param name defines the control name
  63101. */
  63102. constructor(name?: string | undefined);
  63103. protected _getTypeName(): string;
  63104. protected _localDraw(context: CanvasRenderingContext2D): void;
  63105. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63106. private _drawRoundedRect;
  63107. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  63108. }
  63109. }
  63110. declare module BABYLON.GUI {
  63111. /**
  63112. * Enum that determines the text-wrapping mode to use.
  63113. */
  63114. export enum TextWrapping {
  63115. /**
  63116. * Clip the text when it's larger than Control.width; this is the default mode.
  63117. */
  63118. Clip = 0,
  63119. /**
  63120. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  63121. */
  63122. WordWrap = 1,
  63123. /**
  63124. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  63125. */
  63126. Ellipsis = 2
  63127. }
  63128. /**
  63129. * Class used to create text block control
  63130. */
  63131. export class TextBlock extends Control {
  63132. /**
  63133. * Defines the name of the control
  63134. */
  63135. name?: string | undefined;
  63136. private _text;
  63137. private _textWrapping;
  63138. private _textHorizontalAlignment;
  63139. private _textVerticalAlignment;
  63140. private _lines;
  63141. private _resizeToFit;
  63142. private _lineSpacing;
  63143. private _outlineWidth;
  63144. private _outlineColor;
  63145. /**
  63146. * An event triggered after the text is changed
  63147. */
  63148. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  63149. /**
  63150. * An event triggered after the text was broken up into lines
  63151. */
  63152. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  63153. /**
  63154. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  63155. */
  63156. readonly lines: any[];
  63157. /**
  63158. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  63159. */
  63160. /**
  63161. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  63162. */
  63163. resizeToFit: boolean;
  63164. /**
  63165. * Gets or sets a boolean indicating if text must be wrapped
  63166. */
  63167. /**
  63168. * Gets or sets a boolean indicating if text must be wrapped
  63169. */
  63170. textWrapping: TextWrapping | boolean;
  63171. /**
  63172. * Gets or sets text to display
  63173. */
  63174. /**
  63175. * Gets or sets text to display
  63176. */
  63177. text: string;
  63178. /**
  63179. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  63180. */
  63181. /**
  63182. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  63183. */
  63184. textHorizontalAlignment: number;
  63185. /**
  63186. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  63187. */
  63188. /**
  63189. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  63190. */
  63191. textVerticalAlignment: number;
  63192. /**
  63193. * Gets or sets line spacing value
  63194. */
  63195. /**
  63196. * Gets or sets line spacing value
  63197. */
  63198. lineSpacing: string | number;
  63199. /**
  63200. * Gets or sets outlineWidth of the text to display
  63201. */
  63202. /**
  63203. * Gets or sets outlineWidth of the text to display
  63204. */
  63205. outlineWidth: number;
  63206. /**
  63207. * Gets or sets outlineColor of the text to display
  63208. */
  63209. /**
  63210. * Gets or sets outlineColor of the text to display
  63211. */
  63212. outlineColor: string;
  63213. /**
  63214. * Creates a new TextBlock object
  63215. * @param name defines the name of the control
  63216. * @param text defines the text to display (emptry string by default)
  63217. */
  63218. constructor(
  63219. /**
  63220. * Defines the name of the control
  63221. */
  63222. name?: string | undefined, text?: string);
  63223. protected _getTypeName(): string;
  63224. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63225. private _drawText;
  63226. /** @hidden */
  63227. _draw(context: CanvasRenderingContext2D): void;
  63228. protected _applyStates(context: CanvasRenderingContext2D): void;
  63229. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  63230. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  63231. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  63232. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  63233. protected _renderLines(context: CanvasRenderingContext2D): void;
  63234. /**
  63235. * Given a width constraint applied on the text block, find the expected height
  63236. * @returns expected height
  63237. */
  63238. computeExpectedHeight(): number;
  63239. dispose(): void;
  63240. }
  63241. }
  63242. declare module BABYLON.GUI {
  63243. /**
  63244. * Class used to create 2D images
  63245. */
  63246. export class Image extends Control {
  63247. name?: string | undefined;
  63248. private static _WorkingCanvas;
  63249. private _domImage;
  63250. private _imageWidth;
  63251. private _imageHeight;
  63252. private _loaded;
  63253. private _stretch;
  63254. private _source;
  63255. private _autoScale;
  63256. private _sourceLeft;
  63257. private _sourceTop;
  63258. private _sourceWidth;
  63259. private _sourceHeight;
  63260. private _cellWidth;
  63261. private _cellHeight;
  63262. private _cellId;
  63263. private _populateNinePatchSlicesFromImage;
  63264. private _sliceLeft;
  63265. private _sliceRight;
  63266. private _sliceTop;
  63267. private _sliceBottom;
  63268. private _detectPointerOnOpaqueOnly;
  63269. /**
  63270. * BABYLON.Observable notified when the content is loaded
  63271. */
  63272. onImageLoadedObservable: BABYLON.Observable<Image>;
  63273. /**
  63274. * Gets a boolean indicating that the content is loaded
  63275. */
  63276. readonly isLoaded: boolean;
  63277. /**
  63278. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  63279. */
  63280. populateNinePatchSlicesFromImage: boolean;
  63281. /**
  63282. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  63283. * Beware using this as this will comsume more memory as the image has to be stored twice
  63284. */
  63285. detectPointerOnOpaqueOnly: boolean;
  63286. /**
  63287. * Gets or sets the left value for slicing (9-patch)
  63288. */
  63289. sliceLeft: number;
  63290. /**
  63291. * Gets or sets the right value for slicing (9-patch)
  63292. */
  63293. sliceRight: number;
  63294. /**
  63295. * Gets or sets the top value for slicing (9-patch)
  63296. */
  63297. sliceTop: number;
  63298. /**
  63299. * Gets or sets the bottom value for slicing (9-patch)
  63300. */
  63301. sliceBottom: number;
  63302. /**
  63303. * Gets or sets the left coordinate in the source image
  63304. */
  63305. sourceLeft: number;
  63306. /**
  63307. * Gets or sets the top coordinate in the source image
  63308. */
  63309. sourceTop: number;
  63310. /**
  63311. * Gets or sets the width to capture in the source image
  63312. */
  63313. sourceWidth: number;
  63314. /**
  63315. * Gets or sets the height to capture in the source image
  63316. */
  63317. sourceHeight: number;
  63318. /**
  63319. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  63320. * @see http://doc.babylonjs.com/how_to/gui#image
  63321. */
  63322. autoScale: boolean;
  63323. /** Gets or sets the streching mode used by the image */
  63324. stretch: number;
  63325. /**
  63326. * Gets or sets the internal DOM image used to render the control
  63327. */
  63328. domImage: HTMLImageElement;
  63329. private _onImageLoaded;
  63330. private _extractNinePatchSliceDataFromImage;
  63331. /**
  63332. * Gets or sets image source url
  63333. */
  63334. source: BABYLON.Nullable<string>;
  63335. /**
  63336. * Gets or sets the cell width to use when animation sheet is enabled
  63337. * @see http://doc.babylonjs.com/how_to/gui#image
  63338. */
  63339. cellWidth: number;
  63340. /**
  63341. * Gets or sets the cell height to use when animation sheet is enabled
  63342. * @see http://doc.babylonjs.com/how_to/gui#image
  63343. */
  63344. cellHeight: number;
  63345. /**
  63346. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  63347. * @see http://doc.babylonjs.com/how_to/gui#image
  63348. */
  63349. cellId: number;
  63350. /**
  63351. * Creates a new Image
  63352. * @param name defines the control name
  63353. * @param url defines the image url
  63354. */
  63355. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  63356. /**
  63357. * Tests if a given coordinates belong to the current control
  63358. * @param x defines x coordinate to test
  63359. * @param y defines y coordinate to test
  63360. * @returns true if the coordinates are inside the control
  63361. */
  63362. contains(x: number, y: number): boolean;
  63363. protected _getTypeName(): string;
  63364. /** Force the control to synchronize with its content */
  63365. synchronizeSizeWithContent(): void;
  63366. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63367. private _prepareWorkingCanvasForOpaqueDetection;
  63368. private _drawImage;
  63369. _draw(context: CanvasRenderingContext2D): void;
  63370. private _renderCornerPatch;
  63371. private _renderNinePatch;
  63372. dispose(): void;
  63373. /** STRETCH_NONE */
  63374. static readonly STRETCH_NONE: number;
  63375. /** STRETCH_FILL */
  63376. static readonly STRETCH_FILL: number;
  63377. /** STRETCH_UNIFORM */
  63378. static readonly STRETCH_UNIFORM: number;
  63379. /** STRETCH_EXTEND */
  63380. static readonly STRETCH_EXTEND: number;
  63381. /** NINE_PATCH */
  63382. static readonly STRETCH_NINE_PATCH: number;
  63383. }
  63384. }
  63385. declare module BABYLON.GUI {
  63386. /**
  63387. * Class used to create 2D buttons
  63388. */
  63389. export class Button extends Rectangle {
  63390. name?: string | undefined;
  63391. /**
  63392. * Function called to generate a pointer enter animation
  63393. */
  63394. pointerEnterAnimation: () => void;
  63395. /**
  63396. * Function called to generate a pointer out animation
  63397. */
  63398. pointerOutAnimation: () => void;
  63399. /**
  63400. * Function called to generate a pointer down animation
  63401. */
  63402. pointerDownAnimation: () => void;
  63403. /**
  63404. * Function called to generate a pointer up animation
  63405. */
  63406. pointerUpAnimation: () => void;
  63407. /**
  63408. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  63409. */
  63410. delegatePickingToChildren: boolean;
  63411. private _image;
  63412. /**
  63413. * Returns the image part of the button (if any)
  63414. */
  63415. readonly image: BABYLON.Nullable<Image>;
  63416. private _textBlock;
  63417. /**
  63418. * Returns the image part of the button (if any)
  63419. */
  63420. readonly textBlock: BABYLON.Nullable<TextBlock>;
  63421. /**
  63422. * Creates a new Button
  63423. * @param name defines the name of the button
  63424. */
  63425. constructor(name?: string | undefined);
  63426. protected _getTypeName(): string;
  63427. /** @hidden */
  63428. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63429. /** @hidden */
  63430. _onPointerEnter(target: Control): boolean;
  63431. /** @hidden */
  63432. _onPointerOut(target: Control, force?: boolean): void;
  63433. /** @hidden */
  63434. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63435. /** @hidden */
  63436. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63437. /**
  63438. * Creates a new button made with an image and a text
  63439. * @param name defines the name of the button
  63440. * @param text defines the text of the button
  63441. * @param imageUrl defines the url of the image
  63442. * @returns a new Button
  63443. */
  63444. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  63445. /**
  63446. * Creates a new button made with an image
  63447. * @param name defines the name of the button
  63448. * @param imageUrl defines the url of the image
  63449. * @returns a new Button
  63450. */
  63451. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  63452. /**
  63453. * Creates a new button made with a text
  63454. * @param name defines the name of the button
  63455. * @param text defines the text of the button
  63456. * @returns a new Button
  63457. */
  63458. static CreateSimpleButton(name: string, text: string): Button;
  63459. /**
  63460. * Creates a new button made with an image and a centered text
  63461. * @param name defines the name of the button
  63462. * @param text defines the text of the button
  63463. * @param imageUrl defines the url of the image
  63464. * @returns a new Button
  63465. */
  63466. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  63467. }
  63468. }
  63469. declare module BABYLON.GUI {
  63470. /**
  63471. * Class used to create a 2D stack panel container
  63472. */
  63473. export class StackPanel extends Container {
  63474. name?: string | undefined;
  63475. private _isVertical;
  63476. private _manualWidth;
  63477. private _manualHeight;
  63478. private _doNotTrackManualChanges;
  63479. /**
  63480. * Gets or sets a boolean indicating that layou warnings should be ignored
  63481. */
  63482. ignoreLayoutWarnings: boolean;
  63483. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  63484. isVertical: boolean;
  63485. /**
  63486. * Gets or sets panel width.
  63487. * This value should not be set when in horizontal mode as it will be computed automatically
  63488. */
  63489. width: string | number;
  63490. /**
  63491. * Gets or sets panel height.
  63492. * This value should not be set when in vertical mode as it will be computed automatically
  63493. */
  63494. height: string | number;
  63495. /**
  63496. * Creates a new StackPanel
  63497. * @param name defines control name
  63498. */
  63499. constructor(name?: string | undefined);
  63500. protected _getTypeName(): string;
  63501. /** @hidden */
  63502. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63503. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63504. protected _postMeasure(): void;
  63505. }
  63506. }
  63507. declare module BABYLON.GUI {
  63508. /**
  63509. * Class used to represent a 2D checkbox
  63510. */
  63511. export class Checkbox extends Control {
  63512. name?: string | undefined;
  63513. private _isChecked;
  63514. private _background;
  63515. private _checkSizeRatio;
  63516. private _thickness;
  63517. /** Gets or sets border thickness */
  63518. thickness: number;
  63519. /**
  63520. * BABYLON.Observable raised when isChecked property changes
  63521. */
  63522. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  63523. /** Gets or sets a value indicating the ratio between overall size and check size */
  63524. checkSizeRatio: number;
  63525. /** Gets or sets background color */
  63526. background: string;
  63527. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  63528. isChecked: boolean;
  63529. /**
  63530. * Creates a new CheckBox
  63531. * @param name defines the control name
  63532. */
  63533. constructor(name?: string | undefined);
  63534. protected _getTypeName(): string;
  63535. /** @hidden */
  63536. _draw(context: CanvasRenderingContext2D): void;
  63537. /** @hidden */
  63538. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63539. /**
  63540. * Utility function to easily create a checkbox with a header
  63541. * @param title defines the label to use for the header
  63542. * @param onValueChanged defines the callback to call when value changes
  63543. * @returns a StackPanel containing the checkbox and a textBlock
  63544. */
  63545. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  63546. }
  63547. }
  63548. declare module BABYLON.GUI {
  63549. /**
  63550. * Class used to store key control properties
  63551. */
  63552. export class KeyPropertySet {
  63553. /** Width */
  63554. width?: string;
  63555. /** Height */
  63556. height?: string;
  63557. /** Left padding */
  63558. paddingLeft?: string;
  63559. /** Right padding */
  63560. paddingRight?: string;
  63561. /** Top padding */
  63562. paddingTop?: string;
  63563. /** Bottom padding */
  63564. paddingBottom?: string;
  63565. /** Foreground color */
  63566. color?: string;
  63567. /** Background color */
  63568. background?: string;
  63569. }
  63570. /**
  63571. * Class used to create virtual keyboard
  63572. */
  63573. export class VirtualKeyboard extends StackPanel {
  63574. /** BABYLON.Observable raised when a key is pressed */
  63575. onKeyPressObservable: BABYLON.Observable<string>;
  63576. /** Gets or sets default key button width */
  63577. defaultButtonWidth: string;
  63578. /** Gets or sets default key button height */
  63579. defaultButtonHeight: string;
  63580. /** Gets or sets default key button left padding */
  63581. defaultButtonPaddingLeft: string;
  63582. /** Gets or sets default key button right padding */
  63583. defaultButtonPaddingRight: string;
  63584. /** Gets or sets default key button top padding */
  63585. defaultButtonPaddingTop: string;
  63586. /** Gets or sets default key button bottom padding */
  63587. defaultButtonPaddingBottom: string;
  63588. /** Gets or sets default key button foreground color */
  63589. defaultButtonColor: string;
  63590. /** Gets or sets default key button background color */
  63591. defaultButtonBackground: string;
  63592. /** Gets or sets shift button foreground color */
  63593. shiftButtonColor: string;
  63594. /** Gets or sets shift button thickness*/
  63595. selectedShiftThickness: number;
  63596. /** Gets shift key state */
  63597. shiftState: number;
  63598. protected _getTypeName(): string;
  63599. private _createKey;
  63600. /**
  63601. * Adds a new row of keys
  63602. * @param keys defines the list of keys to add
  63603. * @param propertySets defines the associated property sets
  63604. */
  63605. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  63606. /**
  63607. * Set the shift key to a specific state
  63608. * @param shiftState defines the new shift state
  63609. */
  63610. applyShiftState(shiftState: number): void;
  63611. private _currentlyConnectedInputText;
  63612. private _connectedInputTexts;
  63613. private _onKeyPressObserver;
  63614. /** Gets the input text control currently attached to the keyboard */
  63615. readonly connectedInputText: BABYLON.Nullable<InputText>;
  63616. /**
  63617. * Connects the keyboard with an input text control
  63618. *
  63619. * @param input defines the target control
  63620. */
  63621. connect(input: InputText): void;
  63622. /**
  63623. * Disconnects the keyboard from connected InputText controls
  63624. *
  63625. * @param input optionally defines a target control, otherwise all are disconnected
  63626. */
  63627. disconnect(input?: InputText): void;
  63628. private _removeConnectedInputObservables;
  63629. /**
  63630. * Release all resources
  63631. */
  63632. dispose(): void;
  63633. /**
  63634. * Creates a new keyboard using a default layout
  63635. *
  63636. * @param name defines control name
  63637. * @returns a new VirtualKeyboard
  63638. */
  63639. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  63640. }
  63641. }
  63642. declare module BABYLON.GUI {
  63643. /**
  63644. * Class used to create input text control
  63645. */
  63646. export class InputText extends Control implements IFocusableControl {
  63647. name?: string | undefined;
  63648. private _text;
  63649. private _placeholderText;
  63650. private _background;
  63651. private _focusedBackground;
  63652. private _focusedColor;
  63653. private _placeholderColor;
  63654. private _thickness;
  63655. private _margin;
  63656. private _autoStretchWidth;
  63657. private _maxWidth;
  63658. private _isFocused;
  63659. private _blinkTimeout;
  63660. private _blinkIsEven;
  63661. private _cursorOffset;
  63662. private _scrollLeft;
  63663. private _textWidth;
  63664. private _clickedCoordinate;
  63665. private _deadKey;
  63666. private _addKey;
  63667. private _currentKey;
  63668. private _isTextHighlightOn;
  63669. private _textHighlightColor;
  63670. private _highligherOpacity;
  63671. private _highlightedText;
  63672. private _startHighlightIndex;
  63673. private _endHighlightIndex;
  63674. private _cursorIndex;
  63675. private _onFocusSelectAll;
  63676. private _isPointerDown;
  63677. private _onClipboardObserver;
  63678. private _onPointerDblTapObserver;
  63679. /** @hidden */
  63680. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  63681. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  63682. promptMessage: string;
  63683. /** Force disable prompt on mobile device */
  63684. disableMobilePrompt: boolean;
  63685. /** BABYLON.Observable raised when the text changes */
  63686. onTextChangedObservable: BABYLON.Observable<InputText>;
  63687. /** BABYLON.Observable raised just before an entered character is to be added */
  63688. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  63689. /** BABYLON.Observable raised when the control gets the focus */
  63690. onFocusObservable: BABYLON.Observable<InputText>;
  63691. /** BABYLON.Observable raised when the control loses the focus */
  63692. onBlurObservable: BABYLON.Observable<InputText>;
  63693. /**Observable raised when the text is highlighted */
  63694. onTextHighlightObservable: BABYLON.Observable<InputText>;
  63695. /**Observable raised when copy event is triggered */
  63696. onTextCopyObservable: BABYLON.Observable<InputText>;
  63697. /** BABYLON.Observable raised when cut event is triggered */
  63698. onTextCutObservable: BABYLON.Observable<InputText>;
  63699. /** BABYLON.Observable raised when paste event is triggered */
  63700. onTextPasteObservable: BABYLON.Observable<InputText>;
  63701. /** BABYLON.Observable raised when a key event was processed */
  63702. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  63703. /** Gets or sets the maximum width allowed by the control */
  63704. maxWidth: string | number;
  63705. /** Gets the maximum width allowed by the control in pixels */
  63706. readonly maxWidthInPixels: number;
  63707. /** Gets or sets the text highlighter transparency; default: 0.4 */
  63708. highligherOpacity: number;
  63709. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  63710. onFocusSelectAll: boolean;
  63711. /** Gets or sets the text hightlight color */
  63712. textHighlightColor: string;
  63713. /** Gets or sets control margin */
  63714. margin: string;
  63715. /** Gets control margin in pixels */
  63716. readonly marginInPixels: number;
  63717. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  63718. autoStretchWidth: boolean;
  63719. /** Gets or sets border thickness */
  63720. thickness: number;
  63721. /** Gets or sets the background color when focused */
  63722. focusedBackground: string;
  63723. /** Gets or sets the background color when focused */
  63724. focusedColor: string;
  63725. /** Gets or sets the background color */
  63726. background: string;
  63727. /** Gets or sets the placeholder color */
  63728. placeholderColor: string;
  63729. /** Gets or sets the text displayed when the control is empty */
  63730. placeholderText: string;
  63731. /** Gets or sets the dead key flag */
  63732. deadKey: boolean;
  63733. /** Gets or sets the highlight text */
  63734. highlightedText: string;
  63735. /** Gets or sets if the current key should be added */
  63736. addKey: boolean;
  63737. /** Gets or sets the value of the current key being entered */
  63738. currentKey: string;
  63739. /** Gets or sets the text displayed in the control */
  63740. text: string;
  63741. /** Gets or sets control width */
  63742. width: string | number;
  63743. /**
  63744. * Creates a new InputText
  63745. * @param name defines the control name
  63746. * @param text defines the text of the control
  63747. */
  63748. constructor(name?: string | undefined, text?: string);
  63749. /** @hidden */
  63750. onBlur(): void;
  63751. /** @hidden */
  63752. onFocus(): void;
  63753. protected _getTypeName(): string;
  63754. /**
  63755. * Function called to get the list of controls that should not steal the focus from this control
  63756. * @returns an array of controls
  63757. */
  63758. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  63759. /** @hidden */
  63760. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  63761. /** @hidden */
  63762. private _updateValueFromCursorIndex;
  63763. /** @hidden */
  63764. private _processDblClick;
  63765. /** @hidden */
  63766. private _selectAllText;
  63767. /**
  63768. * Handles the keyboard event
  63769. * @param evt Defines the KeyboardEvent
  63770. */
  63771. processKeyboard(evt: KeyboardEvent): void;
  63772. /** @hidden */
  63773. private _onCopyText;
  63774. /** @hidden */
  63775. private _onCutText;
  63776. /** @hidden */
  63777. private _onPasteText;
  63778. _draw(context: CanvasRenderingContext2D): void;
  63779. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63780. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  63781. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63782. protected _beforeRenderText(text: string): string;
  63783. dispose(): void;
  63784. }
  63785. }
  63786. declare module BABYLON.GUI {
  63787. /**
  63788. * Class used to create a 2D grid container
  63789. */
  63790. export class Grid extends Container {
  63791. name?: string | undefined;
  63792. private _rowDefinitions;
  63793. private _columnDefinitions;
  63794. private _cells;
  63795. private _childControls;
  63796. /**
  63797. * Gets the number of columns
  63798. */
  63799. readonly columnCount: number;
  63800. /**
  63801. * Gets the number of rows
  63802. */
  63803. readonly rowCount: number;
  63804. /** Gets the list of children */
  63805. readonly children: Control[];
  63806. /** Gets the list of cells (e.g. the containers) */
  63807. readonly cells: {
  63808. [key: string]: Container;
  63809. };
  63810. /**
  63811. * Gets the definition of a specific row
  63812. * @param index defines the index of the row
  63813. * @returns the row definition
  63814. */
  63815. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  63816. /**
  63817. * Gets the definition of a specific column
  63818. * @param index defines the index of the column
  63819. * @returns the column definition
  63820. */
  63821. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  63822. /**
  63823. * Adds a new row to the grid
  63824. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  63825. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  63826. * @returns the current grid
  63827. */
  63828. addRowDefinition(height: number, isPixel?: boolean): Grid;
  63829. /**
  63830. * Adds a new column to the grid
  63831. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  63832. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  63833. * @returns the current grid
  63834. */
  63835. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  63836. /**
  63837. * Update a row definition
  63838. * @param index defines the index of the row to update
  63839. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  63840. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  63841. * @returns the current grid
  63842. */
  63843. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  63844. /**
  63845. * Update a column definition
  63846. * @param index defines the index of the column to update
  63847. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  63848. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  63849. * @returns the current grid
  63850. */
  63851. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  63852. /**
  63853. * Gets the list of children stored in a specific cell
  63854. * @param row defines the row to check
  63855. * @param column defines the column to check
  63856. * @returns the list of controls
  63857. */
  63858. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  63859. /**
  63860. * Gets a string representing the child cell info (row x column)
  63861. * @param child defines the control to get info from
  63862. * @returns a string containing the child cell info (row x column)
  63863. */
  63864. getChildCellInfo(child: Control): string;
  63865. private _removeCell;
  63866. private _offsetCell;
  63867. /**
  63868. * Remove a column definition at specified index
  63869. * @param index defines the index of the column to remove
  63870. * @returns the current grid
  63871. */
  63872. removeColumnDefinition(index: number): Grid;
  63873. /**
  63874. * Remove a row definition at specified index
  63875. * @param index defines the index of the row to remove
  63876. * @returns the current grid
  63877. */
  63878. removeRowDefinition(index: number): Grid;
  63879. /**
  63880. * Adds a new control to the current grid
  63881. * @param control defines the control to add
  63882. * @param row defines the row where to add the control (0 by default)
  63883. * @param column defines the column where to add the control (0 by default)
  63884. * @returns the current grid
  63885. */
  63886. addControl(control: Control, row?: number, column?: number): Grid;
  63887. /**
  63888. * Removes a control from the current container
  63889. * @param control defines the control to remove
  63890. * @returns the current container
  63891. */
  63892. removeControl(control: Control): Container;
  63893. /**
  63894. * Creates a new Grid
  63895. * @param name defines control name
  63896. */
  63897. constructor(name?: string | undefined);
  63898. protected _getTypeName(): string;
  63899. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  63900. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63901. _flagDescendantsAsMatrixDirty(): void;
  63902. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  63903. /** Releases associated resources */
  63904. dispose(): void;
  63905. }
  63906. }
  63907. declare module BABYLON.GUI {
  63908. /** Class used to create color pickers */
  63909. export class ColorPicker extends Control {
  63910. name?: string | undefined;
  63911. private static _Epsilon;
  63912. private _colorWheelCanvas;
  63913. private _value;
  63914. private _tmpColor;
  63915. private _pointerStartedOnSquare;
  63916. private _pointerStartedOnWheel;
  63917. private _squareLeft;
  63918. private _squareTop;
  63919. private _squareSize;
  63920. private _h;
  63921. private _s;
  63922. private _v;
  63923. private _lastPointerDownID;
  63924. /**
  63925. * BABYLON.Observable raised when the value changes
  63926. */
  63927. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  63928. /** Gets or sets the color of the color picker */
  63929. value: BABYLON.Color3;
  63930. /**
  63931. * Gets or sets control width
  63932. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63933. */
  63934. width: string | number;
  63935. /**
  63936. * Gets or sets control height
  63937. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63938. */
  63939. /** Gets or sets control height */
  63940. height: string | number;
  63941. /** Gets or sets control size */
  63942. size: string | number;
  63943. /**
  63944. * Creates a new ColorPicker
  63945. * @param name defines the control name
  63946. */
  63947. constructor(name?: string | undefined);
  63948. protected _getTypeName(): string;
  63949. /** @hidden */
  63950. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63951. private _updateSquareProps;
  63952. private _drawGradientSquare;
  63953. private _drawCircle;
  63954. private _createColorWheelCanvas;
  63955. /** @hidden */
  63956. _draw(context: CanvasRenderingContext2D): void;
  63957. private _pointerIsDown;
  63958. private _updateValueFromPointer;
  63959. private _isPointOnSquare;
  63960. private _isPointOnWheel;
  63961. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63962. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  63963. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63964. /**
  63965. * This function expands the color picker by creating a color picker dialog with manual
  63966. * color value input and the ability to save colors into an array to be used later in
  63967. * subsequent launches of the dialogue.
  63968. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  63969. * @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.
  63970. * @returns picked color as a hex string and the saved colors array as hex strings.
  63971. */
  63972. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  63973. pickerWidth?: string;
  63974. pickerHeight?: string;
  63975. headerHeight?: string;
  63976. lastColor?: string;
  63977. swatchLimit?: number;
  63978. numSwatchesPerLine?: number;
  63979. savedColors?: Array<string>;
  63980. }): Promise<{
  63981. savedColors?: string[];
  63982. pickedColor: string;
  63983. }>;
  63984. }
  63985. }
  63986. declare module BABYLON.GUI {
  63987. /** Class used to create 2D ellipse containers */
  63988. export class Ellipse extends Container {
  63989. name?: string | undefined;
  63990. private _thickness;
  63991. /** Gets or sets border thickness */
  63992. thickness: number;
  63993. /**
  63994. * Creates a new Ellipse
  63995. * @param name defines the control name
  63996. */
  63997. constructor(name?: string | undefined);
  63998. protected _getTypeName(): string;
  63999. protected _localDraw(context: CanvasRenderingContext2D): void;
  64000. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64001. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64002. }
  64003. }
  64004. declare module BABYLON.GUI {
  64005. /**
  64006. * Class used to create a password control
  64007. */
  64008. export class InputPassword extends InputText {
  64009. protected _beforeRenderText(text: string): string;
  64010. }
  64011. }
  64012. declare module BABYLON.GUI {
  64013. /** Class used to render 2D lines */
  64014. export class Line extends Control {
  64015. name?: string | undefined;
  64016. private _lineWidth;
  64017. private _x1;
  64018. private _y1;
  64019. private _x2;
  64020. private _y2;
  64021. private _dash;
  64022. private _connectedControl;
  64023. private _connectedControlDirtyObserver;
  64024. /** Gets or sets the dash pattern */
  64025. dash: Array<number>;
  64026. /** Gets or sets the control connected with the line end */
  64027. connectedControl: Control;
  64028. /** Gets or sets start coordinates on X axis */
  64029. x1: string | number;
  64030. /** Gets or sets start coordinates on Y axis */
  64031. y1: string | number;
  64032. /** Gets or sets end coordinates on X axis */
  64033. x2: string | number;
  64034. /** Gets or sets end coordinates on Y axis */
  64035. y2: string | number;
  64036. /** Gets or sets line width */
  64037. lineWidth: number;
  64038. /** Gets or sets horizontal alignment */
  64039. horizontalAlignment: number;
  64040. /** Gets or sets vertical alignment */
  64041. verticalAlignment: number;
  64042. private readonly _effectiveX2;
  64043. private readonly _effectiveY2;
  64044. /**
  64045. * Creates a new Line
  64046. * @param name defines the control name
  64047. */
  64048. constructor(name?: string | undefined);
  64049. protected _getTypeName(): string;
  64050. _draw(context: CanvasRenderingContext2D): void;
  64051. _measure(): void;
  64052. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64053. /**
  64054. * Move one end of the line given 3D cartesian coordinates.
  64055. * @param position Targeted world position
  64056. * @param scene BABYLON.Scene
  64057. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  64058. */
  64059. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  64060. /**
  64061. * Move one end of the line to a position in screen absolute space.
  64062. * @param projectedPosition Position in screen absolute space (X, Y)
  64063. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  64064. */
  64065. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  64066. }
  64067. }
  64068. declare module BABYLON.GUI {
  64069. /**
  64070. * Class used to store a point for a MultiLine object.
  64071. * The point can be pure 2D coordinates, a mesh or a control
  64072. */
  64073. export class MultiLinePoint {
  64074. private _multiLine;
  64075. private _x;
  64076. private _y;
  64077. private _control;
  64078. private _mesh;
  64079. private _controlObserver;
  64080. private _meshObserver;
  64081. /** @hidden */
  64082. _point: BABYLON.Vector2;
  64083. /**
  64084. * Creates a new MultiLinePoint
  64085. * @param multiLine defines the source MultiLine object
  64086. */
  64087. constructor(multiLine: MultiLine);
  64088. /** Gets or sets x coordinate */
  64089. x: string | number;
  64090. /** Gets or sets y coordinate */
  64091. y: string | number;
  64092. /** Gets or sets the control associated with this point */
  64093. control: BABYLON.Nullable<Control>;
  64094. /** Gets or sets the mesh associated with this point */
  64095. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64096. /** Resets links */
  64097. resetLinks(): void;
  64098. /**
  64099. * Gets a translation vector
  64100. * @returns the translation vector
  64101. */
  64102. translate(): BABYLON.Vector2;
  64103. private _translatePoint;
  64104. /** Release associated resources */
  64105. dispose(): void;
  64106. }
  64107. }
  64108. declare module BABYLON.GUI {
  64109. /**
  64110. * Class used to create multi line control
  64111. */
  64112. export class MultiLine extends Control {
  64113. name?: string | undefined;
  64114. private _lineWidth;
  64115. private _dash;
  64116. private _points;
  64117. private _minX;
  64118. private _minY;
  64119. private _maxX;
  64120. private _maxY;
  64121. /**
  64122. * Creates a new MultiLine
  64123. * @param name defines the control name
  64124. */
  64125. constructor(name?: string | undefined);
  64126. /** Gets or sets dash pattern */
  64127. dash: Array<number>;
  64128. /**
  64129. * Gets point stored at specified index
  64130. * @param index defines the index to look for
  64131. * @returns the requested point if found
  64132. */
  64133. getAt(index: number): MultiLinePoint;
  64134. /** Function called when a point is updated */
  64135. onPointUpdate: () => void;
  64136. /**
  64137. * Adds new points to the point collection
  64138. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  64139. * @returns the list of created MultiLinePoint
  64140. */
  64141. add(...items: (AbstractMesh | Control | {
  64142. x: string | number;
  64143. y: string | number;
  64144. })[]): MultiLinePoint[];
  64145. /**
  64146. * Adds a new point to the point collection
  64147. * @param item defines the item (mesh, control or 2d coordiantes) to add
  64148. * @returns the created MultiLinePoint
  64149. */
  64150. push(item?: (AbstractMesh | Control | {
  64151. x: string | number;
  64152. y: string | number;
  64153. })): MultiLinePoint;
  64154. /**
  64155. * Remove a specific value or point from the active point collection
  64156. * @param value defines the value or point to remove
  64157. */
  64158. remove(value: number | MultiLinePoint): void;
  64159. /**
  64160. * Resets this object to initial state (no point)
  64161. */
  64162. reset(): void;
  64163. /**
  64164. * Resets all links
  64165. */
  64166. resetLinks(): void;
  64167. /** Gets or sets line width */
  64168. lineWidth: number;
  64169. horizontalAlignment: number;
  64170. verticalAlignment: number;
  64171. protected _getTypeName(): string;
  64172. _draw(context: CanvasRenderingContext2D): void;
  64173. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64174. _measure(): void;
  64175. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64176. dispose(): void;
  64177. }
  64178. }
  64179. declare module BABYLON.GUI {
  64180. /**
  64181. * Class used to create radio button controls
  64182. */
  64183. export class RadioButton extends Control {
  64184. name?: string | undefined;
  64185. private _isChecked;
  64186. private _background;
  64187. private _checkSizeRatio;
  64188. private _thickness;
  64189. /** Gets or sets border thickness */
  64190. thickness: number;
  64191. /** Gets or sets group name */
  64192. group: string;
  64193. /** BABYLON.Observable raised when isChecked is changed */
  64194. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  64195. /** Gets or sets a value indicating the ratio between overall size and check size */
  64196. checkSizeRatio: number;
  64197. /** Gets or sets background color */
  64198. background: string;
  64199. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  64200. isChecked: boolean;
  64201. /**
  64202. * Creates a new RadioButton
  64203. * @param name defines the control name
  64204. */
  64205. constructor(name?: string | undefined);
  64206. protected _getTypeName(): string;
  64207. _draw(context: CanvasRenderingContext2D): void;
  64208. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64209. /**
  64210. * Utility function to easily create a radio button with a header
  64211. * @param title defines the label to use for the header
  64212. * @param group defines the group to use for the radio button
  64213. * @param isChecked defines the initial state of the radio button
  64214. * @param onValueChanged defines the callback to call when value changes
  64215. * @returns a StackPanel containing the radio button and a textBlock
  64216. */
  64217. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  64218. }
  64219. }
  64220. declare module BABYLON.GUI {
  64221. /**
  64222. * Class used to create slider controls
  64223. */
  64224. export class BaseSlider extends Control {
  64225. name?: string | undefined;
  64226. protected _thumbWidth: ValueAndUnit;
  64227. private _minimum;
  64228. private _maximum;
  64229. private _value;
  64230. private _isVertical;
  64231. protected _barOffset: ValueAndUnit;
  64232. private _isThumbClamped;
  64233. protected _displayThumb: boolean;
  64234. private _step;
  64235. private _lastPointerDownID;
  64236. protected _effectiveBarOffset: number;
  64237. protected _renderLeft: number;
  64238. protected _renderTop: number;
  64239. protected _renderWidth: number;
  64240. protected _renderHeight: number;
  64241. protected _backgroundBoxLength: number;
  64242. protected _backgroundBoxThickness: number;
  64243. protected _effectiveThumbThickness: number;
  64244. /** BABYLON.Observable raised when the sldier value changes */
  64245. onValueChangedObservable: BABYLON.Observable<number>;
  64246. /** Gets or sets a boolean indicating if the thumb must be rendered */
  64247. displayThumb: boolean;
  64248. /** Gets or sets a step to apply to values (0 by default) */
  64249. step: number;
  64250. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  64251. barOffset: string | number;
  64252. /** Gets main bar offset in pixels*/
  64253. readonly barOffsetInPixels: number;
  64254. /** Gets or sets thumb width */
  64255. thumbWidth: string | number;
  64256. /** Gets thumb width in pixels */
  64257. readonly thumbWidthInPixels: number;
  64258. /** Gets or sets minimum value */
  64259. minimum: number;
  64260. /** Gets or sets maximum value */
  64261. maximum: number;
  64262. /** Gets or sets current value */
  64263. value: number;
  64264. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  64265. isVertical: boolean;
  64266. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  64267. isThumbClamped: boolean;
  64268. /**
  64269. * Creates a new BaseSlider
  64270. * @param name defines the control name
  64271. */
  64272. constructor(name?: string | undefined);
  64273. protected _getTypeName(): string;
  64274. protected _getThumbPosition(): number;
  64275. protected _getThumbThickness(type: string): number;
  64276. protected _prepareRenderingData(type: string): void;
  64277. private _pointerIsDown;
  64278. /** @hidden */
  64279. protected _updateValueFromPointer(x: number, y: number): void;
  64280. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64281. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64282. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64283. }
  64284. }
  64285. declare module BABYLON.GUI {
  64286. /**
  64287. * Class used to create slider controls
  64288. */
  64289. export class Slider extends BaseSlider {
  64290. name?: string | undefined;
  64291. private _background;
  64292. private _borderColor;
  64293. private _isThumbCircle;
  64294. protected _displayValueBar: boolean;
  64295. /** Gets or sets a boolean indicating if the value bar must be rendered */
  64296. displayValueBar: boolean;
  64297. /** Gets or sets border color */
  64298. borderColor: string;
  64299. /** Gets or sets background color */
  64300. background: string;
  64301. /** Gets or sets a boolean indicating if the thumb should be round or square */
  64302. isThumbCircle: boolean;
  64303. /**
  64304. * Creates a new Slider
  64305. * @param name defines the control name
  64306. */
  64307. constructor(name?: string | undefined);
  64308. protected _getTypeName(): string;
  64309. _draw(context: CanvasRenderingContext2D): void;
  64310. }
  64311. }
  64312. declare module BABYLON.GUI {
  64313. /** Class used to create a RadioGroup
  64314. * which contains groups of radio buttons
  64315. */
  64316. export class SelectorGroup {
  64317. /** name of SelectorGroup */
  64318. name: string;
  64319. private _groupPanel;
  64320. private _selectors;
  64321. private _groupHeader;
  64322. /**
  64323. * Creates a new SelectorGroup
  64324. * @param name of group, used as a group heading
  64325. */
  64326. constructor(
  64327. /** name of SelectorGroup */
  64328. name: string);
  64329. /** Gets the groupPanel of the SelectorGroup */
  64330. readonly groupPanel: StackPanel;
  64331. /** Gets the selectors array */
  64332. readonly selectors: StackPanel[];
  64333. /** Gets and sets the group header */
  64334. header: string;
  64335. /** @hidden */
  64336. private _addGroupHeader;
  64337. /** @hidden*/
  64338. _getSelector(selectorNb: number): StackPanel | undefined;
  64339. /** Removes the selector at the given position
  64340. * @param selectorNb the position of the selector within the group
  64341. */
  64342. removeSelector(selectorNb: number): void;
  64343. }
  64344. /** Class used to create a CheckboxGroup
  64345. * which contains groups of checkbox buttons
  64346. */
  64347. export class CheckboxGroup extends SelectorGroup {
  64348. /** Adds a checkbox as a control
  64349. * @param text is the label for the selector
  64350. * @param func is the function called when the Selector is checked
  64351. * @param checked is true when Selector is checked
  64352. */
  64353. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  64354. /** @hidden */
  64355. _setSelectorLabel(selectorNb: number, label: string): void;
  64356. /** @hidden */
  64357. _setSelectorLabelColor(selectorNb: number, color: string): void;
  64358. /** @hidden */
  64359. _setSelectorButtonColor(selectorNb: number, color: string): void;
  64360. /** @hidden */
  64361. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  64362. }
  64363. /** Class used to create a RadioGroup
  64364. * which contains groups of radio buttons
  64365. */
  64366. export class RadioGroup extends SelectorGroup {
  64367. private _selectNb;
  64368. /** Adds a radio button as a control
  64369. * @param label is the label for the selector
  64370. * @param func is the function called when the Selector is checked
  64371. * @param checked is true when Selector is checked
  64372. */
  64373. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  64374. /** @hidden */
  64375. _setSelectorLabel(selectorNb: number, label: string): void;
  64376. /** @hidden */
  64377. _setSelectorLabelColor(selectorNb: number, color: string): void;
  64378. /** @hidden */
  64379. _setSelectorButtonColor(selectorNb: number, color: string): void;
  64380. /** @hidden */
  64381. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  64382. }
  64383. /** Class used to create a SliderGroup
  64384. * which contains groups of slider buttons
  64385. */
  64386. export class SliderGroup extends SelectorGroup {
  64387. /**
  64388. * Adds a slider to the SelectorGroup
  64389. * @param label is the label for the SliderBar
  64390. * @param func is the function called when the Slider moves
  64391. * @param unit is a string describing the units used, eg degrees or metres
  64392. * @param min is the minimum value for the Slider
  64393. * @param max is the maximum value for the Slider
  64394. * @param value is the start value for the Slider between min and max
  64395. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  64396. */
  64397. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  64398. /** @hidden */
  64399. _setSelectorLabel(selectorNb: number, label: string): void;
  64400. /** @hidden */
  64401. _setSelectorLabelColor(selectorNb: number, color: string): void;
  64402. /** @hidden */
  64403. _setSelectorButtonColor(selectorNb: number, color: string): void;
  64404. /** @hidden */
  64405. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  64406. }
  64407. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  64408. * @see http://doc.babylonjs.com/how_to/selector
  64409. */
  64410. export class SelectionPanel extends Rectangle {
  64411. /** name of SelectionPanel */
  64412. name: string;
  64413. /** an array of SelectionGroups */
  64414. groups: SelectorGroup[];
  64415. private _panel;
  64416. private _buttonColor;
  64417. private _buttonBackground;
  64418. private _headerColor;
  64419. private _barColor;
  64420. private _barHeight;
  64421. private _spacerHeight;
  64422. private _labelColor;
  64423. private _groups;
  64424. private _bars;
  64425. /**
  64426. * Creates a new SelectionPanel
  64427. * @param name of SelectionPanel
  64428. * @param groups is an array of SelectionGroups
  64429. */
  64430. constructor(
  64431. /** name of SelectionPanel */
  64432. name: string,
  64433. /** an array of SelectionGroups */
  64434. groups?: SelectorGroup[]);
  64435. protected _getTypeName(): string;
  64436. /** Gets or sets the headerColor */
  64437. headerColor: string;
  64438. private _setHeaderColor;
  64439. /** Gets or sets the button color */
  64440. buttonColor: string;
  64441. private _setbuttonColor;
  64442. /** Gets or sets the label color */
  64443. labelColor: string;
  64444. private _setLabelColor;
  64445. /** Gets or sets the button background */
  64446. buttonBackground: string;
  64447. private _setButtonBackground;
  64448. /** Gets or sets the color of separator bar */
  64449. barColor: string;
  64450. private _setBarColor;
  64451. /** Gets or sets the height of separator bar */
  64452. barHeight: string;
  64453. private _setBarHeight;
  64454. /** Gets or sets the height of spacers*/
  64455. spacerHeight: string;
  64456. private _setSpacerHeight;
  64457. /** Adds a bar between groups */
  64458. private _addSpacer;
  64459. /** Add a group to the selection panel
  64460. * @param group is the selector group to add
  64461. */
  64462. addGroup(group: SelectorGroup): void;
  64463. /** Remove the group from the given position
  64464. * @param groupNb is the position of the group in the list
  64465. */
  64466. removeGroup(groupNb: number): void;
  64467. /** Change a group header label
  64468. * @param label is the new group header label
  64469. * @param groupNb is the number of the group to relabel
  64470. * */
  64471. setHeaderName(label: string, groupNb: number): void;
  64472. /** Change selector label to the one given
  64473. * @param label is the new selector label
  64474. * @param groupNb is the number of the groupcontaining the selector
  64475. * @param selectorNb is the number of the selector within a group to relabel
  64476. * */
  64477. relabel(label: string, groupNb: number, selectorNb: number): void;
  64478. /** For a given group position remove the selector at the given position
  64479. * @param groupNb is the number of the group to remove the selector from
  64480. * @param selectorNb is the number of the selector within the group
  64481. */
  64482. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  64483. /** For a given group position of correct type add a checkbox button
  64484. * @param groupNb is the number of the group to remove the selector from
  64485. * @param label is the label for the selector
  64486. * @param func is the function called when the Selector is checked
  64487. * @param checked is true when Selector is checked
  64488. */
  64489. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  64490. /** For a given group position of correct type add a radio button
  64491. * @param groupNb is the number of the group to remove the selector from
  64492. * @param label is the label for the selector
  64493. * @param func is the function called when the Selector is checked
  64494. * @param checked is true when Selector is checked
  64495. */
  64496. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  64497. /**
  64498. * For a given slider group add a slider
  64499. * @param groupNb is the number of the group to add the slider to
  64500. * @param label is the label for the Slider
  64501. * @param func is the function called when the Slider moves
  64502. * @param unit is a string describing the units used, eg degrees or metres
  64503. * @param min is the minimum value for the Slider
  64504. * @param max is the maximum value for the Slider
  64505. * @param value is the start value for the Slider between min and max
  64506. * @param onVal is the function used to format the value displayed, eg radians to degrees
  64507. */
  64508. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  64509. }
  64510. }
  64511. declare module BABYLON.GUI {
  64512. /**
  64513. * Class used to hold a the container for ScrollViewer
  64514. * @hidden
  64515. */
  64516. export class _ScrollViewerWindow extends Container {
  64517. parentClientWidth: number;
  64518. parentClientHeight: number;
  64519. /**
  64520. * Creates a new ScrollViewerWindow
  64521. * @param name of ScrollViewerWindow
  64522. */
  64523. constructor(name?: string);
  64524. protected _getTypeName(): string;
  64525. /** @hidden */
  64526. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64527. protected _postMeasure(): void;
  64528. }
  64529. }
  64530. declare module BABYLON.GUI {
  64531. /**
  64532. * Class used to create slider controls
  64533. */
  64534. export class ScrollBar extends BaseSlider {
  64535. name?: string | undefined;
  64536. private _background;
  64537. private _borderColor;
  64538. private _thumbMeasure;
  64539. /** Gets or sets border color */
  64540. borderColor: string;
  64541. /** Gets or sets background color */
  64542. background: string;
  64543. /**
  64544. * Creates a new Slider
  64545. * @param name defines the control name
  64546. */
  64547. constructor(name?: string | undefined);
  64548. protected _getTypeName(): string;
  64549. protected _getThumbThickness(): number;
  64550. _draw(context: CanvasRenderingContext2D): void;
  64551. private _first;
  64552. private _originX;
  64553. private _originY;
  64554. /** @hidden */
  64555. protected _updateValueFromPointer(x: number, y: number): void;
  64556. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64557. }
  64558. }
  64559. declare module BABYLON.GUI {
  64560. /**
  64561. * Class used to hold a viewer window and sliders in a grid
  64562. */
  64563. export class ScrollViewer extends Rectangle {
  64564. private _grid;
  64565. private _horizontalBarSpace;
  64566. private _verticalBarSpace;
  64567. private _dragSpace;
  64568. private _horizontalBar;
  64569. private _verticalBar;
  64570. private _barColor;
  64571. private _barBackground;
  64572. private _barSize;
  64573. private _endLeft;
  64574. private _endTop;
  64575. private _window;
  64576. private _pointerIsOver;
  64577. private _wheelPrecision;
  64578. private _onPointerObserver;
  64579. private _clientWidth;
  64580. private _clientHeight;
  64581. /**
  64582. * Gets the horizontal scrollbar
  64583. */
  64584. readonly horizontalBar: ScrollBar;
  64585. /**
  64586. * Gets the vertical scrollbar
  64587. */
  64588. readonly verticalBar: ScrollBar;
  64589. /**
  64590. * Adds a new control to the current container
  64591. * @param control defines the control to add
  64592. * @returns the current container
  64593. */
  64594. addControl(control: BABYLON.Nullable<Control>): Container;
  64595. /**
  64596. * Removes a control from the current container
  64597. * @param control defines the control to remove
  64598. * @returns the current container
  64599. */
  64600. removeControl(control: Control): Container;
  64601. /** Gets the list of children */
  64602. readonly children: Control[];
  64603. _flagDescendantsAsMatrixDirty(): void;
  64604. /**
  64605. * Creates a new ScrollViewer
  64606. * @param name of ScrollViewer
  64607. */
  64608. constructor(name?: string);
  64609. /** Reset the scroll viewer window to initial size */
  64610. resetWindow(): void;
  64611. protected _getTypeName(): string;
  64612. private _buildClientSizes;
  64613. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64614. protected _postMeasure(): void;
  64615. /**
  64616. * Gets or sets the mouse wheel precision
  64617. * from 0 to 1 with a default value of 0.05
  64618. * */
  64619. wheelPrecision: number;
  64620. /** Gets or sets the bar color */
  64621. barColor: string;
  64622. /** Gets or sets the size of the bar */
  64623. barSize: number;
  64624. /** Gets or sets the bar background */
  64625. barBackground: string;
  64626. /** @hidden */
  64627. private _updateScroller;
  64628. _link(host: AdvancedDynamicTexture): void;
  64629. /** @hidden */
  64630. private _attachWheel;
  64631. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64632. /** Releases associated resources */
  64633. dispose(): void;
  64634. }
  64635. }
  64636. declare module BABYLON.GUI {
  64637. /** Class used to render a grid */
  64638. export class DisplayGrid extends Control {
  64639. name?: string | undefined;
  64640. private _cellWidth;
  64641. private _cellHeight;
  64642. private _minorLineTickness;
  64643. private _minorLineColor;
  64644. private _majorLineTickness;
  64645. private _majorLineColor;
  64646. private _majorLineFrequency;
  64647. private _background;
  64648. private _displayMajorLines;
  64649. private _displayMinorLines;
  64650. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  64651. displayMinorLines: boolean;
  64652. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  64653. displayMajorLines: boolean;
  64654. /** Gets or sets background color (Black by default) */
  64655. background: string;
  64656. /** Gets or sets the width of each cell (20 by default) */
  64657. cellWidth: number;
  64658. /** Gets or sets the height of each cell (20 by default) */
  64659. cellHeight: number;
  64660. /** Gets or sets the tickness of minor lines (1 by default) */
  64661. minorLineTickness: number;
  64662. /** Gets or sets the color of minor lines (DarkGray by default) */
  64663. minorLineColor: string;
  64664. /** Gets or sets the tickness of major lines (2 by default) */
  64665. majorLineTickness: number;
  64666. /** Gets or sets the color of major lines (White by default) */
  64667. majorLineColor: string;
  64668. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  64669. majorLineFrequency: number;
  64670. /**
  64671. * Creates a new GridDisplayRectangle
  64672. * @param name defines the control name
  64673. */
  64674. constructor(name?: string | undefined);
  64675. _draw(context: CanvasRenderingContext2D): void;
  64676. protected _getTypeName(): string;
  64677. }
  64678. }
  64679. declare module BABYLON.GUI {
  64680. /**
  64681. * Class used to create slider controls based on images
  64682. */
  64683. export class ImageBasedSlider extends BaseSlider {
  64684. name?: string | undefined;
  64685. private _backgroundImage;
  64686. private _thumbImage;
  64687. private _valueBarImage;
  64688. private _tempMeasure;
  64689. displayThumb: boolean;
  64690. /**
  64691. * Gets or sets the image used to render the background
  64692. */
  64693. backgroundImage: Image;
  64694. /**
  64695. * Gets or sets the image used to render the value bar
  64696. */
  64697. valueBarImage: Image;
  64698. /**
  64699. * Gets or sets the image used to render the thumb
  64700. */
  64701. thumbImage: Image;
  64702. /**
  64703. * Creates a new ImageBasedSlider
  64704. * @param name defines the control name
  64705. */
  64706. constructor(name?: string | undefined);
  64707. protected _getTypeName(): string;
  64708. _draw(context: CanvasRenderingContext2D): void;
  64709. }
  64710. }
  64711. declare module BABYLON.GUI {
  64712. /**
  64713. * Forcing an export so that this code will execute
  64714. * @hidden
  64715. */
  64716. const name = "Statics";
  64717. }
  64718. declare module BABYLON.GUI {
  64719. /**
  64720. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  64721. */
  64722. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  64723. /**
  64724. * Define the instrumented AdvancedDynamicTexture.
  64725. */
  64726. texture: AdvancedDynamicTexture;
  64727. private _captureRenderTime;
  64728. private _renderTime;
  64729. private _captureLayoutTime;
  64730. private _layoutTime;
  64731. private _onBeginRenderObserver;
  64732. private _onEndRenderObserver;
  64733. private _onBeginLayoutObserver;
  64734. private _onEndLayoutObserver;
  64735. /**
  64736. * Gets the perf counter used to capture render time
  64737. */
  64738. readonly renderTimeCounter: BABYLON.PerfCounter;
  64739. /**
  64740. * Gets the perf counter used to capture layout time
  64741. */
  64742. readonly layoutTimeCounter: BABYLON.PerfCounter;
  64743. /**
  64744. * Enable or disable the render time capture
  64745. */
  64746. captureRenderTime: boolean;
  64747. /**
  64748. * Enable or disable the layout time capture
  64749. */
  64750. captureLayoutTime: boolean;
  64751. /**
  64752. * Instantiates a new advanced dynamic texture instrumentation.
  64753. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  64754. * @param texture Defines the AdvancedDynamicTexture to instrument
  64755. */
  64756. constructor(
  64757. /**
  64758. * Define the instrumented AdvancedDynamicTexture.
  64759. */
  64760. texture: AdvancedDynamicTexture);
  64761. /**
  64762. * Dispose and release associated resources.
  64763. */
  64764. dispose(): void;
  64765. }
  64766. }
  64767. declare module BABYLON.GUI {
  64768. /**
  64769. * Class used to create containers for controls
  64770. */
  64771. export class Container3D extends Control3D {
  64772. private _blockLayout;
  64773. /**
  64774. * Gets the list of child controls
  64775. */
  64776. protected _children: Control3D[];
  64777. /**
  64778. * Gets the list of child controls
  64779. */
  64780. readonly children: Array<Control3D>;
  64781. /**
  64782. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  64783. * This is helpful to optimize layout operation when adding multiple children in a row
  64784. */
  64785. blockLayout: boolean;
  64786. /**
  64787. * Creates a new container
  64788. * @param name defines the container name
  64789. */
  64790. constructor(name?: string);
  64791. /**
  64792. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  64793. * @returns the current container
  64794. */
  64795. updateLayout(): Container3D;
  64796. /**
  64797. * Gets a boolean indicating if the given control is in the children of this control
  64798. * @param control defines the control to check
  64799. * @returns true if the control is in the child list
  64800. */
  64801. containsControl(control: Control3D): boolean;
  64802. /**
  64803. * Adds a control to the children of this control
  64804. * @param control defines the control to add
  64805. * @returns the current container
  64806. */
  64807. addControl(control: Control3D): Container3D;
  64808. /**
  64809. * This function will be called everytime a new control is added
  64810. */
  64811. protected _arrangeChildren(): void;
  64812. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  64813. /**
  64814. * Removes a control from the children of this control
  64815. * @param control defines the control to remove
  64816. * @returns the current container
  64817. */
  64818. removeControl(control: Control3D): Container3D;
  64819. protected _getTypeName(): string;
  64820. /**
  64821. * Releases all associated resources
  64822. */
  64823. dispose(): void;
  64824. /** Control rotation will remain unchanged */
  64825. static readonly UNSET_ORIENTATION: number;
  64826. /** Control will rotate to make it look at sphere central axis */
  64827. static readonly FACEORIGIN_ORIENTATION: number;
  64828. /** Control will rotate to make it look back at sphere central axis */
  64829. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  64830. /** Control will rotate to look at z axis (0, 0, 1) */
  64831. static readonly FACEFORWARD_ORIENTATION: number;
  64832. /** Control will rotate to look at negative z axis (0, 0, -1) */
  64833. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  64834. }
  64835. }
  64836. declare module BABYLON.GUI {
  64837. /**
  64838. * Class used to manage 3D user interface
  64839. * @see http://doc.babylonjs.com/how_to/gui3d
  64840. */
  64841. export class GUI3DManager implements BABYLON.IDisposable {
  64842. private _scene;
  64843. private _sceneDisposeObserver;
  64844. private _utilityLayer;
  64845. private _rootContainer;
  64846. private _pointerObserver;
  64847. private _pointerOutObserver;
  64848. /** @hidden */
  64849. _lastPickedControl: Control3D;
  64850. /** @hidden */
  64851. _lastControlOver: {
  64852. [pointerId: number]: Control3D;
  64853. };
  64854. /** @hidden */
  64855. _lastControlDown: {
  64856. [pointerId: number]: Control3D;
  64857. };
  64858. /**
  64859. * BABYLON.Observable raised when the point picked by the pointer events changed
  64860. */
  64861. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  64862. /** @hidden */
  64863. _sharedMaterials: {
  64864. [key: string]: BABYLON.Material;
  64865. };
  64866. /** Gets the hosting scene */
  64867. readonly scene: BABYLON.Scene;
  64868. /** Gets associated utility layer */
  64869. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  64870. /**
  64871. * Creates a new GUI3DManager
  64872. * @param scene
  64873. */
  64874. constructor(scene?: BABYLON.Scene);
  64875. private _handlePointerOut;
  64876. private _doPicking;
  64877. /**
  64878. * Gets the root container
  64879. */
  64880. readonly rootContainer: Container3D;
  64881. /**
  64882. * Gets a boolean indicating if the given control is in the root child list
  64883. * @param control defines the control to check
  64884. * @returns true if the control is in the root child list
  64885. */
  64886. containsControl(control: Control3D): boolean;
  64887. /**
  64888. * Adds a control to the root child list
  64889. * @param control defines the control to add
  64890. * @returns the current manager
  64891. */
  64892. addControl(control: Control3D): GUI3DManager;
  64893. /**
  64894. * Removes a control from the root child list
  64895. * @param control defines the control to remove
  64896. * @returns the current container
  64897. */
  64898. removeControl(control: Control3D): GUI3DManager;
  64899. /**
  64900. * Releases all associated resources
  64901. */
  64902. dispose(): void;
  64903. }
  64904. }
  64905. declare module BABYLON.GUI {
  64906. /**
  64907. * Class used to transport BABYLON.Vector3 information for pointer events
  64908. */
  64909. export class Vector3WithInfo extends BABYLON.Vector3 {
  64910. /** defines the current mouse button index */
  64911. buttonIndex: number;
  64912. /**
  64913. * Creates a new Vector3WithInfo
  64914. * @param source defines the vector3 data to transport
  64915. * @param buttonIndex defines the current mouse button index
  64916. */
  64917. constructor(source: BABYLON.Vector3,
  64918. /** defines the current mouse button index */
  64919. buttonIndex?: number);
  64920. }
  64921. }
  64922. declare module BABYLON.GUI {
  64923. /**
  64924. * Class used as base class for controls
  64925. */
  64926. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  64927. /** Defines the control name */
  64928. name?: string | undefined;
  64929. /** @hidden */
  64930. _host: GUI3DManager;
  64931. private _node;
  64932. private _downCount;
  64933. private _enterCount;
  64934. private _downPointerIds;
  64935. private _isVisible;
  64936. /** Gets or sets the control position in world space */
  64937. position: BABYLON.Vector3;
  64938. /** Gets or sets the control scaling in world space */
  64939. scaling: BABYLON.Vector3;
  64940. /** Callback used to start pointer enter animation */
  64941. pointerEnterAnimation: () => void;
  64942. /** Callback used to start pointer out animation */
  64943. pointerOutAnimation: () => void;
  64944. /** Callback used to start pointer down animation */
  64945. pointerDownAnimation: () => void;
  64946. /** Callback used to start pointer up animation */
  64947. pointerUpAnimation: () => void;
  64948. /**
  64949. * An event triggered when the pointer move over the control
  64950. */
  64951. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  64952. /**
  64953. * An event triggered when the pointer move out of the control
  64954. */
  64955. onPointerOutObservable: BABYLON.Observable<Control3D>;
  64956. /**
  64957. * An event triggered when the pointer taps the control
  64958. */
  64959. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  64960. /**
  64961. * An event triggered when pointer is up
  64962. */
  64963. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  64964. /**
  64965. * An event triggered when a control is clicked on (with a mouse)
  64966. */
  64967. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  64968. /**
  64969. * An event triggered when pointer enters the control
  64970. */
  64971. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  64972. /**
  64973. * Gets or sets the parent container
  64974. */
  64975. parent: BABYLON.Nullable<Container3D>;
  64976. private _behaviors;
  64977. /**
  64978. * Gets the list of attached behaviors
  64979. * @see http://doc.babylonjs.com/features/behaviour
  64980. */
  64981. readonly behaviors: BABYLON.Behavior<Control3D>[];
  64982. /**
  64983. * Attach a behavior to the control
  64984. * @see http://doc.babylonjs.com/features/behaviour
  64985. * @param behavior defines the behavior to attach
  64986. * @returns the current control
  64987. */
  64988. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  64989. /**
  64990. * Remove an attached behavior
  64991. * @see http://doc.babylonjs.com/features/behaviour
  64992. * @param behavior defines the behavior to attach
  64993. * @returns the current control
  64994. */
  64995. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  64996. /**
  64997. * Gets an attached behavior by name
  64998. * @param name defines the name of the behavior to look for
  64999. * @see http://doc.babylonjs.com/features/behaviour
  65000. * @returns null if behavior was not found else the requested behavior
  65001. */
  65002. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  65003. /** Gets or sets a boolean indicating if the control is visible */
  65004. isVisible: boolean;
  65005. /**
  65006. * Creates a new control
  65007. * @param name defines the control name
  65008. */
  65009. constructor(
  65010. /** Defines the control name */
  65011. name?: string | undefined);
  65012. /**
  65013. * Gets a string representing the class name
  65014. */
  65015. readonly typeName: string;
  65016. /**
  65017. * Get the current class name of the control.
  65018. * @returns current class name
  65019. */
  65020. getClassName(): string;
  65021. protected _getTypeName(): string;
  65022. /**
  65023. * Gets the transform node used by this control
  65024. */
  65025. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  65026. /**
  65027. * Gets the mesh used to render this control
  65028. */
  65029. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65030. /**
  65031. * Link the control as child of the given node
  65032. * @param node defines the node to link to. Use null to unlink the control
  65033. * @returns the current control
  65034. */
  65035. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  65036. /** @hidden **/
  65037. _prepareNode(scene: BABYLON.Scene): void;
  65038. /**
  65039. * Node creation.
  65040. * Can be overriden by children
  65041. * @param scene defines the scene where the node must be attached
  65042. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  65043. */
  65044. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  65045. /**
  65046. * Affect a material to the given mesh
  65047. * @param mesh defines the mesh which will represent the control
  65048. */
  65049. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  65050. /** @hidden */
  65051. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  65052. /** @hidden */
  65053. _onPointerEnter(target: Control3D): boolean;
  65054. /** @hidden */
  65055. _onPointerOut(target: Control3D): void;
  65056. /** @hidden */
  65057. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  65058. /** @hidden */
  65059. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65060. /** @hidden */
  65061. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  65062. /** @hidden */
  65063. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  65064. /** @hidden */
  65065. _disposeNode(): void;
  65066. /**
  65067. * Releases all associated resources
  65068. */
  65069. dispose(): void;
  65070. }
  65071. }
  65072. declare module BABYLON.GUI {
  65073. /**
  65074. * Class used as a root to all buttons
  65075. */
  65076. export class AbstractButton3D extends Control3D {
  65077. /**
  65078. * Creates a new button
  65079. * @param name defines the control name
  65080. */
  65081. constructor(name?: string);
  65082. protected _getTypeName(): string;
  65083. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65084. }
  65085. }
  65086. declare module BABYLON.GUI {
  65087. /**
  65088. * Class used to create a button in 3D
  65089. */
  65090. export class Button3D extends AbstractButton3D {
  65091. /** @hidden */
  65092. protected _currentMaterial: BABYLON.Material;
  65093. private _facadeTexture;
  65094. private _content;
  65095. private _contentResolution;
  65096. private _contentScaleRatio;
  65097. /**
  65098. * Gets or sets the texture resolution used to render content (512 by default)
  65099. */
  65100. contentResolution: BABYLON.int;
  65101. /**
  65102. * Gets or sets the texture scale ratio used to render content (2 by default)
  65103. */
  65104. contentScaleRatio: number;
  65105. protected _disposeFacadeTexture(): void;
  65106. protected _resetContent(): void;
  65107. /**
  65108. * Creates a new button
  65109. * @param name defines the control name
  65110. */
  65111. constructor(name?: string);
  65112. /**
  65113. * Gets or sets the GUI 2D content used to display the button's facade
  65114. */
  65115. content: Control;
  65116. /**
  65117. * Apply the facade texture (created from the content property).
  65118. * This function can be overloaded by child classes
  65119. * @param facadeTexture defines the AdvancedDynamicTexture to use
  65120. */
  65121. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  65122. protected _getTypeName(): string;
  65123. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65124. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  65125. /**
  65126. * Releases all associated resources
  65127. */
  65128. dispose(): void;
  65129. }
  65130. }
  65131. declare module BABYLON.GUI {
  65132. /**
  65133. * Abstract class used to create a container panel deployed on the surface of a volume
  65134. */
  65135. export abstract class VolumeBasedPanel extends Container3D {
  65136. private _columns;
  65137. private _rows;
  65138. private _rowThenColum;
  65139. private _orientation;
  65140. protected _cellWidth: number;
  65141. protected _cellHeight: number;
  65142. /**
  65143. * Gets or sets the distance between elements
  65144. */
  65145. margin: number;
  65146. /**
  65147. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  65148. * | Value | Type | Description |
  65149. * | ----- | ----------------------------------- | ----------- |
  65150. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  65151. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  65152. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  65153. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  65154. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  65155. */
  65156. orientation: number;
  65157. /**
  65158. * Gets or sets the number of columns requested (10 by default).
  65159. * The panel will automatically compute the number of rows based on number of child controls.
  65160. */
  65161. columns: BABYLON.int;
  65162. /**
  65163. * Gets or sets a the number of rows requested.
  65164. * The panel will automatically compute the number of columns based on number of child controls.
  65165. */
  65166. rows: BABYLON.int;
  65167. /**
  65168. * Creates new VolumeBasedPanel
  65169. */
  65170. constructor();
  65171. protected _arrangeChildren(): void;
  65172. /** Child classes must implement this function to provide correct control positioning */
  65173. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65174. /** Child classes can implement this function to provide additional processing */
  65175. protected _finalProcessing(): void;
  65176. }
  65177. }
  65178. declare module BABYLON.GUI {
  65179. /**
  65180. * Class used to create a container panel deployed on the surface of a cylinder
  65181. */
  65182. export class CylinderPanel extends VolumeBasedPanel {
  65183. private _radius;
  65184. /**
  65185. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  65186. */
  65187. radius: BABYLON.float;
  65188. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65189. private _cylindricalMapping;
  65190. }
  65191. }
  65192. declare module BABYLON.GUI {
  65193. /** @hidden */
  65194. export var fluentVertexShader: {
  65195. name: string;
  65196. shader: string;
  65197. };
  65198. }
  65199. declare module BABYLON.GUI {
  65200. /** @hidden */
  65201. export var fluentPixelShader: {
  65202. name: string;
  65203. shader: string;
  65204. };
  65205. }
  65206. declare module BABYLON.GUI {
  65207. /** @hidden */
  65208. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  65209. INNERGLOW: boolean;
  65210. BORDER: boolean;
  65211. HOVERLIGHT: boolean;
  65212. TEXTURE: boolean;
  65213. constructor();
  65214. }
  65215. /**
  65216. * Class used to render controls with fluent desgin
  65217. */
  65218. export class FluentMaterial extends BABYLON.PushMaterial {
  65219. /**
  65220. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  65221. */
  65222. innerGlowColorIntensity: number;
  65223. /**
  65224. * Gets or sets the inner glow color (white by default)
  65225. */
  65226. innerGlowColor: BABYLON.Color3;
  65227. /**
  65228. * Gets or sets alpha value (default is 1.0)
  65229. */
  65230. alpha: number;
  65231. /**
  65232. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  65233. */
  65234. albedoColor: BABYLON.Color3;
  65235. /**
  65236. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  65237. */
  65238. renderBorders: boolean;
  65239. /**
  65240. * Gets or sets border width (default is 0.5)
  65241. */
  65242. borderWidth: number;
  65243. /**
  65244. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  65245. */
  65246. edgeSmoothingValue: number;
  65247. /**
  65248. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  65249. */
  65250. borderMinValue: number;
  65251. /**
  65252. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  65253. */
  65254. renderHoverLight: boolean;
  65255. /**
  65256. * Gets or sets the radius used to render the hover light (default is 1.0)
  65257. */
  65258. hoverRadius: number;
  65259. /**
  65260. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  65261. */
  65262. hoverColor: BABYLON.Color4;
  65263. /**
  65264. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  65265. */
  65266. hoverPosition: BABYLON.Vector3;
  65267. private _albedoTexture;
  65268. /** Gets or sets the texture to use for albedo color */
  65269. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  65270. /**
  65271. * Creates a new Fluent material
  65272. * @param name defines the name of the material
  65273. * @param scene defines the hosting scene
  65274. */
  65275. constructor(name: string, scene: BABYLON.Scene);
  65276. needAlphaBlending(): boolean;
  65277. needAlphaTesting(): boolean;
  65278. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  65279. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  65280. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  65281. getActiveTextures(): BABYLON.BaseTexture[];
  65282. hasTexture(texture: BABYLON.BaseTexture): boolean;
  65283. dispose(forceDisposeEffect?: boolean): void;
  65284. clone(name: string): FluentMaterial;
  65285. serialize(): any;
  65286. getClassName(): string;
  65287. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  65288. }
  65289. }
  65290. declare module BABYLON.GUI {
  65291. /**
  65292. * Class used to create a holographic button in 3D
  65293. */
  65294. export class HolographicButton extends Button3D {
  65295. private _backPlate;
  65296. private _textPlate;
  65297. private _frontPlate;
  65298. private _text;
  65299. private _imageUrl;
  65300. private _shareMaterials;
  65301. private _frontMaterial;
  65302. private _backMaterial;
  65303. private _plateMaterial;
  65304. private _pickedPointObserver;
  65305. private _tooltipFade;
  65306. private _tooltipTextBlock;
  65307. private _tooltipTexture;
  65308. private _tooltipMesh;
  65309. private _tooltipHoverObserver;
  65310. private _tooltipOutObserver;
  65311. private _disposeTooltip;
  65312. /**
  65313. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  65314. */
  65315. tooltipText: BABYLON.Nullable<string>;
  65316. /**
  65317. * Gets or sets text for the button
  65318. */
  65319. text: string;
  65320. /**
  65321. * Gets or sets the image url for the button
  65322. */
  65323. imageUrl: string;
  65324. /**
  65325. * Gets the back material used by this button
  65326. */
  65327. readonly backMaterial: FluentMaterial;
  65328. /**
  65329. * Gets the front material used by this button
  65330. */
  65331. readonly frontMaterial: FluentMaterial;
  65332. /**
  65333. * Gets the plate material used by this button
  65334. */
  65335. readonly plateMaterial: BABYLON.StandardMaterial;
  65336. /**
  65337. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  65338. */
  65339. readonly shareMaterials: boolean;
  65340. /**
  65341. * Creates a new button
  65342. * @param name defines the control name
  65343. */
  65344. constructor(name?: string, shareMaterials?: boolean);
  65345. protected _getTypeName(): string;
  65346. private _rebuildContent;
  65347. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65348. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  65349. private _createBackMaterial;
  65350. private _createFrontMaterial;
  65351. private _createPlateMaterial;
  65352. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  65353. /**
  65354. * Releases all associated resources
  65355. */
  65356. dispose(): void;
  65357. }
  65358. }
  65359. declare module BABYLON.GUI {
  65360. /**
  65361. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  65362. */
  65363. export class MeshButton3D extends Button3D {
  65364. /** @hidden */
  65365. protected _currentMesh: BABYLON.Mesh;
  65366. /**
  65367. * Creates a new 3D button based on a mesh
  65368. * @param mesh mesh to become a 3D button
  65369. * @param name defines the control name
  65370. */
  65371. constructor(mesh: BABYLON.Mesh, name?: string);
  65372. protected _getTypeName(): string;
  65373. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65374. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  65375. }
  65376. }
  65377. declare module BABYLON.GUI {
  65378. /**
  65379. * Class used to create a container panel deployed on the surface of a plane
  65380. */
  65381. export class PlanePanel extends VolumeBasedPanel {
  65382. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65383. }
  65384. }
  65385. declare module BABYLON.GUI {
  65386. /**
  65387. * Class used to create a container panel where items get randomized planar mapping
  65388. */
  65389. export class ScatterPanel extends VolumeBasedPanel {
  65390. private _iteration;
  65391. /**
  65392. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  65393. */
  65394. iteration: BABYLON.float;
  65395. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65396. private _scatterMapping;
  65397. protected _finalProcessing(): void;
  65398. }
  65399. }
  65400. declare module BABYLON.GUI {
  65401. /**
  65402. * Class used to create a container panel deployed on the surface of a sphere
  65403. */
  65404. export class SpherePanel extends VolumeBasedPanel {
  65405. private _radius;
  65406. /**
  65407. * Gets or sets the radius of the sphere where to project controls (5 by default)
  65408. */
  65409. radius: BABYLON.float;
  65410. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65411. private _sphericalMapping;
  65412. }
  65413. }
  65414. declare module BABYLON.GUI {
  65415. /**
  65416. * Class used to create a stack panel in 3D on XY plane
  65417. */
  65418. export class StackPanel3D extends Container3D {
  65419. private _isVertical;
  65420. /**
  65421. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  65422. */
  65423. isVertical: boolean;
  65424. /**
  65425. * Gets or sets the distance between elements
  65426. */
  65427. margin: number;
  65428. /**
  65429. * Creates new StackPanel
  65430. * @param isVertical
  65431. */
  65432. constructor(isVertical?: boolean);
  65433. protected _arrangeChildren(): void;
  65434. }
  65435. }
  65436. declare module BABYLON {
  65437. /**
  65438. * Mode that determines the coordinate system to use.
  65439. */
  65440. export enum GLTFLoaderCoordinateSystemMode {
  65441. /**
  65442. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  65443. */
  65444. AUTO = 0,
  65445. /**
  65446. * Sets the useRightHandedSystem flag on the scene.
  65447. */
  65448. FORCE_RIGHT_HANDED = 1
  65449. }
  65450. /**
  65451. * Mode that determines what animations will start.
  65452. */
  65453. export enum GLTFLoaderAnimationStartMode {
  65454. /**
  65455. * No animation will start.
  65456. */
  65457. NONE = 0,
  65458. /**
  65459. * The first animation will start.
  65460. */
  65461. FIRST = 1,
  65462. /**
  65463. * All animations will start.
  65464. */
  65465. ALL = 2
  65466. }
  65467. /**
  65468. * Interface that contains the data for the glTF asset.
  65469. */
  65470. export interface IGLTFLoaderData {
  65471. /**
  65472. * Object that represents the glTF JSON.
  65473. */
  65474. json: Object;
  65475. /**
  65476. * The BIN chunk of a binary glTF.
  65477. */
  65478. bin: Nullable<ArrayBufferView>;
  65479. }
  65480. /**
  65481. * Interface for extending the loader.
  65482. */
  65483. export interface IGLTFLoaderExtension {
  65484. /**
  65485. * The name of this extension.
  65486. */
  65487. readonly name: string;
  65488. /**
  65489. * Defines whether this extension is enabled.
  65490. */
  65491. enabled: boolean;
  65492. }
  65493. /**
  65494. * Loader state.
  65495. */
  65496. export enum GLTFLoaderState {
  65497. /**
  65498. * The asset is loading.
  65499. */
  65500. LOADING = 0,
  65501. /**
  65502. * The asset is ready for rendering.
  65503. */
  65504. READY = 1,
  65505. /**
  65506. * The asset is completely loaded.
  65507. */
  65508. COMPLETE = 2
  65509. }
  65510. /** @hidden */
  65511. export interface IGLTFLoader extends IDisposable {
  65512. readonly state: Nullable<GLTFLoaderState>;
  65513. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  65514. meshes: AbstractMesh[];
  65515. particleSystems: IParticleSystem[];
  65516. skeletons: Skeleton[];
  65517. animationGroups: AnimationGroup[];
  65518. }>;
  65519. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  65520. }
  65521. /**
  65522. * File loader for loading glTF files into a scene.
  65523. */
  65524. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  65525. /** @hidden */
  65526. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  65527. /** @hidden */
  65528. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  65529. /**
  65530. * Raised when the asset has been parsed
  65531. */
  65532. onParsedObservable: Observable<IGLTFLoaderData>;
  65533. private _onParsedObserver;
  65534. /**
  65535. * Raised when the asset has been parsed
  65536. */
  65537. onParsed: (loaderData: IGLTFLoaderData) => void;
  65538. /**
  65539. * 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.
  65540. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  65541. * Defaults to true.
  65542. * @hidden
  65543. */
  65544. static IncrementalLoading: boolean;
  65545. /**
  65546. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  65547. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  65548. * @hidden
  65549. */
  65550. static HomogeneousCoordinates: boolean;
  65551. /**
  65552. * The coordinate system mode. Defaults to AUTO.
  65553. */
  65554. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  65555. /**
  65556. * The animation start mode. Defaults to FIRST.
  65557. */
  65558. animationStartMode: GLTFLoaderAnimationStartMode;
  65559. /**
  65560. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  65561. */
  65562. compileMaterials: boolean;
  65563. /**
  65564. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  65565. */
  65566. useClipPlane: boolean;
  65567. /**
  65568. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  65569. */
  65570. compileShadowGenerators: boolean;
  65571. /**
  65572. * Defines if the Alpha blended materials are only applied as coverage.
  65573. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  65574. * If true, no extra effects are applied to transparent pixels.
  65575. */
  65576. transparencyAsCoverage: boolean;
  65577. /**
  65578. * Function called before loading a url referenced by the asset.
  65579. */
  65580. preprocessUrlAsync: (url: string) => Promise<string>;
  65581. /**
  65582. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  65583. */
  65584. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  65585. private _onMeshLoadedObserver;
  65586. /**
  65587. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  65588. */
  65589. onMeshLoaded: (mesh: AbstractMesh) => void;
  65590. /**
  65591. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  65592. */
  65593. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  65594. private _onTextureLoadedObserver;
  65595. /**
  65596. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  65597. */
  65598. onTextureLoaded: (texture: BaseTexture) => void;
  65599. /**
  65600. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  65601. */
  65602. readonly onMaterialLoadedObservable: Observable<Material>;
  65603. private _onMaterialLoadedObserver;
  65604. /**
  65605. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  65606. */
  65607. onMaterialLoaded: (material: Material) => void;
  65608. /**
  65609. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  65610. */
  65611. readonly onCameraLoadedObservable: Observable<Camera>;
  65612. private _onCameraLoadedObserver;
  65613. /**
  65614. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  65615. */
  65616. onCameraLoaded: (camera: Camera) => void;
  65617. /**
  65618. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  65619. * For assets with LODs, raised when all of the LODs are complete.
  65620. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  65621. */
  65622. readonly onCompleteObservable: Observable<void>;
  65623. private _onCompleteObserver;
  65624. /**
  65625. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  65626. * For assets with LODs, raised when all of the LODs are complete.
  65627. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  65628. */
  65629. onComplete: () => void;
  65630. /**
  65631. * Observable raised when an error occurs.
  65632. */
  65633. readonly onErrorObservable: Observable<any>;
  65634. private _onErrorObserver;
  65635. /**
  65636. * Callback raised when an error occurs.
  65637. */
  65638. onError: (reason: any) => void;
  65639. /**
  65640. * Observable raised after the loader is disposed.
  65641. */
  65642. readonly onDisposeObservable: Observable<void>;
  65643. private _onDisposeObserver;
  65644. /**
  65645. * Callback raised after the loader is disposed.
  65646. */
  65647. onDispose: () => void;
  65648. /**
  65649. * Observable raised after a loader extension is created.
  65650. * Set additional options for a loader extension in this event.
  65651. */
  65652. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  65653. private _onExtensionLoadedObserver;
  65654. /**
  65655. * Callback raised after a loader extension is created.
  65656. */
  65657. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  65658. /**
  65659. * Defines if the loader logging is enabled.
  65660. */
  65661. loggingEnabled: boolean;
  65662. /**
  65663. * Defines if the loader should capture performance counters.
  65664. */
  65665. capturePerformanceCounters: boolean;
  65666. /**
  65667. * Defines if the loader should validate the asset.
  65668. */
  65669. validate: boolean;
  65670. /**
  65671. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  65672. */
  65673. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  65674. private _onValidatedObserver;
  65675. /**
  65676. * Callback raised after a loader extension is created.
  65677. */
  65678. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  65679. private _loader;
  65680. /**
  65681. * Name of the loader ("gltf")
  65682. */
  65683. name: string;
  65684. /**
  65685. * Supported file extensions of the loader (.gltf, .glb)
  65686. */
  65687. extensions: ISceneLoaderPluginExtensions;
  65688. /**
  65689. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  65690. */
  65691. dispose(): void;
  65692. /** @hidden */
  65693. _clear(): void;
  65694. /**
  65695. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  65696. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  65697. * @param scene the scene the meshes should be added to
  65698. * @param data the glTF data to load
  65699. * @param rootUrl root url to load from
  65700. * @param onProgress event that fires when loading progress has occured
  65701. * @param fileName Defines the name of the file to load
  65702. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  65703. */
  65704. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  65705. meshes: AbstractMesh[];
  65706. particleSystems: IParticleSystem[];
  65707. skeletons: Skeleton[];
  65708. animationGroups: AnimationGroup[];
  65709. }>;
  65710. /**
  65711. * Imports all objects from the loaded glTF data and adds them to the scene
  65712. * @param scene the scene the objects should be added to
  65713. * @param data the glTF data to load
  65714. * @param rootUrl root url to load from
  65715. * @param onProgress event that fires when loading progress has occured
  65716. * @param fileName Defines the name of the file to load
  65717. * @returns a promise which completes when objects have been loaded to the scene
  65718. */
  65719. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  65720. /**
  65721. * Load into an asset container.
  65722. * @param scene The scene to load into
  65723. * @param data The data to import
  65724. * @param rootUrl The root url for scene and resources
  65725. * @param onProgress The callback when the load progresses
  65726. * @param fileName Defines the name of the file to load
  65727. * @returns The loaded asset container
  65728. */
  65729. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  65730. /**
  65731. * If the data string can be loaded directly.
  65732. * @param data string contianing the file data
  65733. * @returns if the data can be loaded directly
  65734. */
  65735. canDirectLoad(data: string): boolean;
  65736. /**
  65737. * Rewrites a url by combining a root url and response url.
  65738. */
  65739. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  65740. /**
  65741. * Instantiates a glTF file loader plugin.
  65742. * @returns the created plugin
  65743. */
  65744. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  65745. /**
  65746. * The loader state or null if the loader is not active.
  65747. */
  65748. readonly loaderState: Nullable<GLTFLoaderState>;
  65749. /**
  65750. * Returns a promise that resolves when the asset is completely loaded.
  65751. * @returns a promise that resolves when the asset is completely loaded.
  65752. */
  65753. whenCompleteAsync(): Promise<void>;
  65754. private _parseAsync;
  65755. private _validateAsync;
  65756. private _getLoader;
  65757. private _unpackBinary;
  65758. private _unpackBinaryV1;
  65759. private _unpackBinaryV2;
  65760. private static _parseVersion;
  65761. private static _compareVersion;
  65762. private static _decodeBufferToText;
  65763. private static readonly _logSpaces;
  65764. private _logIndentLevel;
  65765. private _loggingEnabled;
  65766. /** @hidden */
  65767. _log: (message: string) => void;
  65768. /** @hidden */
  65769. _logOpen(message: string): void;
  65770. /** @hidden */
  65771. _logClose(): void;
  65772. private _logEnabled;
  65773. private _logDisabled;
  65774. private _capturePerformanceCounters;
  65775. /** @hidden */
  65776. _startPerformanceCounter: (counterName: string) => void;
  65777. /** @hidden */
  65778. _endPerformanceCounter: (counterName: string) => void;
  65779. private _startPerformanceCounterEnabled;
  65780. private _startPerformanceCounterDisabled;
  65781. private _endPerformanceCounterEnabled;
  65782. private _endPerformanceCounterDisabled;
  65783. }
  65784. }
  65785. declare module BABYLON.GLTF1 {
  65786. /**
  65787. * Enums
  65788. * @hidden
  65789. */
  65790. export enum EComponentType {
  65791. BYTE = 5120,
  65792. UNSIGNED_BYTE = 5121,
  65793. SHORT = 5122,
  65794. UNSIGNED_SHORT = 5123,
  65795. FLOAT = 5126
  65796. }
  65797. /** @hidden */
  65798. export enum EShaderType {
  65799. FRAGMENT = 35632,
  65800. VERTEX = 35633
  65801. }
  65802. /** @hidden */
  65803. export enum EParameterType {
  65804. BYTE = 5120,
  65805. UNSIGNED_BYTE = 5121,
  65806. SHORT = 5122,
  65807. UNSIGNED_SHORT = 5123,
  65808. INT = 5124,
  65809. UNSIGNED_INT = 5125,
  65810. FLOAT = 5126,
  65811. FLOAT_VEC2 = 35664,
  65812. FLOAT_VEC3 = 35665,
  65813. FLOAT_VEC4 = 35666,
  65814. INT_VEC2 = 35667,
  65815. INT_VEC3 = 35668,
  65816. INT_VEC4 = 35669,
  65817. BOOL = 35670,
  65818. BOOL_VEC2 = 35671,
  65819. BOOL_VEC3 = 35672,
  65820. BOOL_VEC4 = 35673,
  65821. FLOAT_MAT2 = 35674,
  65822. FLOAT_MAT3 = 35675,
  65823. FLOAT_MAT4 = 35676,
  65824. SAMPLER_2D = 35678
  65825. }
  65826. /** @hidden */
  65827. export enum ETextureWrapMode {
  65828. CLAMP_TO_EDGE = 33071,
  65829. MIRRORED_REPEAT = 33648,
  65830. REPEAT = 10497
  65831. }
  65832. /** @hidden */
  65833. export enum ETextureFilterType {
  65834. NEAREST = 9728,
  65835. LINEAR = 9728,
  65836. NEAREST_MIPMAP_NEAREST = 9984,
  65837. LINEAR_MIPMAP_NEAREST = 9985,
  65838. NEAREST_MIPMAP_LINEAR = 9986,
  65839. LINEAR_MIPMAP_LINEAR = 9987
  65840. }
  65841. /** @hidden */
  65842. export enum ETextureFormat {
  65843. ALPHA = 6406,
  65844. RGB = 6407,
  65845. RGBA = 6408,
  65846. LUMINANCE = 6409,
  65847. LUMINANCE_ALPHA = 6410
  65848. }
  65849. /** @hidden */
  65850. export enum ECullingType {
  65851. FRONT = 1028,
  65852. BACK = 1029,
  65853. FRONT_AND_BACK = 1032
  65854. }
  65855. /** @hidden */
  65856. export enum EBlendingFunction {
  65857. ZERO = 0,
  65858. ONE = 1,
  65859. SRC_COLOR = 768,
  65860. ONE_MINUS_SRC_COLOR = 769,
  65861. DST_COLOR = 774,
  65862. ONE_MINUS_DST_COLOR = 775,
  65863. SRC_ALPHA = 770,
  65864. ONE_MINUS_SRC_ALPHA = 771,
  65865. DST_ALPHA = 772,
  65866. ONE_MINUS_DST_ALPHA = 773,
  65867. CONSTANT_COLOR = 32769,
  65868. ONE_MINUS_CONSTANT_COLOR = 32770,
  65869. CONSTANT_ALPHA = 32771,
  65870. ONE_MINUS_CONSTANT_ALPHA = 32772,
  65871. SRC_ALPHA_SATURATE = 776
  65872. }
  65873. /** @hidden */
  65874. export interface IGLTFProperty {
  65875. extensions?: {
  65876. [key: string]: any;
  65877. };
  65878. extras?: Object;
  65879. }
  65880. /** @hidden */
  65881. export interface IGLTFChildRootProperty extends IGLTFProperty {
  65882. name?: string;
  65883. }
  65884. /** @hidden */
  65885. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  65886. bufferView: string;
  65887. byteOffset: number;
  65888. byteStride: number;
  65889. count: number;
  65890. type: string;
  65891. componentType: EComponentType;
  65892. max?: number[];
  65893. min?: number[];
  65894. name?: string;
  65895. }
  65896. /** @hidden */
  65897. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  65898. buffer: string;
  65899. byteOffset: number;
  65900. byteLength: number;
  65901. byteStride: number;
  65902. target?: number;
  65903. }
  65904. /** @hidden */
  65905. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  65906. uri: string;
  65907. byteLength?: number;
  65908. type?: string;
  65909. }
  65910. /** @hidden */
  65911. export interface IGLTFShader extends IGLTFChildRootProperty {
  65912. uri: string;
  65913. type: EShaderType;
  65914. }
  65915. /** @hidden */
  65916. export interface IGLTFProgram extends IGLTFChildRootProperty {
  65917. attributes: string[];
  65918. fragmentShader: string;
  65919. vertexShader: string;
  65920. }
  65921. /** @hidden */
  65922. export interface IGLTFTechniqueParameter {
  65923. type: number;
  65924. count?: number;
  65925. semantic?: string;
  65926. node?: string;
  65927. value?: number | boolean | string | Array<any>;
  65928. source?: string;
  65929. babylonValue?: any;
  65930. }
  65931. /** @hidden */
  65932. export interface IGLTFTechniqueCommonProfile {
  65933. lightingModel: string;
  65934. texcoordBindings: Object;
  65935. parameters?: Array<any>;
  65936. }
  65937. /** @hidden */
  65938. export interface IGLTFTechniqueStatesFunctions {
  65939. blendColor?: number[];
  65940. blendEquationSeparate?: number[];
  65941. blendFuncSeparate?: number[];
  65942. colorMask: boolean[];
  65943. cullFace: number[];
  65944. }
  65945. /** @hidden */
  65946. export interface IGLTFTechniqueStates {
  65947. enable: number[];
  65948. functions: IGLTFTechniqueStatesFunctions;
  65949. }
  65950. /** @hidden */
  65951. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  65952. parameters: {
  65953. [key: string]: IGLTFTechniqueParameter;
  65954. };
  65955. program: string;
  65956. attributes: {
  65957. [key: string]: string;
  65958. };
  65959. uniforms: {
  65960. [key: string]: string;
  65961. };
  65962. states: IGLTFTechniqueStates;
  65963. }
  65964. /** @hidden */
  65965. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  65966. technique?: string;
  65967. values: string[];
  65968. }
  65969. /** @hidden */
  65970. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  65971. attributes: {
  65972. [key: string]: string;
  65973. };
  65974. indices: string;
  65975. material: string;
  65976. mode?: number;
  65977. }
  65978. /** @hidden */
  65979. export interface IGLTFMesh extends IGLTFChildRootProperty {
  65980. primitives: IGLTFMeshPrimitive[];
  65981. }
  65982. /** @hidden */
  65983. export interface IGLTFImage extends IGLTFChildRootProperty {
  65984. uri: string;
  65985. }
  65986. /** @hidden */
  65987. export interface IGLTFSampler extends IGLTFChildRootProperty {
  65988. magFilter?: number;
  65989. minFilter?: number;
  65990. wrapS?: number;
  65991. wrapT?: number;
  65992. }
  65993. /** @hidden */
  65994. export interface IGLTFTexture extends IGLTFChildRootProperty {
  65995. sampler: string;
  65996. source: string;
  65997. format?: ETextureFormat;
  65998. internalFormat?: ETextureFormat;
  65999. target?: number;
  66000. type?: number;
  66001. babylonTexture?: Texture;
  66002. }
  66003. /** @hidden */
  66004. export interface IGLTFAmbienLight {
  66005. color?: number[];
  66006. }
  66007. /** @hidden */
  66008. export interface IGLTFDirectionalLight {
  66009. color?: number[];
  66010. }
  66011. /** @hidden */
  66012. export interface IGLTFPointLight {
  66013. color?: number[];
  66014. constantAttenuation?: number;
  66015. linearAttenuation?: number;
  66016. quadraticAttenuation?: number;
  66017. }
  66018. /** @hidden */
  66019. export interface IGLTFSpotLight {
  66020. color?: number[];
  66021. constantAttenuation?: number;
  66022. fallOfAngle?: number;
  66023. fallOffExponent?: number;
  66024. linearAttenuation?: number;
  66025. quadraticAttenuation?: number;
  66026. }
  66027. /** @hidden */
  66028. export interface IGLTFLight extends IGLTFChildRootProperty {
  66029. type: string;
  66030. }
  66031. /** @hidden */
  66032. export interface IGLTFCameraOrthographic {
  66033. xmag: number;
  66034. ymag: number;
  66035. zfar: number;
  66036. znear: number;
  66037. }
  66038. /** @hidden */
  66039. export interface IGLTFCameraPerspective {
  66040. aspectRatio: number;
  66041. yfov: number;
  66042. zfar: number;
  66043. znear: number;
  66044. }
  66045. /** @hidden */
  66046. export interface IGLTFCamera extends IGLTFChildRootProperty {
  66047. type: string;
  66048. }
  66049. /** @hidden */
  66050. export interface IGLTFAnimationChannelTarget {
  66051. id: string;
  66052. path: string;
  66053. }
  66054. /** @hidden */
  66055. export interface IGLTFAnimationChannel {
  66056. sampler: string;
  66057. target: IGLTFAnimationChannelTarget;
  66058. }
  66059. /** @hidden */
  66060. export interface IGLTFAnimationSampler {
  66061. input: string;
  66062. output: string;
  66063. interpolation?: string;
  66064. }
  66065. /** @hidden */
  66066. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  66067. channels?: IGLTFAnimationChannel[];
  66068. parameters?: {
  66069. [key: string]: string;
  66070. };
  66071. samplers?: {
  66072. [key: string]: IGLTFAnimationSampler;
  66073. };
  66074. }
  66075. /** @hidden */
  66076. export interface IGLTFNodeInstanceSkin {
  66077. skeletons: string[];
  66078. skin: string;
  66079. meshes: string[];
  66080. }
  66081. /** @hidden */
  66082. export interface IGLTFSkins extends IGLTFChildRootProperty {
  66083. bindShapeMatrix: number[];
  66084. inverseBindMatrices: string;
  66085. jointNames: string[];
  66086. babylonSkeleton?: Skeleton;
  66087. }
  66088. /** @hidden */
  66089. export interface IGLTFNode extends IGLTFChildRootProperty {
  66090. camera?: string;
  66091. children: string[];
  66092. skin?: string;
  66093. jointName?: string;
  66094. light?: string;
  66095. matrix: number[];
  66096. mesh?: string;
  66097. meshes?: string[];
  66098. rotation?: number[];
  66099. scale?: number[];
  66100. translation?: number[];
  66101. babylonNode?: Node;
  66102. }
  66103. /** @hidden */
  66104. export interface IGLTFScene extends IGLTFChildRootProperty {
  66105. nodes: string[];
  66106. }
  66107. /** @hidden */
  66108. export interface IGLTFRuntime {
  66109. extensions: {
  66110. [key: string]: any;
  66111. };
  66112. accessors: {
  66113. [key: string]: IGLTFAccessor;
  66114. };
  66115. buffers: {
  66116. [key: string]: IGLTFBuffer;
  66117. };
  66118. bufferViews: {
  66119. [key: string]: IGLTFBufferView;
  66120. };
  66121. meshes: {
  66122. [key: string]: IGLTFMesh;
  66123. };
  66124. lights: {
  66125. [key: string]: IGLTFLight;
  66126. };
  66127. cameras: {
  66128. [key: string]: IGLTFCamera;
  66129. };
  66130. nodes: {
  66131. [key: string]: IGLTFNode;
  66132. };
  66133. images: {
  66134. [key: string]: IGLTFImage;
  66135. };
  66136. textures: {
  66137. [key: string]: IGLTFTexture;
  66138. };
  66139. shaders: {
  66140. [key: string]: IGLTFShader;
  66141. };
  66142. programs: {
  66143. [key: string]: IGLTFProgram;
  66144. };
  66145. samplers: {
  66146. [key: string]: IGLTFSampler;
  66147. };
  66148. techniques: {
  66149. [key: string]: IGLTFTechnique;
  66150. };
  66151. materials: {
  66152. [key: string]: IGLTFMaterial;
  66153. };
  66154. animations: {
  66155. [key: string]: IGLTFAnimation;
  66156. };
  66157. skins: {
  66158. [key: string]: IGLTFSkins;
  66159. };
  66160. currentScene?: Object;
  66161. scenes: {
  66162. [key: string]: IGLTFScene;
  66163. };
  66164. extensionsUsed: string[];
  66165. extensionsRequired?: string[];
  66166. buffersCount: number;
  66167. shaderscount: number;
  66168. scene: Scene;
  66169. rootUrl: string;
  66170. loadedBufferCount: number;
  66171. loadedBufferViews: {
  66172. [name: string]: ArrayBufferView;
  66173. };
  66174. loadedShaderCount: number;
  66175. importOnlyMeshes: boolean;
  66176. importMeshesNames?: string[];
  66177. dummyNodes: Node[];
  66178. }
  66179. /** @hidden */
  66180. export interface INodeToRoot {
  66181. bone: Bone;
  66182. node: IGLTFNode;
  66183. id: string;
  66184. }
  66185. /** @hidden */
  66186. export interface IJointNode {
  66187. node: IGLTFNode;
  66188. id: string;
  66189. }
  66190. }
  66191. declare module BABYLON.GLTF1 {
  66192. /**
  66193. * Utils functions for GLTF
  66194. * @hidden
  66195. */
  66196. export class GLTFUtils {
  66197. /**
  66198. * Sets the given "parameter" matrix
  66199. * @param scene: the Scene object
  66200. * @param source: the source node where to pick the matrix
  66201. * @param parameter: the GLTF technique parameter
  66202. * @param uniformName: the name of the shader's uniform
  66203. * @param shaderMaterial: the shader material
  66204. */
  66205. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  66206. /**
  66207. * Sets the given "parameter" matrix
  66208. * @param shaderMaterial: the shader material
  66209. * @param uniform: the name of the shader's uniform
  66210. * @param value: the value of the uniform
  66211. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  66212. */
  66213. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  66214. /**
  66215. * Returns the wrap mode of the texture
  66216. * @param mode: the mode value
  66217. */
  66218. static GetWrapMode(mode: number): number;
  66219. /**
  66220. * Returns the byte stride giving an accessor
  66221. * @param accessor: the GLTF accessor objet
  66222. */
  66223. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  66224. /**
  66225. * Returns the texture filter mode giving a mode value
  66226. * @param mode: the filter mode value
  66227. */
  66228. static GetTextureFilterMode(mode: number): ETextureFilterType;
  66229. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  66230. /**
  66231. * Returns a buffer from its accessor
  66232. * @param gltfRuntime: the GLTF runtime
  66233. * @param accessor: the GLTF accessor
  66234. */
  66235. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  66236. /**
  66237. * Decodes a buffer view into a string
  66238. * @param view: the buffer view
  66239. */
  66240. static DecodeBufferToText(view: ArrayBufferView): string;
  66241. /**
  66242. * Returns the default material of gltf. Related to
  66243. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  66244. * @param scene: the Babylon.js scene
  66245. */
  66246. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  66247. private static _DefaultMaterial;
  66248. }
  66249. }
  66250. declare module BABYLON.GLTF1 {
  66251. /**
  66252. * Implementation of the base glTF spec
  66253. * @hidden
  66254. */
  66255. export class GLTFLoaderBase {
  66256. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  66257. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  66258. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  66259. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  66260. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  66261. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  66262. }
  66263. /**
  66264. * glTF V1 Loader
  66265. * @hidden
  66266. */
  66267. export class GLTFLoader implements IGLTFLoader {
  66268. static Extensions: {
  66269. [name: string]: GLTFLoaderExtension;
  66270. };
  66271. static RegisterExtension(extension: GLTFLoaderExtension): void;
  66272. state: Nullable<GLTFLoaderState>;
  66273. dispose(): void;
  66274. private _importMeshAsync;
  66275. /**
  66276. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  66277. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  66278. * @param scene the scene the meshes should be added to
  66279. * @param data gltf data containing information of the meshes in a loaded file
  66280. * @param rootUrl root url to load from
  66281. * @param onProgress event that fires when loading progress has occured
  66282. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  66283. */
  66284. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  66285. meshes: AbstractMesh[];
  66286. particleSystems: IParticleSystem[];
  66287. skeletons: Skeleton[];
  66288. animationGroups: AnimationGroup[];
  66289. }>;
  66290. private _loadAsync;
  66291. /**
  66292. * Imports all objects from a loaded gltf file and adds them to the scene
  66293. * @param scene the scene the objects should be added to
  66294. * @param data gltf data containing information of the meshes in a loaded file
  66295. * @param rootUrl root url to load from
  66296. * @param onProgress event that fires when loading progress has occured
  66297. * @returns a promise which completes when objects have been loaded to the scene
  66298. */
  66299. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  66300. private _loadShadersAsync;
  66301. private _loadBuffersAsync;
  66302. private _createNodes;
  66303. }
  66304. /** @hidden */
  66305. export abstract class GLTFLoaderExtension {
  66306. private _name;
  66307. constructor(name: string);
  66308. readonly name: string;
  66309. /**
  66310. * Defines an override for loading the runtime
  66311. * Return true to stop further extensions from loading the runtime
  66312. */
  66313. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  66314. /**
  66315. * Defines an onverride for creating gltf runtime
  66316. * Return true to stop further extensions from creating the runtime
  66317. */
  66318. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  66319. /**
  66320. * Defines an override for loading buffers
  66321. * Return true to stop further extensions from loading this buffer
  66322. */
  66323. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  66324. /**
  66325. * Defines an override for loading texture buffers
  66326. * Return true to stop further extensions from loading this texture data
  66327. */
  66328. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  66329. /**
  66330. * Defines an override for creating textures
  66331. * Return true to stop further extensions from loading this texture
  66332. */
  66333. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  66334. /**
  66335. * Defines an override for loading shader strings
  66336. * Return true to stop further extensions from loading this shader data
  66337. */
  66338. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  66339. /**
  66340. * Defines an override for loading materials
  66341. * Return true to stop further extensions from loading this material
  66342. */
  66343. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  66344. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  66345. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  66346. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  66347. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  66348. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  66349. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  66350. private static LoadTextureBufferAsync;
  66351. private static CreateTextureAsync;
  66352. private static ApplyExtensions;
  66353. }
  66354. }
  66355. declare module BABYLON.GLTF1 {
  66356. /** @hidden */
  66357. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  66358. private _bin;
  66359. constructor();
  66360. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  66361. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  66362. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  66363. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  66364. }
  66365. }
  66366. declare module BABYLON.GLTF1 {
  66367. /** @hidden */
  66368. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  66369. constructor();
  66370. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  66371. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  66372. private _loadTexture;
  66373. }
  66374. }
  66375. declare module BABYLON.GLTF2.Loader {
  66376. /**
  66377. * Loader interface with an index field.
  66378. */
  66379. export interface IArrayItem {
  66380. /**
  66381. * The index of this item in the array.
  66382. */
  66383. index: number;
  66384. }
  66385. /**
  66386. * Loader interface with additional members.
  66387. */
  66388. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  66389. /** @hidden */
  66390. _data?: Promise<ArrayBufferView>;
  66391. /** @hidden */
  66392. _babylonVertexBuffer?: Promise<VertexBuffer>;
  66393. }
  66394. /**
  66395. * Loader interface with additional members.
  66396. */
  66397. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  66398. }
  66399. /** @hidden */
  66400. export interface _IAnimationSamplerData {
  66401. input: Float32Array;
  66402. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  66403. output: Float32Array;
  66404. }
  66405. /**
  66406. * Loader interface with additional members.
  66407. */
  66408. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  66409. /** @hidden */
  66410. _data?: Promise<_IAnimationSamplerData>;
  66411. }
  66412. /**
  66413. * Loader interface with additional members.
  66414. */
  66415. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  66416. channels: IAnimationChannel[];
  66417. samplers: IAnimationSampler[];
  66418. /** @hidden */
  66419. _babylonAnimationGroup?: AnimationGroup;
  66420. }
  66421. /**
  66422. * Loader interface with additional members.
  66423. */
  66424. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  66425. /** @hidden */
  66426. _data?: Promise<ArrayBufferView>;
  66427. }
  66428. /**
  66429. * Loader interface with additional members.
  66430. */
  66431. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  66432. /** @hidden */
  66433. _data?: Promise<ArrayBufferView>;
  66434. /** @hidden */
  66435. _babylonBuffer?: Promise<Buffer>;
  66436. }
  66437. /**
  66438. * Loader interface with additional members.
  66439. */
  66440. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  66441. }
  66442. /**
  66443. * Loader interface with additional members.
  66444. */
  66445. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  66446. /** @hidden */
  66447. _data?: Promise<ArrayBufferView>;
  66448. }
  66449. /**
  66450. * Loader interface with additional members.
  66451. */
  66452. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  66453. }
  66454. /**
  66455. * Loader interface with additional members.
  66456. */
  66457. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  66458. }
  66459. /**
  66460. * Loader interface with additional members.
  66461. */
  66462. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  66463. baseColorTexture?: ITextureInfo;
  66464. metallicRoughnessTexture?: ITextureInfo;
  66465. }
  66466. /**
  66467. * Loader interface with additional members.
  66468. */
  66469. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  66470. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  66471. normalTexture?: IMaterialNormalTextureInfo;
  66472. occlusionTexture?: IMaterialOcclusionTextureInfo;
  66473. emissiveTexture?: ITextureInfo;
  66474. /** @hidden */
  66475. _data?: {
  66476. [babylonDrawMode: number]: {
  66477. babylonMaterial: Material;
  66478. babylonMeshes: AbstractMesh[];
  66479. promise: Promise<void>;
  66480. };
  66481. };
  66482. }
  66483. /**
  66484. * Loader interface with additional members.
  66485. */
  66486. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  66487. primitives: IMeshPrimitive[];
  66488. }
  66489. /**
  66490. * Loader interface with additional members.
  66491. */
  66492. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  66493. /** @hidden */
  66494. _instanceData?: {
  66495. babylonSourceMesh: Mesh;
  66496. promise: Promise<any>;
  66497. };
  66498. }
  66499. /**
  66500. * Loader interface with additional members.
  66501. */
  66502. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  66503. /**
  66504. * The parent glTF node.
  66505. */
  66506. parent?: INode;
  66507. /** @hidden */
  66508. _babylonTransformNode?: TransformNode;
  66509. /** @hidden */
  66510. _primitiveBabylonMeshes?: AbstractMesh[];
  66511. /** @hidden */
  66512. _babylonBones?: Bone[];
  66513. /** @hidden */
  66514. _numMorphTargets?: number;
  66515. }
  66516. /** @hidden */
  66517. export interface _ISamplerData {
  66518. noMipMaps: boolean;
  66519. samplingMode: number;
  66520. wrapU: number;
  66521. wrapV: number;
  66522. }
  66523. /**
  66524. * Loader interface with additional members.
  66525. */
  66526. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  66527. /** @hidden */
  66528. _data?: _ISamplerData;
  66529. }
  66530. /**
  66531. * Loader interface with additional members.
  66532. */
  66533. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  66534. }
  66535. /**
  66536. * Loader interface with additional members.
  66537. */
  66538. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  66539. /** @hidden */
  66540. _data?: {
  66541. babylonSkeleton: Skeleton;
  66542. promise: Promise<void>;
  66543. };
  66544. }
  66545. /**
  66546. * Loader interface with additional members.
  66547. */
  66548. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  66549. }
  66550. /**
  66551. * Loader interface with additional members.
  66552. */
  66553. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  66554. }
  66555. /**
  66556. * Loader interface with additional members.
  66557. */
  66558. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  66559. accessors?: IAccessor[];
  66560. animations?: IAnimation[];
  66561. buffers?: IBuffer[];
  66562. bufferViews?: IBufferView[];
  66563. cameras?: ICamera[];
  66564. images?: IImage[];
  66565. materials?: IMaterial[];
  66566. meshes?: IMesh[];
  66567. nodes?: INode[];
  66568. samplers?: ISampler[];
  66569. scenes?: IScene[];
  66570. skins?: ISkin[];
  66571. textures?: ITexture[];
  66572. }
  66573. }
  66574. declare module BABYLON.GLTF2 {
  66575. /**
  66576. * Interface for a glTF loader extension.
  66577. */
  66578. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  66579. /**
  66580. * Called after the loader state changes to LOADING.
  66581. */
  66582. onLoading?(): void;
  66583. /**
  66584. * Called after the loader state changes to READY.
  66585. */
  66586. onReady?(): void;
  66587. /**
  66588. * Define this method to modify the default behavior when loading scenes.
  66589. * @param context The context when loading the asset
  66590. * @param scene The glTF scene property
  66591. * @returns A promise that resolves when the load is complete or null if not handled
  66592. */
  66593. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  66594. /**
  66595. * Define this method to modify the default behavior when loading nodes.
  66596. * @param context The context when loading the asset
  66597. * @param node The glTF node property
  66598. * @param assign A function called synchronously after parsing the glTF properties
  66599. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  66600. */
  66601. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66602. /**
  66603. * Define this method to modify the default behavior when loading cameras.
  66604. * @param context The context when loading the asset
  66605. * @param camera The glTF camera property
  66606. * @param assign A function called synchronously after parsing the glTF properties
  66607. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  66608. */
  66609. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  66610. /**
  66611. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  66612. * @param context The context when loading the asset
  66613. * @param primitive The glTF mesh primitive property
  66614. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  66615. */
  66616. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  66617. /**
  66618. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  66619. * @param context The context when loading the asset
  66620. * @param name The mesh name when loading the asset
  66621. * @param node The glTF node when loading the asset
  66622. * @param mesh The glTF mesh when loading the asset
  66623. * @param primitive The glTF mesh primitive property
  66624. * @param assign A function called synchronously after parsing the glTF properties
  66625. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  66626. */
  66627. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  66628. /**
  66629. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  66630. * @param context The context when loading the asset
  66631. * @param material The glTF material property
  66632. * @param assign A function called synchronously after parsing the glTF properties
  66633. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  66634. */
  66635. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  66636. /**
  66637. * Define this method to modify the default behavior when creating materials.
  66638. * @param context The context when loading the asset
  66639. * @param material The glTF material property
  66640. * @param babylonDrawMode The draw mode for the Babylon material
  66641. * @returns The Babylon material or null if not handled
  66642. */
  66643. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  66644. /**
  66645. * Define this method to modify the default behavior when loading material properties.
  66646. * @param context The context when loading the asset
  66647. * @param material The glTF material property
  66648. * @param babylonMaterial The Babylon material
  66649. * @returns A promise that resolves when the load is complete or null if not handled
  66650. */
  66651. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66652. /**
  66653. * Define this method to modify the default behavior when loading texture infos.
  66654. * @param context The context when loading the asset
  66655. * @param textureInfo The glTF texture info property
  66656. * @param assign A function called synchronously after parsing the glTF properties
  66657. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  66658. */
  66659. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  66660. /**
  66661. * Define this method to modify the default behavior when loading animations.
  66662. * @param context The context when loading the asset
  66663. * @param animation The glTF animation property
  66664. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  66665. */
  66666. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  66667. /**
  66668. * @hidden Define this method to modify the default behavior when loading skins.
  66669. * @param context The context when loading the asset
  66670. * @param node The glTF node property
  66671. * @param skin The glTF skin property
  66672. * @returns A promise that resolves when the load is complete or null if not handled
  66673. */
  66674. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  66675. /**
  66676. * @hidden Define this method to modify the default behavior when loading uris.
  66677. * @param context The context when loading the asset
  66678. * @param property The glTF property associated with the uri
  66679. * @param uri The uri to load
  66680. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  66681. */
  66682. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  66683. }
  66684. }
  66685. declare module BABYLON.GLTF2 {
  66686. /**
  66687. * Helper class for working with arrays when loading the glTF asset
  66688. */
  66689. export class ArrayItem {
  66690. /**
  66691. * Gets an item from the given array.
  66692. * @param context The context when loading the asset
  66693. * @param array The array to get the item from
  66694. * @param index The index to the array
  66695. * @returns The array item
  66696. */
  66697. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  66698. /**
  66699. * Assign an `index` field to each item of the given array.
  66700. * @param array The array of items
  66701. */
  66702. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  66703. }
  66704. /**
  66705. * The glTF 2.0 loader
  66706. */
  66707. export class GLTFLoader implements IGLTFLoader {
  66708. /** @hidden */
  66709. _completePromises: Promise<any>[];
  66710. private _disposed;
  66711. private _parent;
  66712. private _state;
  66713. private _extensions;
  66714. private _rootUrl;
  66715. private _fileName;
  66716. private _uniqueRootUrl;
  66717. private _gltf;
  66718. private _babylonScene;
  66719. private _rootBabylonMesh;
  66720. private _defaultBabylonMaterialData;
  66721. private _progressCallback?;
  66722. private _requests;
  66723. private static readonly _DefaultSampler;
  66724. private static _ExtensionNames;
  66725. private static _ExtensionFactories;
  66726. /**
  66727. * Registers a loader extension.
  66728. * @param name The name of the loader extension.
  66729. * @param factory The factory function that creates the loader extension.
  66730. */
  66731. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  66732. /**
  66733. * Unregisters a loader extension.
  66734. * @param name The name of the loader extenion.
  66735. * @returns A boolean indicating whether the extension has been unregistered
  66736. */
  66737. static UnregisterExtension(name: string): boolean;
  66738. /**
  66739. * Gets the loader state.
  66740. */
  66741. readonly state: Nullable<GLTFLoaderState>;
  66742. /**
  66743. * The glTF object parsed from the JSON.
  66744. */
  66745. readonly gltf: IGLTF;
  66746. /**
  66747. * The Babylon scene when loading the asset.
  66748. */
  66749. readonly babylonScene: Scene;
  66750. /**
  66751. * The root Babylon mesh when loading the asset.
  66752. */
  66753. readonly rootBabylonMesh: Mesh;
  66754. /** @hidden */
  66755. constructor(parent: GLTFFileLoader);
  66756. /** @hidden */
  66757. dispose(): void;
  66758. /** @hidden */
  66759. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  66760. meshes: AbstractMesh[];
  66761. particleSystems: IParticleSystem[];
  66762. skeletons: Skeleton[];
  66763. animationGroups: AnimationGroup[];
  66764. }>;
  66765. /** @hidden */
  66766. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  66767. private _loadAsync;
  66768. private _loadData;
  66769. private _setupData;
  66770. private _loadExtensions;
  66771. private _checkExtensions;
  66772. private _setState;
  66773. private _createRootNode;
  66774. /**
  66775. * Loads a glTF scene.
  66776. * @param context The context when loading the asset
  66777. * @param scene The glTF scene property
  66778. * @returns A promise that resolves when the load is complete
  66779. */
  66780. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  66781. private _forEachPrimitive;
  66782. private _getMeshes;
  66783. private _getSkeletons;
  66784. private _getAnimationGroups;
  66785. private _startAnimations;
  66786. /**
  66787. * Loads a glTF node.
  66788. * @param context The context when loading the asset
  66789. * @param node The glTF node property
  66790. * @param assign A function called synchronously after parsing the glTF properties
  66791. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  66792. */
  66793. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  66794. private _loadMeshAsync;
  66795. /**
  66796. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  66797. * @param context The context when loading the asset
  66798. * @param name The mesh name when loading the asset
  66799. * @param node The glTF node when loading the asset
  66800. * @param mesh The glTF mesh when loading the asset
  66801. * @param primitive The glTF mesh primitive property
  66802. * @param assign A function called synchronously after parsing the glTF properties
  66803. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  66804. */
  66805. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  66806. private _loadVertexDataAsync;
  66807. private _createMorphTargets;
  66808. private _loadMorphTargetsAsync;
  66809. private _loadMorphTargetVertexDataAsync;
  66810. private static _LoadTransform;
  66811. private _loadSkinAsync;
  66812. private _loadBones;
  66813. private _loadBone;
  66814. private _loadSkinInverseBindMatricesDataAsync;
  66815. private _updateBoneMatrices;
  66816. private _getNodeMatrix;
  66817. /**
  66818. * Loads a glTF camera.
  66819. * @param context The context when loading the asset
  66820. * @param camera The glTF camera property
  66821. * @param assign A function called synchronously after parsing the glTF properties
  66822. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  66823. */
  66824. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  66825. private _loadAnimationsAsync;
  66826. /**
  66827. * Loads a glTF animation.
  66828. * @param context The context when loading the asset
  66829. * @param animation The glTF animation property
  66830. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  66831. */
  66832. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  66833. /**
  66834. * @hidden Loads a glTF animation channel.
  66835. * @param context The context when loading the asset
  66836. * @param animationContext The context of the animation when loading the asset
  66837. * @param animation The glTF animation property
  66838. * @param channel The glTF animation channel property
  66839. * @param babylonAnimationGroup The babylon animation group property
  66840. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  66841. * @returns A void promise when the channel load is complete
  66842. */
  66843. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  66844. private _loadAnimationSamplerAsync;
  66845. private _loadBufferAsync;
  66846. /**
  66847. * Loads a glTF buffer view.
  66848. * @param context The context when loading the asset
  66849. * @param bufferView The glTF buffer view property
  66850. * @returns A promise that resolves with the loaded data when the load is complete
  66851. */
  66852. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  66853. private _loadAccessorAsync;
  66854. private _loadFloatAccessorAsync;
  66855. private _loadIndicesAccessorAsync;
  66856. private _loadVertexBufferViewAsync;
  66857. private _loadVertexAccessorAsync;
  66858. private _loadMaterialMetallicRoughnessPropertiesAsync;
  66859. /** @hidden */
  66860. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  66861. private _createDefaultMaterial;
  66862. /**
  66863. * Creates a Babylon material from a glTF material.
  66864. * @param context The context when loading the asset
  66865. * @param material The glTF material property
  66866. * @param babylonDrawMode The draw mode for the Babylon material
  66867. * @returns The Babylon material
  66868. */
  66869. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  66870. /**
  66871. * Loads properties from a glTF material into a Babylon material.
  66872. * @param context The context when loading the asset
  66873. * @param material The glTF material property
  66874. * @param babylonMaterial The Babylon material
  66875. * @returns A promise that resolves when the load is complete
  66876. */
  66877. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  66878. /**
  66879. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  66880. * @param context The context when loading the asset
  66881. * @param material The glTF material property
  66882. * @param babylonMaterial The Babylon material
  66883. * @returns A promise that resolves when the load is complete
  66884. */
  66885. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  66886. /**
  66887. * Loads the alpha properties from a glTF material into a Babylon material.
  66888. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  66889. * @param context The context when loading the asset
  66890. * @param material The glTF material property
  66891. * @param babylonMaterial The Babylon material
  66892. */
  66893. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  66894. /**
  66895. * Loads a glTF texture info.
  66896. * @param context The context when loading the asset
  66897. * @param textureInfo The glTF texture info property
  66898. * @param assign A function called synchronously after parsing the glTF properties
  66899. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  66900. */
  66901. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  66902. private _loadTextureAsync;
  66903. private _loadSampler;
  66904. /**
  66905. * Loads a glTF image.
  66906. * @param context The context when loading the asset
  66907. * @param image The glTF image property
  66908. * @returns A promise that resolves with the loaded data when the load is complete
  66909. */
  66910. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  66911. /**
  66912. * Loads a glTF uri.
  66913. * @param context The context when loading the asset
  66914. * @param property The glTF property associated with the uri
  66915. * @param uri The base64 or relative uri
  66916. * @returns A promise that resolves with the loaded data when the load is complete
  66917. */
  66918. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  66919. private _onProgress;
  66920. /**
  66921. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  66922. * @param babylonObject the Babylon object with metadata
  66923. * @param pointer the JSON pointer
  66924. */
  66925. static AddPointerMetadata(babylonObject: {
  66926. metadata: any;
  66927. }, pointer: string): void;
  66928. private static _GetTextureWrapMode;
  66929. private static _GetTextureSamplingMode;
  66930. private static _GetTypedArrayConstructor;
  66931. private static _GetTypedArray;
  66932. private static _GetNumComponents;
  66933. private static _ValidateUri;
  66934. private static _GetDrawMode;
  66935. private _compileMaterialsAsync;
  66936. private _compileShadowGeneratorsAsync;
  66937. private _forEachExtensions;
  66938. private _applyExtensions;
  66939. private _extensionsOnLoading;
  66940. private _extensionsOnReady;
  66941. private _extensionsLoadSceneAsync;
  66942. private _extensionsLoadNodeAsync;
  66943. private _extensionsLoadCameraAsync;
  66944. private _extensionsLoadVertexDataAsync;
  66945. private _extensionsLoadMeshPrimitiveAsync;
  66946. private _extensionsLoadMaterialAsync;
  66947. private _extensionsCreateMaterial;
  66948. private _extensionsLoadMaterialPropertiesAsync;
  66949. private _extensionsLoadTextureInfoAsync;
  66950. private _extensionsLoadAnimationAsync;
  66951. private _extensionsLoadSkinAsync;
  66952. private _extensionsLoadUriAsync;
  66953. /**
  66954. * Helper method called by a loader extension to load an glTF extension.
  66955. * @param context The context when loading the asset
  66956. * @param property The glTF property to load the extension from
  66957. * @param extensionName The name of the extension to load
  66958. * @param actionAsync The action to run
  66959. * @returns The promise returned by actionAsync or null if the extension does not exist
  66960. */
  66961. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  66962. /**
  66963. * Helper method called by a loader extension to load a glTF extra.
  66964. * @param context The context when loading the asset
  66965. * @param property The glTF property to load the extra from
  66966. * @param extensionName The name of the extension to load
  66967. * @param actionAsync The action to run
  66968. * @returns The promise returned by actionAsync or null if the extra does not exist
  66969. */
  66970. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  66971. /**
  66972. * Increments the indentation level and logs a message.
  66973. * @param message The message to log
  66974. */
  66975. logOpen(message: string): void;
  66976. /**
  66977. * Decrements the indentation level.
  66978. */
  66979. logClose(): void;
  66980. /**
  66981. * Logs a message
  66982. * @param message The message to log
  66983. */
  66984. log(message: string): void;
  66985. /**
  66986. * Starts a performance counter.
  66987. * @param counterName The name of the performance counter
  66988. */
  66989. startPerformanceCounter(counterName: string): void;
  66990. /**
  66991. * Ends a performance counter.
  66992. * @param counterName The name of the performance counter
  66993. */
  66994. endPerformanceCounter(counterName: string): void;
  66995. }
  66996. }
  66997. declare module BABYLON.GLTF2.Loader.Extensions {
  66998. /**
  66999. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  67000. */
  67001. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  67002. /** The name of this extension. */
  67003. readonly name: string;
  67004. /** Defines whether this extension is enabled. */
  67005. enabled: boolean;
  67006. private _loader;
  67007. private _lights?;
  67008. /** @hidden */
  67009. constructor(loader: GLTFLoader);
  67010. /** @hidden */
  67011. dispose(): void;
  67012. /** @hidden */
  67013. onLoading(): void;
  67014. /** @hidden */
  67015. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  67016. private _loadLightAsync;
  67017. }
  67018. }
  67019. declare module BABYLON.GLTF2.Loader.Extensions {
  67020. /**
  67021. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  67022. */
  67023. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  67024. /** The name of this extension. */
  67025. readonly name: string;
  67026. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  67027. dracoCompression?: DracoCompression;
  67028. /** Defines whether this extension is enabled. */
  67029. enabled: boolean;
  67030. private _loader;
  67031. /** @hidden */
  67032. constructor(loader: GLTFLoader);
  67033. /** @hidden */
  67034. dispose(): void;
  67035. /** @hidden */
  67036. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  67037. }
  67038. }
  67039. declare module BABYLON.GLTF2.Loader.Extensions {
  67040. /**
  67041. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  67042. */
  67043. export class KHR_lights implements IGLTFLoaderExtension {
  67044. /** The name of this extension. */
  67045. readonly name: string;
  67046. /** Defines whether this extension is enabled. */
  67047. enabled: boolean;
  67048. private _loader;
  67049. private _lights?;
  67050. /** @hidden */
  67051. constructor(loader: GLTFLoader);
  67052. /** @hidden */
  67053. dispose(): void;
  67054. /** @hidden */
  67055. onLoading(): void;
  67056. /** @hidden */
  67057. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67058. }
  67059. }
  67060. declare module BABYLON.GLTF2.Loader.Extensions {
  67061. /**
  67062. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  67063. */
  67064. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  67065. /** The name of this extension. */
  67066. readonly name: string;
  67067. /** Defines whether this extension is enabled. */
  67068. enabled: boolean;
  67069. private _loader;
  67070. /** @hidden */
  67071. constructor(loader: GLTFLoader);
  67072. /** @hidden */
  67073. dispose(): void;
  67074. /** @hidden */
  67075. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67076. private _loadSpecularGlossinessPropertiesAsync;
  67077. }
  67078. }
  67079. declare module BABYLON.GLTF2.Loader.Extensions {
  67080. /**
  67081. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  67082. */
  67083. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  67084. /** The name of this extension. */
  67085. readonly name: string;
  67086. /** Defines whether this extension is enabled. */
  67087. enabled: boolean;
  67088. private _loader;
  67089. /** @hidden */
  67090. constructor(loader: GLTFLoader);
  67091. /** @hidden */
  67092. dispose(): void;
  67093. /** @hidden */
  67094. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67095. private _loadUnlitPropertiesAsync;
  67096. }
  67097. }
  67098. declare module BABYLON.GLTF2.Loader.Extensions {
  67099. /**
  67100. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  67101. */
  67102. export class KHR_texture_transform implements IGLTFLoaderExtension {
  67103. /** The name of this extension. */
  67104. readonly name: string;
  67105. /** Defines whether this extension is enabled. */
  67106. enabled: boolean;
  67107. private _loader;
  67108. /** @hidden */
  67109. constructor(loader: GLTFLoader);
  67110. /** @hidden */
  67111. dispose(): void;
  67112. /** @hidden */
  67113. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  67114. }
  67115. }
  67116. declare module BABYLON.GLTF2.Loader.Extensions {
  67117. /**
  67118. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  67119. */
  67120. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  67121. /** The name of this extension. */
  67122. readonly name: string;
  67123. /** Defines whether this extension is enabled. */
  67124. enabled: boolean;
  67125. private _loader;
  67126. private _clips;
  67127. private _emitters;
  67128. /** @hidden */
  67129. constructor(loader: GLTFLoader);
  67130. /** @hidden */
  67131. dispose(): void;
  67132. /** @hidden */
  67133. onLoading(): void;
  67134. /** @hidden */
  67135. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  67136. /** @hidden */
  67137. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67138. /** @hidden */
  67139. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  67140. private _loadClipAsync;
  67141. private _loadEmitterAsync;
  67142. private _getEventAction;
  67143. private _loadAnimationEventAsync;
  67144. }
  67145. }
  67146. declare module BABYLON.GLTF2.Loader.Extensions {
  67147. /**
  67148. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  67149. */
  67150. export class MSFT_lod implements IGLTFLoaderExtension {
  67151. /** The name of this extension. */
  67152. readonly name: string;
  67153. /** Defines whether this extension is enabled. */
  67154. enabled: boolean;
  67155. /**
  67156. * Maximum number of LODs to load, starting from the lowest LOD.
  67157. */
  67158. maxLODsToLoad: number;
  67159. /**
  67160. * Observable raised when all node LODs of one level are loaded.
  67161. * The event data is the index of the loaded LOD starting from zero.
  67162. * Dispose the loader to cancel the loading of the next level of LODs.
  67163. */
  67164. onNodeLODsLoadedObservable: Observable<number>;
  67165. /**
  67166. * Observable raised when all material LODs of one level are loaded.
  67167. * The event data is the index of the loaded LOD starting from zero.
  67168. * Dispose the loader to cancel the loading of the next level of LODs.
  67169. */
  67170. onMaterialLODsLoadedObservable: Observable<number>;
  67171. private _loader;
  67172. private _nodeIndexLOD;
  67173. private _nodeSignalLODs;
  67174. private _nodePromiseLODs;
  67175. private _materialIndexLOD;
  67176. private _materialSignalLODs;
  67177. private _materialPromiseLODs;
  67178. /** @hidden */
  67179. constructor(loader: GLTFLoader);
  67180. /** @hidden */
  67181. dispose(): void;
  67182. /** @hidden */
  67183. onReady(): void;
  67184. /** @hidden */
  67185. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67186. /** @hidden */
  67187. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  67188. /** @hidden */
  67189. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  67190. /**
  67191. * Gets an array of LOD properties from lowest to highest.
  67192. */
  67193. private _getLODs;
  67194. private _disposeUnusedMaterials;
  67195. }
  67196. }
  67197. declare module BABYLON.GLTF2.Loader.Extensions {
  67198. /** @hidden */
  67199. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  67200. readonly name: string;
  67201. enabled: boolean;
  67202. private _loader;
  67203. constructor(loader: GLTFLoader);
  67204. dispose(): void;
  67205. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67206. }
  67207. }
  67208. declare module BABYLON.GLTF2.Loader.Extensions {
  67209. /** @hidden */
  67210. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  67211. readonly name: string;
  67212. enabled: boolean;
  67213. private _loader;
  67214. constructor(loader: GLTFLoader);
  67215. dispose(): void;
  67216. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67217. }
  67218. }
  67219. declare module BABYLON.GLTF2.Loader.Extensions {
  67220. /**
  67221. * Store glTF extras (if present) in BJS objects' metadata
  67222. */
  67223. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  67224. /** The name of this extension. */
  67225. readonly name: string;
  67226. /** Defines whether this extension is enabled. */
  67227. enabled: boolean;
  67228. private _loader;
  67229. private _assignExtras;
  67230. /** @hidden */
  67231. constructor(loader: GLTFLoader);
  67232. /** @hidden */
  67233. dispose(): void;
  67234. /** @hidden */
  67235. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67236. /** @hidden */
  67237. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  67238. /** @hidden */
  67239. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  67240. }
  67241. }
  67242. declare module BABYLON {
  67243. /**
  67244. * Class reading and parsing the MTL file bundled with the obj file.
  67245. */
  67246. export class MTLFileLoader {
  67247. /**
  67248. * All material loaded from the mtl will be set here
  67249. */
  67250. materials: StandardMaterial[];
  67251. /**
  67252. * This function will read the mtl file and create each material described inside
  67253. * This function could be improve by adding :
  67254. * -some component missing (Ni, Tf...)
  67255. * -including the specific options available
  67256. *
  67257. * @param scene defines the scene the material will be created in
  67258. * @param data defines the mtl data to parse
  67259. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  67260. */
  67261. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  67262. /**
  67263. * Gets the texture for the material.
  67264. *
  67265. * If the material is imported from input file,
  67266. * We sanitize the url to ensure it takes the textre from aside the material.
  67267. *
  67268. * @param rootUrl The root url to load from
  67269. * @param value The value stored in the mtl
  67270. * @return The Texture
  67271. */
  67272. private static _getTexture;
  67273. }
  67274. /**
  67275. * Options for loading OBJ/MTL files
  67276. */
  67277. type MeshLoadOptions = {
  67278. /**
  67279. * Defines if UVs are optimized by default during load.
  67280. */
  67281. OptimizeWithUV: boolean;
  67282. /**
  67283. * Defines custom scaling of UV coordinates of loaded meshes.
  67284. */
  67285. UVScaling: Vector2;
  67286. /**
  67287. * Invert model on y-axis (does a model scaling inversion)
  67288. */
  67289. InvertY: boolean;
  67290. /**
  67291. * Invert Y-Axis of referenced textures on load
  67292. */
  67293. InvertTextureY: boolean;
  67294. /**
  67295. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  67296. */
  67297. ImportVertexColors: boolean;
  67298. /**
  67299. * Compute the normals for the model, even if normals are present in the file.
  67300. */
  67301. ComputeNormals: boolean;
  67302. /**
  67303. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  67304. */
  67305. SkipMaterials: boolean;
  67306. /**
  67307. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  67308. */
  67309. MaterialLoadingFailsSilently: boolean;
  67310. };
  67311. /**
  67312. * OBJ file type loader.
  67313. * This is a babylon scene loader plugin.
  67314. */
  67315. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  67316. /**
  67317. * Defines if UVs are optimized by default during load.
  67318. */
  67319. static OPTIMIZE_WITH_UV: boolean;
  67320. /**
  67321. * Invert model on y-axis (does a model scaling inversion)
  67322. */
  67323. static INVERT_Y: boolean;
  67324. /**
  67325. * Invert Y-Axis of referenced textures on load
  67326. */
  67327. static INVERT_TEXTURE_Y: boolean;
  67328. /**
  67329. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  67330. */
  67331. static IMPORT_VERTEX_COLORS: boolean;
  67332. /**
  67333. * Compute the normals for the model, even if normals are present in the file.
  67334. */
  67335. static COMPUTE_NORMALS: boolean;
  67336. /**
  67337. * Defines custom scaling of UV coordinates of loaded meshes.
  67338. */
  67339. static UV_SCALING: Vector2;
  67340. /**
  67341. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  67342. */
  67343. static SKIP_MATERIALS: boolean;
  67344. /**
  67345. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  67346. *
  67347. * Defaults to true for backwards compatibility.
  67348. */
  67349. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  67350. /**
  67351. * Defines the name of the plugin.
  67352. */
  67353. name: string;
  67354. /**
  67355. * Defines the extension the plugin is able to load.
  67356. */
  67357. extensions: string;
  67358. /** @hidden */
  67359. obj: RegExp;
  67360. /** @hidden */
  67361. group: RegExp;
  67362. /** @hidden */
  67363. mtllib: RegExp;
  67364. /** @hidden */
  67365. usemtl: RegExp;
  67366. /** @hidden */
  67367. smooth: RegExp;
  67368. /** @hidden */
  67369. vertexPattern: RegExp;
  67370. /** @hidden */
  67371. normalPattern: RegExp;
  67372. /** @hidden */
  67373. uvPattern: RegExp;
  67374. /** @hidden */
  67375. facePattern1: RegExp;
  67376. /** @hidden */
  67377. facePattern2: RegExp;
  67378. /** @hidden */
  67379. facePattern3: RegExp;
  67380. /** @hidden */
  67381. facePattern4: RegExp;
  67382. /** @hidden */
  67383. facePattern5: RegExp;
  67384. private _meshLoadOptions;
  67385. /**
  67386. * Creates loader for .OBJ files
  67387. *
  67388. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  67389. */
  67390. constructor(meshLoadOptions?: MeshLoadOptions);
  67391. private static readonly currentMeshLoadOptions;
  67392. /**
  67393. * Calls synchronously the MTL file attached to this obj.
  67394. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  67395. * Without this function materials are not displayed in the first frame (but displayed after).
  67396. * In consequence it is impossible to get material information in your HTML file
  67397. *
  67398. * @param url The URL of the MTL file
  67399. * @param rootUrl
  67400. * @param onSuccess Callback function to be called when the MTL file is loaded
  67401. * @private
  67402. */
  67403. private _loadMTL;
  67404. /**
  67405. * Instantiates a OBJ file loader plugin.
  67406. * @returns the created plugin
  67407. */
  67408. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  67409. /**
  67410. * If the data string can be loaded directly.
  67411. *
  67412. * @param data string containing the file data
  67413. * @returns if the data can be loaded directly
  67414. */
  67415. canDirectLoad(data: string): boolean;
  67416. /**
  67417. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  67418. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67419. * @param scene the scene the meshes should be added to
  67420. * @param data the OBJ data to load
  67421. * @param rootUrl root url to load from
  67422. * @param onProgress event that fires when loading progress has occured
  67423. * @param fileName Defines the name of the file to load
  67424. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67425. */
  67426. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67427. meshes: AbstractMesh[];
  67428. particleSystems: IParticleSystem[];
  67429. skeletons: Skeleton[];
  67430. animationGroups: AnimationGroup[];
  67431. }>;
  67432. /**
  67433. * Imports all objects from the loaded OBJ data and adds them to the scene
  67434. * @param scene the scene the objects should be added to
  67435. * @param data the OBJ data to load
  67436. * @param rootUrl root url to load from
  67437. * @param onProgress event that fires when loading progress has occured
  67438. * @param fileName Defines the name of the file to load
  67439. * @returns a promise which completes when objects have been loaded to the scene
  67440. */
  67441. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67442. /**
  67443. * Load into an asset container.
  67444. * @param scene The scene to load into
  67445. * @param data The data to import
  67446. * @param rootUrl The root url for scene and resources
  67447. * @param onProgress The callback when the load progresses
  67448. * @param fileName Defines the name of the file to load
  67449. * @returns The loaded asset container
  67450. */
  67451. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  67452. /**
  67453. * Read the OBJ file and create an Array of meshes.
  67454. * Each mesh contains all information given by the OBJ and the MTL file.
  67455. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  67456. *
  67457. * @param meshesNames
  67458. * @param scene Scene The scene where are displayed the data
  67459. * @param data String The content of the obj file
  67460. * @param rootUrl String The path to the folder
  67461. * @returns Array<AbstractMesh>
  67462. * @private
  67463. */
  67464. private _parseSolid;
  67465. }
  67466. }
  67467. declare module BABYLON {
  67468. /**
  67469. * STL file type loader.
  67470. * This is a babylon scene loader plugin.
  67471. */
  67472. export class STLFileLoader implements ISceneLoaderPlugin {
  67473. /** @hidden */
  67474. solidPattern: RegExp;
  67475. /** @hidden */
  67476. facetsPattern: RegExp;
  67477. /** @hidden */
  67478. normalPattern: RegExp;
  67479. /** @hidden */
  67480. vertexPattern: RegExp;
  67481. /**
  67482. * Defines the name of the plugin.
  67483. */
  67484. name: string;
  67485. /**
  67486. * Defines the extensions the stl loader is able to load.
  67487. * force data to come in as an ArrayBuffer
  67488. * we'll convert to string if it looks like it's an ASCII .stl
  67489. */
  67490. extensions: ISceneLoaderPluginExtensions;
  67491. /**
  67492. * Import meshes into a scene.
  67493. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  67494. * @param scene The scene to import into
  67495. * @param data The data to import
  67496. * @param rootUrl The root url for scene and resources
  67497. * @param meshes The meshes array to import into
  67498. * @param particleSystems The particle systems array to import into
  67499. * @param skeletons The skeletons array to import into
  67500. * @param onError The callback when import fails
  67501. * @returns True if successful or false otherwise
  67502. */
  67503. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  67504. /**
  67505. * Load into a scene.
  67506. * @param scene The scene to load into
  67507. * @param data The data to import
  67508. * @param rootUrl The root url for scene and resources
  67509. * @param onError The callback when import fails
  67510. * @returns true if successful or false otherwise
  67511. */
  67512. load(scene: Scene, data: any, rootUrl: string): boolean;
  67513. /**
  67514. * Load into an asset container.
  67515. * @param scene The scene to load into
  67516. * @param data The data to import
  67517. * @param rootUrl The root url for scene and resources
  67518. * @param onError The callback when import fails
  67519. * @returns The loaded asset container
  67520. */
  67521. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  67522. private _isBinary;
  67523. private _parseBinary;
  67524. private _parseASCII;
  67525. }
  67526. }
  67527. declare module BABYLON {
  67528. /**
  67529. * Class for generating OBJ data from a Babylon scene.
  67530. */
  67531. export class OBJExport {
  67532. /**
  67533. * Exports the geometry of a Mesh array in .OBJ file format (text)
  67534. * @param mesh defines the list of meshes to serialize
  67535. * @param materials defines if materials should be exported
  67536. * @param matlibname defines the name of the associated mtl file
  67537. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  67538. * @returns the OBJ content
  67539. */
  67540. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  67541. /**
  67542. * Exports the material(s) of a mesh in .MTL file format (text)
  67543. * @param mesh defines the mesh to extract the material from
  67544. * @returns the mtl content
  67545. */
  67546. static MTL(mesh: Mesh): string;
  67547. }
  67548. }
  67549. declare module BABYLON {
  67550. /** @hidden */
  67551. export var __IGLTFExporterExtension: number;
  67552. /**
  67553. * Interface for extending the exporter
  67554. * @hidden
  67555. */
  67556. export interface IGLTFExporterExtension {
  67557. /**
  67558. * The name of this extension
  67559. */
  67560. readonly name: string;
  67561. /**
  67562. * Defines whether this extension is enabled
  67563. */
  67564. enabled: boolean;
  67565. /**
  67566. * Defines whether this extension is required
  67567. */
  67568. required: boolean;
  67569. }
  67570. }
  67571. declare module BABYLON.GLTF2.Exporter {
  67572. /** @hidden */
  67573. export var __IGLTFExporterExtensionV2: number;
  67574. /**
  67575. * Interface for a glTF exporter extension
  67576. * @hidden
  67577. */
  67578. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  67579. /**
  67580. * Define this method to modify the default behavior before exporting a texture
  67581. * @param context The context when loading the asset
  67582. * @param babylonTexture The glTF texture info property
  67583. * @param mimeType The mime-type of the generated image
  67584. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  67585. */
  67586. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  67587. /**
  67588. * Define this method to modify the default behavior when exporting texture info
  67589. * @param context The context when loading the asset
  67590. * @param meshPrimitive glTF mesh primitive
  67591. * @param babylonSubMesh Babylon submesh
  67592. * @param binaryWriter glTF serializer binary writer instance
  67593. * @returns nullable IMeshPrimitive promise
  67594. */
  67595. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  67596. /**
  67597. * Define this method to modify the default behavior when exporting a node
  67598. * @param context The context when exporting the node
  67599. * @param node glTF node
  67600. * @param babylonNode BabylonJS node
  67601. * @returns nullable INode promise
  67602. */
  67603. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  67604. /**
  67605. * Called after the exporter state changes to EXPORTING
  67606. */
  67607. onExporting?(): void;
  67608. }
  67609. }
  67610. declare module BABYLON.GLTF2.Exporter {
  67611. /**
  67612. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  67613. * @hidden
  67614. */
  67615. export class _GLTFMaterialExporter {
  67616. /**
  67617. * Represents the dielectric specular values for R, G and B
  67618. */
  67619. private static readonly _DielectricSpecular;
  67620. /**
  67621. * Allows the maximum specular power to be defined for material calculations
  67622. */
  67623. private static readonly _MaxSpecularPower;
  67624. /**
  67625. * Mapping to store textures
  67626. */
  67627. private _textureMap;
  67628. /**
  67629. * Numeric tolerance value
  67630. */
  67631. private static readonly _Epsilon;
  67632. /**
  67633. * Reference to the glTF Exporter
  67634. */
  67635. private _exporter;
  67636. constructor(exporter: _Exporter);
  67637. /**
  67638. * Specifies if two colors are approximately equal in value
  67639. * @param color1 first color to compare to
  67640. * @param color2 second color to compare to
  67641. * @param epsilon threshold value
  67642. */
  67643. private static FuzzyEquals;
  67644. /**
  67645. * Gets the materials from a Babylon scene and converts them to glTF materials
  67646. * @param scene babylonjs scene
  67647. * @param mimeType texture mime type
  67648. * @param images array of images
  67649. * @param textures array of textures
  67650. * @param materials array of materials
  67651. * @param imageData mapping of texture names to base64 textures
  67652. * @param hasTextureCoords specifies if texture coordinates are present on the material
  67653. */
  67654. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67655. /**
  67656. * Makes a copy of the glTF material without the texture parameters
  67657. * @param originalMaterial original glTF material
  67658. * @returns glTF material without texture parameters
  67659. */
  67660. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  67661. /**
  67662. * Specifies if the material has any texture parameters present
  67663. * @param material glTF Material
  67664. * @returns boolean specifying if texture parameters are present
  67665. */
  67666. _hasTexturesPresent(material: IMaterial): boolean;
  67667. /**
  67668. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  67669. * @param babylonStandardMaterial
  67670. * @returns glTF Metallic Roughness Material representation
  67671. */
  67672. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  67673. /**
  67674. * Computes the metallic factor
  67675. * @param diffuse diffused value
  67676. * @param specular specular value
  67677. * @param oneMinusSpecularStrength one minus the specular strength
  67678. * @returns metallic value
  67679. */
  67680. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  67681. /**
  67682. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  67683. * @param glTFMaterial glTF material
  67684. * @param babylonMaterial Babylon material
  67685. */
  67686. private static _SetAlphaMode;
  67687. /**
  67688. * Converts a Babylon Standard Material to a glTF Material
  67689. * @param babylonStandardMaterial BJS Standard Material
  67690. * @param mimeType mime type to use for the textures
  67691. * @param images array of glTF image interfaces
  67692. * @param textures array of glTF texture interfaces
  67693. * @param materials array of glTF material interfaces
  67694. * @param imageData map of image file name to data
  67695. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67696. */
  67697. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67698. /**
  67699. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  67700. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  67701. * @param mimeType mime type to use for the textures
  67702. * @param images array of glTF image interfaces
  67703. * @param textures array of glTF texture interfaces
  67704. * @param materials array of glTF material interfaces
  67705. * @param imageData map of image file name to data
  67706. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67707. */
  67708. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67709. /**
  67710. * Converts an image typed array buffer to a base64 image
  67711. * @param buffer typed array buffer
  67712. * @param width width of the image
  67713. * @param height height of the image
  67714. * @param mimeType mimetype of the image
  67715. * @returns base64 image string
  67716. */
  67717. private _createBase64FromCanvasAsync;
  67718. /**
  67719. * Generates a white texture based on the specified width and height
  67720. * @param width width of the texture in pixels
  67721. * @param height height of the texture in pixels
  67722. * @param scene babylonjs scene
  67723. * @returns white texture
  67724. */
  67725. private _createWhiteTexture;
  67726. /**
  67727. * 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
  67728. * @param texture1 first texture to resize
  67729. * @param texture2 second texture to resize
  67730. * @param scene babylonjs scene
  67731. * @returns resized textures or null
  67732. */
  67733. private _resizeTexturesToSameDimensions;
  67734. /**
  67735. * Converts an array of pixels to a Float32Array
  67736. * Throws an error if the pixel format is not supported
  67737. * @param pixels - array buffer containing pixel values
  67738. * @returns Float32 of pixels
  67739. */
  67740. private _convertPixelArrayToFloat32;
  67741. /**
  67742. * Convert Specular Glossiness Textures to Metallic Roughness
  67743. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  67744. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  67745. * @param diffuseTexture texture used to store diffuse information
  67746. * @param specularGlossinessTexture texture used to store specular and glossiness information
  67747. * @param factors specular glossiness material factors
  67748. * @param mimeType the mime type to use for the texture
  67749. * @returns pbr metallic roughness interface or null
  67750. */
  67751. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  67752. /**
  67753. * Converts specular glossiness material properties to metallic roughness
  67754. * @param specularGlossiness interface with specular glossiness material properties
  67755. * @returns interface with metallic roughness material properties
  67756. */
  67757. private _convertSpecularGlossinessToMetallicRoughness;
  67758. /**
  67759. * Calculates the surface reflectance, independent of lighting conditions
  67760. * @param color Color source to calculate brightness from
  67761. * @returns number representing the perceived brightness, or zero if color is undefined
  67762. */
  67763. private _getPerceivedBrightness;
  67764. /**
  67765. * Returns the maximum color component value
  67766. * @param color
  67767. * @returns maximum color component value, or zero if color is null or undefined
  67768. */
  67769. private _getMaxComponent;
  67770. /**
  67771. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  67772. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  67773. * @param mimeType mime type to use for the textures
  67774. * @param images array of glTF image interfaces
  67775. * @param textures array of glTF texture interfaces
  67776. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  67777. * @param imageData map of image file name to data
  67778. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67779. * @returns glTF PBR Metallic Roughness factors
  67780. */
  67781. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  67782. private _getGLTFTextureSampler;
  67783. private _getGLTFTextureWrapMode;
  67784. private _getGLTFTextureWrapModesSampler;
  67785. /**
  67786. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  67787. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  67788. * @param mimeType mime type to use for the textures
  67789. * @param images array of glTF image interfaces
  67790. * @param textures array of glTF texture interfaces
  67791. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  67792. * @param imageData map of image file name to data
  67793. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67794. * @returns glTF PBR Metallic Roughness factors
  67795. */
  67796. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  67797. /**
  67798. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  67799. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  67800. * @param mimeType mime type to use for the textures
  67801. * @param images array of glTF image interfaces
  67802. * @param textures array of glTF texture interfaces
  67803. * @param materials array of glTF material interfaces
  67804. * @param imageData map of image file name to data
  67805. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67806. */
  67807. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67808. private setMetallicRoughnessPbrMaterial;
  67809. private getPixelsFromTexture;
  67810. /**
  67811. * Extracts a texture from a Babylon texture into file data and glTF data
  67812. * @param babylonTexture Babylon texture to extract
  67813. * @param mimeType Mime Type of the babylonTexture
  67814. * @return glTF texture info, or null if the texture format is not supported
  67815. */
  67816. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  67817. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  67818. /**
  67819. * Builds a texture from base64 string
  67820. * @param base64Texture base64 texture string
  67821. * @param baseTextureName Name to use for the texture
  67822. * @param mimeType image mime type for the texture
  67823. * @param images array of images
  67824. * @param textures array of textures
  67825. * @param imageData map of image data
  67826. * @returns glTF texture info, or null if the texture format is not supported
  67827. */
  67828. private _getTextureInfoFromBase64;
  67829. }
  67830. }
  67831. declare module BABYLON {
  67832. /**
  67833. * Class for holding and downloading glTF file data
  67834. */
  67835. export class GLTFData {
  67836. /**
  67837. * Object which contains the file name as the key and its data as the value
  67838. */
  67839. glTFFiles: {
  67840. [fileName: string]: string | Blob;
  67841. };
  67842. /**
  67843. * Initializes the glTF file object
  67844. */
  67845. constructor();
  67846. /**
  67847. * Downloads the glTF data as files based on their names and data
  67848. */
  67849. downloadFiles(): void;
  67850. }
  67851. }
  67852. declare module BABYLON {
  67853. /**
  67854. * Holds a collection of exporter options and parameters
  67855. */
  67856. export interface IExportOptions {
  67857. /**
  67858. * Function which indicates whether a babylon node should be exported or not
  67859. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  67860. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  67861. */
  67862. shouldExportNode?(node: Node): boolean;
  67863. /**
  67864. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  67865. * @param metadata source metadata to read from
  67866. * @returns the data to store to glTF node extras
  67867. */
  67868. metadataSelector?(metadata: any): any;
  67869. /**
  67870. * The sample rate to bake animation curves
  67871. */
  67872. animationSampleRate?: number;
  67873. /**
  67874. * Begin serialization without waiting for the scene to be ready
  67875. */
  67876. exportWithoutWaitingForScene?: boolean;
  67877. }
  67878. /**
  67879. * Class for generating glTF data from a Babylon scene.
  67880. */
  67881. export class GLTF2Export {
  67882. /**
  67883. * Exports the geometry of the scene to .gltf file format asynchronously
  67884. * @param scene Babylon scene with scene hierarchy information
  67885. * @param filePrefix File prefix to use when generating the glTF file
  67886. * @param options Exporter options
  67887. * @returns Returns an object with a .gltf file and associates texture names
  67888. * as keys and their data and paths as values
  67889. */
  67890. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  67891. private static _PreExportAsync;
  67892. private static _PostExportAsync;
  67893. /**
  67894. * Exports the geometry of the scene to .glb file format asychronously
  67895. * @param scene Babylon scene with scene hierarchy information
  67896. * @param filePrefix File prefix to use when generating glb file
  67897. * @param options Exporter options
  67898. * @returns Returns an object with a .glb filename as key and data as value
  67899. */
  67900. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  67901. }
  67902. }
  67903. declare module BABYLON.GLTF2.Exporter {
  67904. /**
  67905. * @hidden
  67906. */
  67907. export class _GLTFUtilities {
  67908. /**
  67909. * Creates a buffer view based on the supplied arguments
  67910. * @param bufferIndex index value of the specified buffer
  67911. * @param byteOffset byte offset value
  67912. * @param byteLength byte length of the bufferView
  67913. * @param byteStride byte distance between conequential elements
  67914. * @param name name of the buffer view
  67915. * @returns bufferView for glTF
  67916. */
  67917. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  67918. /**
  67919. * Creates an accessor based on the supplied arguments
  67920. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  67921. * @param name The name of the accessor
  67922. * @param type The type of the accessor
  67923. * @param componentType The datatype of components in the attribute
  67924. * @param count The number of attributes referenced by this accessor
  67925. * @param byteOffset The offset relative to the start of the bufferView in bytes
  67926. * @param min Minimum value of each component in this attribute
  67927. * @param max Maximum value of each component in this attribute
  67928. * @returns accessor for glTF
  67929. */
  67930. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  67931. /**
  67932. * Calculates the minimum and maximum values of an array of position floats
  67933. * @param positions Positions array of a mesh
  67934. * @param vertexStart Starting vertex offset to calculate min and max values
  67935. * @param vertexCount Number of vertices to check for min and max values
  67936. * @returns min number array and max number array
  67937. */
  67938. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  67939. min: number[];
  67940. max: number[];
  67941. };
  67942. /**
  67943. * Converts a new right-handed Vector3
  67944. * @param vector vector3 array
  67945. * @returns right-handed Vector3
  67946. */
  67947. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  67948. /**
  67949. * Converts a Vector3 to right-handed
  67950. * @param vector Vector3 to convert to right-handed
  67951. */
  67952. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  67953. /**
  67954. * Converts a three element number array to right-handed
  67955. * @param vector number array to convert to right-handed
  67956. */
  67957. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  67958. /**
  67959. * Converts a new right-handed Vector3
  67960. * @param vector vector3 array
  67961. * @returns right-handed Vector3
  67962. */
  67963. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  67964. /**
  67965. * Converts a Vector3 to right-handed
  67966. * @param vector Vector3 to convert to right-handed
  67967. */
  67968. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  67969. /**
  67970. * Converts a three element number array to right-handed
  67971. * @param vector number array to convert to right-handed
  67972. */
  67973. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  67974. /**
  67975. * Converts a Vector4 to right-handed
  67976. * @param vector Vector4 to convert to right-handed
  67977. */
  67978. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  67979. /**
  67980. * Converts a Vector4 to right-handed
  67981. * @param vector Vector4 to convert to right-handed
  67982. */
  67983. static _GetRightHandedArray4FromRef(vector: number[]): void;
  67984. /**
  67985. * Converts a Quaternion to right-handed
  67986. * @param quaternion Source quaternion to convert to right-handed
  67987. */
  67988. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  67989. /**
  67990. * Converts a Quaternion to right-handed
  67991. * @param quaternion Source quaternion to convert to right-handed
  67992. */
  67993. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  67994. static _NormalizeTangentFromRef(tangent: Vector4): void;
  67995. }
  67996. }
  67997. declare module BABYLON.GLTF2.Exporter {
  67998. /**
  67999. * Converts Babylon Scene into glTF 2.0.
  68000. * @hidden
  68001. */
  68002. export class _Exporter {
  68003. /**
  68004. * Stores the glTF to export
  68005. */
  68006. _glTF: IGLTF;
  68007. /**
  68008. * Stores all generated buffer views, which represents views into the main glTF buffer data
  68009. */
  68010. _bufferViews: IBufferView[];
  68011. /**
  68012. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  68013. */
  68014. _accessors: IAccessor[];
  68015. /**
  68016. * Stores all the generated nodes, which contains transform and/or mesh information per node
  68017. */
  68018. private _nodes;
  68019. /**
  68020. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  68021. */
  68022. private _scenes;
  68023. /**
  68024. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  68025. */
  68026. private _meshes;
  68027. /**
  68028. * Stores all the generated material information, which represents the appearance of each primitive
  68029. */
  68030. _materials: IMaterial[];
  68031. _materialMap: {
  68032. [materialID: number]: number;
  68033. };
  68034. /**
  68035. * Stores all the generated texture information, which is referenced by glTF materials
  68036. */
  68037. _textures: ITexture[];
  68038. /**
  68039. * Stores all the generated image information, which is referenced by glTF textures
  68040. */
  68041. _images: IImage[];
  68042. /**
  68043. * Stores all the texture samplers
  68044. */
  68045. _samplers: ISampler[];
  68046. /**
  68047. * Stores all the generated animation samplers, which is referenced by glTF animations
  68048. */
  68049. /**
  68050. * Stores the animations for glTF models
  68051. */
  68052. private _animations;
  68053. /**
  68054. * Stores the total amount of bytes stored in the glTF buffer
  68055. */
  68056. private _totalByteLength;
  68057. /**
  68058. * Stores a reference to the Babylon scene containing the source geometry and material information
  68059. */
  68060. _babylonScene: Scene;
  68061. /**
  68062. * Stores a map of the image data, where the key is the file name and the value
  68063. * is the image data
  68064. */
  68065. _imageData: {
  68066. [fileName: string]: {
  68067. data: Uint8Array;
  68068. mimeType: ImageMimeType;
  68069. };
  68070. };
  68071. /**
  68072. * Stores a map of the unique id of a node to its index in the node array
  68073. */
  68074. private _nodeMap;
  68075. /**
  68076. * Specifies if the Babylon scene should be converted to right-handed on export
  68077. */
  68078. _convertToRightHandedSystem: boolean;
  68079. /**
  68080. * Baked animation sample rate
  68081. */
  68082. private _animationSampleRate;
  68083. private _options;
  68084. private _localEngine;
  68085. _glTFMaterialExporter: _GLTFMaterialExporter;
  68086. private _extensions;
  68087. private static _ExtensionNames;
  68088. private static _ExtensionFactories;
  68089. private _applyExtensions;
  68090. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  68091. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  68092. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  68093. private _forEachExtensions;
  68094. private _extensionsOnExporting;
  68095. /**
  68096. * Load glTF serializer extensions
  68097. */
  68098. private _loadExtensions;
  68099. /**
  68100. * Creates a glTF Exporter instance, which can accept optional exporter options
  68101. * @param babylonScene Babylon scene object
  68102. * @param options Options to modify the behavior of the exporter
  68103. */
  68104. constructor(babylonScene: Scene, options?: IExportOptions);
  68105. /**
  68106. * Registers a glTF exporter extension
  68107. * @param name Name of the extension to export
  68108. * @param factory The factory function that creates the exporter extension
  68109. */
  68110. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  68111. /**
  68112. * Un-registers an exporter extension
  68113. * @param name The name fo the exporter extension
  68114. * @returns A boolean indicating whether the extension has been un-registered
  68115. */
  68116. static UnregisterExtension(name: string): boolean;
  68117. /**
  68118. * Lazy load a local engine with premultiplied alpha set to false
  68119. */
  68120. _getLocalEngine(): Engine;
  68121. private reorderIndicesBasedOnPrimitiveMode;
  68122. /**
  68123. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  68124. * clock-wise during export to glTF
  68125. * @param submesh BabylonJS submesh
  68126. * @param primitiveMode Primitive mode of the mesh
  68127. * @param sideOrientation the winding order of the submesh
  68128. * @param vertexBufferKind The type of vertex attribute
  68129. * @param meshAttributeArray The vertex attribute data
  68130. * @param byteOffset The offset to the binary data
  68131. * @param binaryWriter The binary data for the glTF file
  68132. */
  68133. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  68134. /**
  68135. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  68136. * clock-wise during export to glTF
  68137. * @param submesh BabylonJS submesh
  68138. * @param primitiveMode Primitive mode of the mesh
  68139. * @param sideOrientation the winding order of the submesh
  68140. * @param vertexBufferKind The type of vertex attribute
  68141. * @param meshAttributeArray The vertex attribute data
  68142. * @param byteOffset The offset to the binary data
  68143. * @param binaryWriter The binary data for the glTF file
  68144. */
  68145. private reorderTriangleFillMode;
  68146. /**
  68147. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  68148. * clock-wise during export to glTF
  68149. * @param submesh BabylonJS submesh
  68150. * @param primitiveMode Primitive mode of the mesh
  68151. * @param sideOrientation the winding order of the submesh
  68152. * @param vertexBufferKind The type of vertex attribute
  68153. * @param meshAttributeArray The vertex attribute data
  68154. * @param byteOffset The offset to the binary data
  68155. * @param binaryWriter The binary data for the glTF file
  68156. */
  68157. private reorderTriangleStripDrawMode;
  68158. /**
  68159. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  68160. * clock-wise during export to glTF
  68161. * @param submesh BabylonJS submesh
  68162. * @param primitiveMode Primitive mode of the mesh
  68163. * @param sideOrientation the winding order of the submesh
  68164. * @param vertexBufferKind The type of vertex attribute
  68165. * @param meshAttributeArray The vertex attribute data
  68166. * @param byteOffset The offset to the binary data
  68167. * @param binaryWriter The binary data for the glTF file
  68168. */
  68169. private reorderTriangleFanMode;
  68170. /**
  68171. * Writes the vertex attribute data to binary
  68172. * @param vertices The vertices to write to the binary writer
  68173. * @param byteOffset The offset into the binary writer to overwrite binary data
  68174. * @param vertexAttributeKind The vertex attribute type
  68175. * @param meshAttributeArray The vertex attribute data
  68176. * @param binaryWriter The writer containing the binary data
  68177. */
  68178. private writeVertexAttributeData;
  68179. /**
  68180. * Writes mesh attribute data to a data buffer
  68181. * Returns the bytelength of the data
  68182. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  68183. * @param meshAttributeArray Array containing the attribute data
  68184. * @param binaryWriter The buffer to write the binary data to
  68185. * @param indices Used to specify the order of the vertex data
  68186. */
  68187. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  68188. /**
  68189. * Generates glTF json data
  68190. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  68191. * @param glTFPrefix Text to use when prefixing a glTF file
  68192. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  68193. * @returns json data as string
  68194. */
  68195. private generateJSON;
  68196. /**
  68197. * Generates data for .gltf and .bin files based on the glTF prefix string
  68198. * @param glTFPrefix Text to use when prefixing a glTF file
  68199. * @returns GLTFData with glTF file data
  68200. */
  68201. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  68202. /**
  68203. * Creates a binary buffer for glTF
  68204. * @returns array buffer for binary data
  68205. */
  68206. private _generateBinaryAsync;
  68207. /**
  68208. * Pads the number to a multiple of 4
  68209. * @param num number to pad
  68210. * @returns padded number
  68211. */
  68212. private _getPadding;
  68213. /**
  68214. * Generates a glb file from the json and binary data
  68215. * Returns an object with the glb file name as the key and data as the value
  68216. * @param glTFPrefix
  68217. * @returns object with glb filename as key and data as value
  68218. */
  68219. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  68220. /**
  68221. * Sets the TRS for each node
  68222. * @param node glTF Node for storing the transformation data
  68223. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  68224. */
  68225. private setNodeTransformation;
  68226. private getVertexBufferFromMesh;
  68227. /**
  68228. * Creates a bufferview based on the vertices type for the Babylon mesh
  68229. * @param kind Indicates the type of vertices data
  68230. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  68231. * @param binaryWriter The buffer to write the bufferview data to
  68232. */
  68233. private createBufferViewKind;
  68234. /**
  68235. * The primitive mode of the Babylon mesh
  68236. * @param babylonMesh The BabylonJS mesh
  68237. */
  68238. private getMeshPrimitiveMode;
  68239. /**
  68240. * Sets the primitive mode of the glTF mesh primitive
  68241. * @param meshPrimitive glTF mesh primitive
  68242. * @param primitiveMode The primitive mode
  68243. */
  68244. private setPrimitiveMode;
  68245. /**
  68246. * Sets the vertex attribute accessor based of the glTF mesh primitive
  68247. * @param meshPrimitive glTF mesh primitive
  68248. * @param attributeKind vertex attribute
  68249. * @returns boolean specifying if uv coordinates are present
  68250. */
  68251. private setAttributeKind;
  68252. /**
  68253. * Sets data for the primitive attributes of each submesh
  68254. * @param mesh glTF Mesh object to store the primitive attribute information
  68255. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  68256. * @param binaryWriter Buffer to write the attribute data to
  68257. */
  68258. private setPrimitiveAttributesAsync;
  68259. /**
  68260. * Creates a glTF scene based on the array of meshes
  68261. * Returns the the total byte offset
  68262. * @param babylonScene Babylon scene to get the mesh data from
  68263. * @param binaryWriter Buffer to write binary data to
  68264. */
  68265. private createSceneAsync;
  68266. /**
  68267. * Creates a mapping of Node unique id to node index and handles animations
  68268. * @param babylonScene Babylon Scene
  68269. * @param nodes Babylon transform nodes
  68270. * @param binaryWriter Buffer to write binary data to
  68271. * @returns Node mapping of unique id to index
  68272. */
  68273. private createNodeMapAndAnimationsAsync;
  68274. /**
  68275. * Creates a glTF node from a Babylon mesh
  68276. * @param babylonMesh Source Babylon mesh
  68277. * @param binaryWriter Buffer for storing geometry data
  68278. * @returns glTF node
  68279. */
  68280. private createNodeAsync;
  68281. }
  68282. /**
  68283. * @hidden
  68284. *
  68285. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  68286. */
  68287. export class _BinaryWriter {
  68288. /**
  68289. * Array buffer which stores all binary data
  68290. */
  68291. private _arrayBuffer;
  68292. /**
  68293. * View of the array buffer
  68294. */
  68295. private _dataView;
  68296. /**
  68297. * byte offset of data in array buffer
  68298. */
  68299. private _byteOffset;
  68300. /**
  68301. * Initialize binary writer with an initial byte length
  68302. * @param byteLength Initial byte length of the array buffer
  68303. */
  68304. constructor(byteLength: number);
  68305. /**
  68306. * Resize the array buffer to the specified byte length
  68307. * @param byteLength
  68308. */
  68309. private resizeBuffer;
  68310. /**
  68311. * Get an array buffer with the length of the byte offset
  68312. * @returns ArrayBuffer resized to the byte offset
  68313. */
  68314. getArrayBuffer(): ArrayBuffer;
  68315. /**
  68316. * Get the byte offset of the array buffer
  68317. * @returns byte offset
  68318. */
  68319. getByteOffset(): number;
  68320. /**
  68321. * Stores an UInt8 in the array buffer
  68322. * @param entry
  68323. * @param byteOffset If defined, specifies where to set the value as an offset.
  68324. */
  68325. setUInt8(entry: number, byteOffset?: number): void;
  68326. /**
  68327. * Gets an UInt32 in the array buffer
  68328. * @param entry
  68329. * @param byteOffset If defined, specifies where to set the value as an offset.
  68330. */
  68331. getUInt32(byteOffset: number): number;
  68332. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  68333. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  68334. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  68335. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  68336. /**
  68337. * Stores a Float32 in the array buffer
  68338. * @param entry
  68339. */
  68340. setFloat32(entry: number, byteOffset?: number): void;
  68341. /**
  68342. * Stores an UInt32 in the array buffer
  68343. * @param entry
  68344. * @param byteOffset If defined, specifies where to set the value as an offset.
  68345. */
  68346. setUInt32(entry: number, byteOffset?: number): void;
  68347. }
  68348. }
  68349. declare module BABYLON.GLTF2.Exporter {
  68350. /**
  68351. * @hidden
  68352. * Interface to store animation data.
  68353. */
  68354. export interface _IAnimationData {
  68355. /**
  68356. * Keyframe data.
  68357. */
  68358. inputs: number[];
  68359. /**
  68360. * Value data.
  68361. */
  68362. outputs: number[][];
  68363. /**
  68364. * Animation interpolation data.
  68365. */
  68366. samplerInterpolation: AnimationSamplerInterpolation;
  68367. /**
  68368. * Minimum keyframe value.
  68369. */
  68370. inputsMin: number;
  68371. /**
  68372. * Maximum keyframe value.
  68373. */
  68374. inputsMax: number;
  68375. }
  68376. /**
  68377. * @hidden
  68378. */
  68379. export interface _IAnimationInfo {
  68380. /**
  68381. * The target channel for the animation
  68382. */
  68383. animationChannelTargetPath: AnimationChannelTargetPath;
  68384. /**
  68385. * The glTF accessor type for the data.
  68386. */
  68387. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  68388. /**
  68389. * Specifies if quaternions should be used.
  68390. */
  68391. useQuaternion: boolean;
  68392. }
  68393. /**
  68394. * @hidden
  68395. * Utility class for generating glTF animation data from BabylonJS.
  68396. */
  68397. export class _GLTFAnimation {
  68398. /**
  68399. * @ignore
  68400. *
  68401. * Creates glTF channel animation from BabylonJS animation.
  68402. * @param babylonTransformNode - BabylonJS mesh.
  68403. * @param animation - animation.
  68404. * @param animationChannelTargetPath - The target animation channel.
  68405. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  68406. * @param useQuaternion - Specifies if quaternions are used.
  68407. * @returns nullable IAnimationData
  68408. */
  68409. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  68410. private static _DeduceAnimationInfo;
  68411. /**
  68412. * @ignore
  68413. * Create node animations from the transform node animations
  68414. * @param babylonNode
  68415. * @param runtimeGLTFAnimation
  68416. * @param idleGLTFAnimations
  68417. * @param nodeMap
  68418. * @param nodes
  68419. * @param binaryWriter
  68420. * @param bufferViews
  68421. * @param accessors
  68422. * @param convertToRightHandedSystem
  68423. */
  68424. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  68425. [key: number]: number;
  68426. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  68427. /**
  68428. * @ignore
  68429. * Create node animations from the animation groups
  68430. * @param babylonScene
  68431. * @param glTFAnimations
  68432. * @param nodeMap
  68433. * @param nodes
  68434. * @param binaryWriter
  68435. * @param bufferViews
  68436. * @param accessors
  68437. * @param convertToRightHandedSystem
  68438. */
  68439. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  68440. [key: number]: number;
  68441. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  68442. private static AddAnimation;
  68443. /**
  68444. * Create a baked animation
  68445. * @param babylonTransformNode BabylonJS mesh
  68446. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  68447. * @param animationChannelTargetPath animation target channel
  68448. * @param minFrame minimum animation frame
  68449. * @param maxFrame maximum animation frame
  68450. * @param fps frames per second of the animation
  68451. * @param inputs input key frames of the animation
  68452. * @param outputs output key frame data of the animation
  68453. * @param convertToRightHandedSystem converts the values to right-handed
  68454. * @param useQuaternion specifies if quaternions should be used
  68455. */
  68456. private static _CreateBakedAnimation;
  68457. private static _ConvertFactorToVector3OrQuaternion;
  68458. private static _SetInterpolatedValue;
  68459. /**
  68460. * Creates linear animation from the animation key frames
  68461. * @param babylonTransformNode BabylonJS mesh
  68462. * @param animation BabylonJS animation
  68463. * @param animationChannelTargetPath The target animation channel
  68464. * @param frameDelta The difference between the last and first frame of the animation
  68465. * @param inputs Array to store the key frame times
  68466. * @param outputs Array to store the key frame data
  68467. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  68468. * @param useQuaternion Specifies if quaternions are used in the animation
  68469. */
  68470. private static _CreateLinearOrStepAnimation;
  68471. /**
  68472. * Creates cubic spline animation from the animation key frames
  68473. * @param babylonTransformNode BabylonJS mesh
  68474. * @param animation BabylonJS animation
  68475. * @param animationChannelTargetPath The target animation channel
  68476. * @param frameDelta The difference between the last and first frame of the animation
  68477. * @param inputs Array to store the key frame times
  68478. * @param outputs Array to store the key frame data
  68479. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  68480. * @param useQuaternion Specifies if quaternions are used in the animation
  68481. */
  68482. private static _CreateCubicSplineAnimation;
  68483. private static _GetBasePositionRotationOrScale;
  68484. /**
  68485. * Adds a key frame value
  68486. * @param keyFrame
  68487. * @param animation
  68488. * @param outputs
  68489. * @param animationChannelTargetPath
  68490. * @param basePositionRotationOrScale
  68491. * @param convertToRightHandedSystem
  68492. * @param useQuaternion
  68493. */
  68494. private static _AddKeyframeValue;
  68495. /**
  68496. * Determine the interpolation based on the key frames
  68497. * @param keyFrames
  68498. * @param animationChannelTargetPath
  68499. * @param useQuaternion
  68500. */
  68501. private static _DeduceInterpolation;
  68502. /**
  68503. * Adds an input tangent or output tangent to the output data
  68504. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  68505. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  68506. * @param outputs The animation data by keyframe
  68507. * @param animationChannelTargetPath The target animation channel
  68508. * @param interpolation The interpolation type
  68509. * @param keyFrame The key frame with the animation data
  68510. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  68511. * @param useQuaternion Specifies if quaternions are used
  68512. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  68513. */
  68514. private static AddSplineTangent;
  68515. /**
  68516. * Get the minimum and maximum key frames' frame values
  68517. * @param keyFrames animation key frames
  68518. * @returns the minimum and maximum key frame value
  68519. */
  68520. private static calculateMinMaxKeyFrames;
  68521. }
  68522. }
  68523. declare module BABYLON.GLTF2.Exporter {
  68524. /** @hidden */
  68525. export var textureTransformPixelShader: {
  68526. name: string;
  68527. shader: string;
  68528. };
  68529. }
  68530. declare module BABYLON.GLTF2.Exporter.Extensions {
  68531. /**
  68532. * @hidden
  68533. */
  68534. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  68535. /** Name of this extension */
  68536. readonly name: string;
  68537. /** Defines whether this extension is enabled */
  68538. enabled: boolean;
  68539. /** Defines whether this extension is required */
  68540. required: boolean;
  68541. /** Reference to the glTF exporter */
  68542. private _exporter;
  68543. constructor(exporter: _Exporter);
  68544. dispose(): void;
  68545. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  68546. /**
  68547. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  68548. * @param babylonTexture
  68549. * @param offset
  68550. * @param rotation
  68551. * @param scale
  68552. * @param scene
  68553. */
  68554. private _textureTransformTextureAsync;
  68555. }
  68556. }
  68557. declare module BABYLON.GLTF2.Exporter.Extensions {
  68558. /**
  68559. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  68560. */
  68561. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  68562. /** The name of this extension. */
  68563. readonly name: string;
  68564. /** Defines whether this extension is enabled. */
  68565. enabled: boolean;
  68566. /** Defines whether this extension is required */
  68567. required: boolean;
  68568. /** Reference to the glTF exporter */
  68569. private _exporter;
  68570. private _lights;
  68571. /** @hidden */
  68572. constructor(exporter: _Exporter);
  68573. /** @hidden */
  68574. dispose(): void;
  68575. /** @hidden */
  68576. onExporting(): void;
  68577. /**
  68578. * Define this method to modify the default behavior when exporting a node
  68579. * @param context The context when exporting the node
  68580. * @param node glTF node
  68581. * @param babylonNode BabylonJS node
  68582. * @returns nullable INode promise
  68583. */
  68584. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  68585. }
  68586. }
  68587. declare module BABYLON {
  68588. /**
  68589. * Class for generating STL data from a Babylon scene.
  68590. */
  68591. export class STLExport {
  68592. /**
  68593. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  68594. * @param meshes list defines the mesh to serialize
  68595. * @param download triggers the automatic download of the file.
  68596. * @param fileName changes the downloads fileName.
  68597. * @param binary changes the STL to a binary type.
  68598. * @param isLittleEndian toggle for binary type exporter.
  68599. * @returns the STL as UTF8 string
  68600. */
  68601. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  68602. }
  68603. }
  68604. /**
  68605. * @ignoreChildren
  68606. * @ignore
  68607. */
  68608. declare module "babylonjs-gltf2interface" {
  68609. export = BABYLON.GLTF2;
  68610. }
  68611. /**
  68612. * Module for glTF 2.0 Interface
  68613. * @ignoreChildren
  68614. * @ignore
  68615. */
  68616. declare module BABYLON.GLTF2 {
  68617. /**
  68618. * The datatype of the components in the attribute
  68619. */
  68620. const enum AccessorComponentType {
  68621. /**
  68622. * Byte
  68623. */
  68624. BYTE = 5120,
  68625. /**
  68626. * Unsigned Byte
  68627. */
  68628. UNSIGNED_BYTE = 5121,
  68629. /**
  68630. * Short
  68631. */
  68632. SHORT = 5122,
  68633. /**
  68634. * Unsigned Short
  68635. */
  68636. UNSIGNED_SHORT = 5123,
  68637. /**
  68638. * Unsigned Int
  68639. */
  68640. UNSIGNED_INT = 5125,
  68641. /**
  68642. * Float
  68643. */
  68644. FLOAT = 5126,
  68645. }
  68646. /**
  68647. * Specifies if the attirbute is a scalar, vector, or matrix
  68648. */
  68649. const enum AccessorType {
  68650. /**
  68651. * Scalar
  68652. */
  68653. SCALAR = "SCALAR",
  68654. /**
  68655. * Vector2
  68656. */
  68657. VEC2 = "VEC2",
  68658. /**
  68659. * Vector3
  68660. */
  68661. VEC3 = "VEC3",
  68662. /**
  68663. * Vector4
  68664. */
  68665. VEC4 = "VEC4",
  68666. /**
  68667. * Matrix2x2
  68668. */
  68669. MAT2 = "MAT2",
  68670. /**
  68671. * Matrix3x3
  68672. */
  68673. MAT3 = "MAT3",
  68674. /**
  68675. * Matrix4x4
  68676. */
  68677. MAT4 = "MAT4",
  68678. }
  68679. /**
  68680. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  68681. */
  68682. const enum AnimationChannelTargetPath {
  68683. /**
  68684. * Translation
  68685. */
  68686. TRANSLATION = "translation",
  68687. /**
  68688. * Rotation
  68689. */
  68690. ROTATION = "rotation",
  68691. /**
  68692. * Scale
  68693. */
  68694. SCALE = "scale",
  68695. /**
  68696. * Weights
  68697. */
  68698. WEIGHTS = "weights",
  68699. }
  68700. /**
  68701. * Interpolation algorithm
  68702. */
  68703. const enum AnimationSamplerInterpolation {
  68704. /**
  68705. * The animated values are linearly interpolated between keyframes
  68706. */
  68707. LINEAR = "LINEAR",
  68708. /**
  68709. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  68710. */
  68711. STEP = "STEP",
  68712. /**
  68713. * The animation's interpolation is computed using a cubic spline with specified tangents
  68714. */
  68715. CUBICSPLINE = "CUBICSPLINE",
  68716. }
  68717. /**
  68718. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  68719. */
  68720. const enum CameraType {
  68721. /**
  68722. * A perspective camera containing properties to create a perspective projection matrix
  68723. */
  68724. PERSPECTIVE = "perspective",
  68725. /**
  68726. * An orthographic camera containing properties to create an orthographic projection matrix
  68727. */
  68728. ORTHOGRAPHIC = "orthographic",
  68729. }
  68730. /**
  68731. * The mime-type of the image
  68732. */
  68733. const enum ImageMimeType {
  68734. /**
  68735. * JPEG Mime-type
  68736. */
  68737. JPEG = "image/jpeg",
  68738. /**
  68739. * PNG Mime-type
  68740. */
  68741. PNG = "image/png",
  68742. }
  68743. /**
  68744. * The alpha rendering mode of the material
  68745. */
  68746. const enum MaterialAlphaMode {
  68747. /**
  68748. * The alpha value is ignored and the rendered output is fully opaque
  68749. */
  68750. OPAQUE = "OPAQUE",
  68751. /**
  68752. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  68753. */
  68754. MASK = "MASK",
  68755. /**
  68756. * 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)
  68757. */
  68758. BLEND = "BLEND",
  68759. }
  68760. /**
  68761. * The type of the primitives to render
  68762. */
  68763. const enum MeshPrimitiveMode {
  68764. /**
  68765. * Points
  68766. */
  68767. POINTS = 0,
  68768. /**
  68769. * Lines
  68770. */
  68771. LINES = 1,
  68772. /**
  68773. * Line Loop
  68774. */
  68775. LINE_LOOP = 2,
  68776. /**
  68777. * Line Strip
  68778. */
  68779. LINE_STRIP = 3,
  68780. /**
  68781. * Triangles
  68782. */
  68783. TRIANGLES = 4,
  68784. /**
  68785. * Triangle Strip
  68786. */
  68787. TRIANGLE_STRIP = 5,
  68788. /**
  68789. * Triangle Fan
  68790. */
  68791. TRIANGLE_FAN = 6,
  68792. }
  68793. /**
  68794. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  68795. */
  68796. const enum TextureMagFilter {
  68797. /**
  68798. * Nearest
  68799. */
  68800. NEAREST = 9728,
  68801. /**
  68802. * Linear
  68803. */
  68804. LINEAR = 9729,
  68805. }
  68806. /**
  68807. * Minification filter. All valid values correspond to WebGL enums
  68808. */
  68809. const enum TextureMinFilter {
  68810. /**
  68811. * Nearest
  68812. */
  68813. NEAREST = 9728,
  68814. /**
  68815. * Linear
  68816. */
  68817. LINEAR = 9729,
  68818. /**
  68819. * Nearest Mip-Map Nearest
  68820. */
  68821. NEAREST_MIPMAP_NEAREST = 9984,
  68822. /**
  68823. * Linear Mipmap Nearest
  68824. */
  68825. LINEAR_MIPMAP_NEAREST = 9985,
  68826. /**
  68827. * Nearest Mipmap Linear
  68828. */
  68829. NEAREST_MIPMAP_LINEAR = 9986,
  68830. /**
  68831. * Linear Mipmap Linear
  68832. */
  68833. LINEAR_MIPMAP_LINEAR = 9987,
  68834. }
  68835. /**
  68836. * S (U) wrapping mode. All valid values correspond to WebGL enums
  68837. */
  68838. const enum TextureWrapMode {
  68839. /**
  68840. * Clamp to Edge
  68841. */
  68842. CLAMP_TO_EDGE = 33071,
  68843. /**
  68844. * Mirrored Repeat
  68845. */
  68846. MIRRORED_REPEAT = 33648,
  68847. /**
  68848. * Repeat
  68849. */
  68850. REPEAT = 10497,
  68851. }
  68852. /**
  68853. * glTF Property
  68854. */
  68855. interface IProperty {
  68856. /**
  68857. * Dictionary object with extension-specific objects
  68858. */
  68859. extensions?: {
  68860. [key: string]: any;
  68861. };
  68862. /**
  68863. * Application-Specific data
  68864. */
  68865. extras?: any;
  68866. }
  68867. /**
  68868. * glTF Child of Root Property
  68869. */
  68870. interface IChildRootProperty extends IProperty {
  68871. /**
  68872. * The user-defined name of this object
  68873. */
  68874. name?: string;
  68875. }
  68876. /**
  68877. * Indices of those attributes that deviate from their initialization value
  68878. */
  68879. interface IAccessorSparseIndices extends IProperty {
  68880. /**
  68881. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  68882. */
  68883. bufferView: number;
  68884. /**
  68885. * The offset relative to the start of the bufferView in bytes. Must be aligned
  68886. */
  68887. byteOffset?: number;
  68888. /**
  68889. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  68890. */
  68891. componentType: AccessorComponentType;
  68892. }
  68893. /**
  68894. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  68895. */
  68896. interface IAccessorSparseValues extends IProperty {
  68897. /**
  68898. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  68899. */
  68900. bufferView: number;
  68901. /**
  68902. * The offset relative to the start of the bufferView in bytes. Must be aligned
  68903. */
  68904. byteOffset?: number;
  68905. }
  68906. /**
  68907. * Sparse storage of attributes that deviate from their initialization value
  68908. */
  68909. interface IAccessorSparse extends IProperty {
  68910. /**
  68911. * The number of attributes encoded in this sparse accessor
  68912. */
  68913. count: number;
  68914. /**
  68915. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  68916. */
  68917. indices: IAccessorSparseIndices;
  68918. /**
  68919. * 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
  68920. */
  68921. values: IAccessorSparseValues;
  68922. }
  68923. /**
  68924. * 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
  68925. */
  68926. interface IAccessor extends IChildRootProperty {
  68927. /**
  68928. * The index of the bufferview
  68929. */
  68930. bufferView?: number;
  68931. /**
  68932. * The offset relative to the start of the bufferView in bytes
  68933. */
  68934. byteOffset?: number;
  68935. /**
  68936. * The datatype of components in the attribute
  68937. */
  68938. componentType: AccessorComponentType;
  68939. /**
  68940. * Specifies whether integer data values should be normalized
  68941. */
  68942. normalized?: boolean;
  68943. /**
  68944. * The number of attributes referenced by this accessor
  68945. */
  68946. count: number;
  68947. /**
  68948. * Specifies if the attribute is a scalar, vector, or matrix
  68949. */
  68950. type: AccessorType;
  68951. /**
  68952. * Maximum value of each component in this attribute
  68953. */
  68954. max?: number[];
  68955. /**
  68956. * Minimum value of each component in this attribute
  68957. */
  68958. min?: number[];
  68959. /**
  68960. * Sparse storage of attributes that deviate from their initialization value
  68961. */
  68962. sparse?: IAccessorSparse;
  68963. }
  68964. /**
  68965. * Targets an animation's sampler at a node's property
  68966. */
  68967. interface IAnimationChannel extends IProperty {
  68968. /**
  68969. * The index of a sampler in this animation used to compute the value for the target
  68970. */
  68971. sampler: number;
  68972. /**
  68973. * The index of the node and TRS property to target
  68974. */
  68975. target: IAnimationChannelTarget;
  68976. }
  68977. /**
  68978. * The index of the node and TRS property that an animation channel targets
  68979. */
  68980. interface IAnimationChannelTarget extends IProperty {
  68981. /**
  68982. * The index of the node to target
  68983. */
  68984. node: number;
  68985. /**
  68986. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  68987. */
  68988. path: AnimationChannelTargetPath;
  68989. }
  68990. /**
  68991. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  68992. */
  68993. interface IAnimationSampler extends IProperty {
  68994. /**
  68995. * The index of an accessor containing keyframe input values, e.g., time
  68996. */
  68997. input: number;
  68998. /**
  68999. * Interpolation algorithm
  69000. */
  69001. interpolation?: AnimationSamplerInterpolation;
  69002. /**
  69003. * The index of an accessor, containing keyframe output values
  69004. */
  69005. output: number;
  69006. }
  69007. /**
  69008. * A keyframe animation
  69009. */
  69010. interface IAnimation extends IChildRootProperty {
  69011. /**
  69012. * An array of channels, each of which targets an animation's sampler at a node's property
  69013. */
  69014. channels: IAnimationChannel[];
  69015. /**
  69016. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  69017. */
  69018. samplers: IAnimationSampler[];
  69019. }
  69020. /**
  69021. * Metadata about the glTF asset
  69022. */
  69023. interface IAsset extends IChildRootProperty {
  69024. /**
  69025. * A copyright message suitable for display to credit the content creator
  69026. */
  69027. copyright?: string;
  69028. /**
  69029. * Tool that generated this glTF model. Useful for debugging
  69030. */
  69031. generator?: string;
  69032. /**
  69033. * The glTF version that this asset targets
  69034. */
  69035. version: string;
  69036. /**
  69037. * The minimum glTF version that this asset targets
  69038. */
  69039. minVersion?: string;
  69040. }
  69041. /**
  69042. * A buffer points to binary geometry, animation, or skins
  69043. */
  69044. interface IBuffer extends IChildRootProperty {
  69045. /**
  69046. * 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
  69047. */
  69048. uri?: string;
  69049. /**
  69050. * The length of the buffer in bytes
  69051. */
  69052. byteLength: number;
  69053. }
  69054. /**
  69055. * A view into a buffer generally representing a subset of the buffer
  69056. */
  69057. interface IBufferView extends IChildRootProperty {
  69058. /**
  69059. * The index of the buffer
  69060. */
  69061. buffer: number;
  69062. /**
  69063. * The offset into the buffer in bytes
  69064. */
  69065. byteOffset?: number;
  69066. /**
  69067. * The lenth of the bufferView in bytes
  69068. */
  69069. byteLength: number;
  69070. /**
  69071. * The stride, in bytes
  69072. */
  69073. byteStride?: number;
  69074. }
  69075. /**
  69076. * An orthographic camera containing properties to create an orthographic projection matrix
  69077. */
  69078. interface ICameraOrthographic extends IProperty {
  69079. /**
  69080. * The floating-point horizontal magnification of the view. Must not be zero
  69081. */
  69082. xmag: number;
  69083. /**
  69084. * The floating-point vertical magnification of the view. Must not be zero
  69085. */
  69086. ymag: number;
  69087. /**
  69088. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  69089. */
  69090. zfar: number;
  69091. /**
  69092. * The floating-point distance to the near clipping plane
  69093. */
  69094. znear: number;
  69095. }
  69096. /**
  69097. * A perspective camera containing properties to create a perspective projection matrix
  69098. */
  69099. interface ICameraPerspective extends IProperty {
  69100. /**
  69101. * The floating-point aspect ratio of the field of view
  69102. */
  69103. aspectRatio?: number;
  69104. /**
  69105. * The floating-point vertical field of view in radians
  69106. */
  69107. yfov: number;
  69108. /**
  69109. * The floating-point distance to the far clipping plane
  69110. */
  69111. zfar?: number;
  69112. /**
  69113. * The floating-point distance to the near clipping plane
  69114. */
  69115. znear: number;
  69116. }
  69117. /**
  69118. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  69119. */
  69120. interface ICamera extends IChildRootProperty {
  69121. /**
  69122. * An orthographic camera containing properties to create an orthographic projection matrix
  69123. */
  69124. orthographic?: ICameraOrthographic;
  69125. /**
  69126. * A perspective camera containing properties to create a perspective projection matrix
  69127. */
  69128. perspective?: ICameraPerspective;
  69129. /**
  69130. * Specifies if the camera uses a perspective or orthographic projection
  69131. */
  69132. type: CameraType;
  69133. }
  69134. /**
  69135. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  69136. */
  69137. interface IImage extends IChildRootProperty {
  69138. /**
  69139. * 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
  69140. */
  69141. uri?: string;
  69142. /**
  69143. * The image's MIME type
  69144. */
  69145. mimeType?: ImageMimeType;
  69146. /**
  69147. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  69148. */
  69149. bufferView?: number;
  69150. }
  69151. /**
  69152. * Material Normal Texture Info
  69153. */
  69154. interface IMaterialNormalTextureInfo extends ITextureInfo {
  69155. /**
  69156. * The scalar multiplier applied to each normal vector of the normal texture
  69157. */
  69158. scale?: number;
  69159. }
  69160. /**
  69161. * Material Occlusion Texture Info
  69162. */
  69163. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  69164. /**
  69165. * A scalar multiplier controlling the amount of occlusion applied
  69166. */
  69167. strength?: number;
  69168. }
  69169. /**
  69170. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  69171. */
  69172. interface IMaterialPbrMetallicRoughness {
  69173. /**
  69174. * The material's base color factor
  69175. */
  69176. baseColorFactor?: number[];
  69177. /**
  69178. * The base color texture
  69179. */
  69180. baseColorTexture?: ITextureInfo;
  69181. /**
  69182. * The metalness of the material
  69183. */
  69184. metallicFactor?: number;
  69185. /**
  69186. * The roughness of the material
  69187. */
  69188. roughnessFactor?: number;
  69189. /**
  69190. * The metallic-roughness texture
  69191. */
  69192. metallicRoughnessTexture?: ITextureInfo;
  69193. }
  69194. /**
  69195. * The material appearance of a primitive
  69196. */
  69197. interface IMaterial extends IChildRootProperty {
  69198. /**
  69199. * 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
  69200. */
  69201. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  69202. /**
  69203. * The normal map texture
  69204. */
  69205. normalTexture?: IMaterialNormalTextureInfo;
  69206. /**
  69207. * The occlusion map texture
  69208. */
  69209. occlusionTexture?: IMaterialOcclusionTextureInfo;
  69210. /**
  69211. * The emissive map texture
  69212. */
  69213. emissiveTexture?: ITextureInfo;
  69214. /**
  69215. * 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
  69216. */
  69217. emissiveFactor?: number[];
  69218. /**
  69219. * The alpha rendering mode of the material
  69220. */
  69221. alphaMode?: MaterialAlphaMode;
  69222. /**
  69223. * The alpha cutoff value of the material
  69224. */
  69225. alphaCutoff?: number;
  69226. /**
  69227. * Specifies whether the material is double sided
  69228. */
  69229. doubleSided?: boolean;
  69230. }
  69231. /**
  69232. * Geometry to be rendered with the given material
  69233. */
  69234. interface IMeshPrimitive extends IProperty {
  69235. /**
  69236. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  69237. */
  69238. attributes: {
  69239. [name: string]: number;
  69240. };
  69241. /**
  69242. * The index of the accessor that contains the indices
  69243. */
  69244. indices?: number;
  69245. /**
  69246. * The index of the material to apply to this primitive when rendering
  69247. */
  69248. material?: number;
  69249. /**
  69250. * The type of primitives to render. All valid values correspond to WebGL enums
  69251. */
  69252. mode?: MeshPrimitiveMode;
  69253. /**
  69254. * 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
  69255. */
  69256. targets?: {
  69257. [name: string]: number;
  69258. }[];
  69259. }
  69260. /**
  69261. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  69262. */
  69263. interface IMesh extends IChildRootProperty {
  69264. /**
  69265. * An array of primitives, each defining geometry to be rendered with a material
  69266. */
  69267. primitives: IMeshPrimitive[];
  69268. /**
  69269. * Array of weights to be applied to the Morph Targets
  69270. */
  69271. weights?: number[];
  69272. }
  69273. /**
  69274. * A node in the node hierarchy
  69275. */
  69276. interface INode extends IChildRootProperty {
  69277. /**
  69278. * The index of the camera referenced by this node
  69279. */
  69280. camera?: number;
  69281. /**
  69282. * The indices of this node's children
  69283. */
  69284. children?: number[];
  69285. /**
  69286. * The index of the skin referenced by this node
  69287. */
  69288. skin?: number;
  69289. /**
  69290. * A floating-point 4x4 transformation matrix stored in column-major order
  69291. */
  69292. matrix?: number[];
  69293. /**
  69294. * The index of the mesh in this node
  69295. */
  69296. mesh?: number;
  69297. /**
  69298. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  69299. */
  69300. rotation?: number[];
  69301. /**
  69302. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  69303. */
  69304. scale?: number[];
  69305. /**
  69306. * The node's translation along the x, y, and z axes
  69307. */
  69308. translation?: number[];
  69309. /**
  69310. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  69311. */
  69312. weights?: number[];
  69313. }
  69314. /**
  69315. * Texture sampler properties for filtering and wrapping modes
  69316. */
  69317. interface ISampler extends IChildRootProperty {
  69318. /**
  69319. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  69320. */
  69321. magFilter?: TextureMagFilter;
  69322. /**
  69323. * Minification filter. All valid values correspond to WebGL enums
  69324. */
  69325. minFilter?: TextureMinFilter;
  69326. /**
  69327. * S (U) wrapping mode. All valid values correspond to WebGL enums
  69328. */
  69329. wrapS?: TextureWrapMode;
  69330. /**
  69331. * T (V) wrapping mode. All valid values correspond to WebGL enums
  69332. */
  69333. wrapT?: TextureWrapMode;
  69334. }
  69335. /**
  69336. * The root nodes of a scene
  69337. */
  69338. interface IScene extends IChildRootProperty {
  69339. /**
  69340. * The indices of each root node
  69341. */
  69342. nodes: number[];
  69343. }
  69344. /**
  69345. * Joints and matrices defining a skin
  69346. */
  69347. interface ISkin extends IChildRootProperty {
  69348. /**
  69349. * 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
  69350. */
  69351. inverseBindMatrices?: number;
  69352. /**
  69353. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  69354. */
  69355. skeleton?: number;
  69356. /**
  69357. * 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)
  69358. */
  69359. joints: number[];
  69360. }
  69361. /**
  69362. * A texture and its sampler
  69363. */
  69364. interface ITexture extends IChildRootProperty {
  69365. /**
  69366. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  69367. */
  69368. sampler?: number;
  69369. /**
  69370. * The index of the image used by this texture
  69371. */
  69372. source: number;
  69373. }
  69374. /**
  69375. * Reference to a texture
  69376. */
  69377. interface ITextureInfo extends IProperty {
  69378. /**
  69379. * The index of the texture
  69380. */
  69381. index: number;
  69382. /**
  69383. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  69384. */
  69385. texCoord?: number;
  69386. }
  69387. /**
  69388. * The root object for a glTF asset
  69389. */
  69390. interface IGLTF extends IProperty {
  69391. /**
  69392. * An array of accessors. An accessor is a typed view into a bufferView
  69393. */
  69394. accessors?: IAccessor[];
  69395. /**
  69396. * An array of keyframe animations
  69397. */
  69398. animations?: IAnimation[];
  69399. /**
  69400. * Metadata about the glTF asset
  69401. */
  69402. asset: IAsset;
  69403. /**
  69404. * An array of buffers. A buffer points to binary geometry, animation, or skins
  69405. */
  69406. buffers?: IBuffer[];
  69407. /**
  69408. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  69409. */
  69410. bufferViews?: IBufferView[];
  69411. /**
  69412. * An array of cameras
  69413. */
  69414. cameras?: ICamera[];
  69415. /**
  69416. * Names of glTF extensions used somewhere in this asset
  69417. */
  69418. extensionsUsed?: string[];
  69419. /**
  69420. * Names of glTF extensions required to properly load this asset
  69421. */
  69422. extensionsRequired?: string[];
  69423. /**
  69424. * An array of images. An image defines data used to create a texture
  69425. */
  69426. images?: IImage[];
  69427. /**
  69428. * An array of materials. A material defines the appearance of a primitive
  69429. */
  69430. materials?: IMaterial[];
  69431. /**
  69432. * An array of meshes. A mesh is a set of primitives to be rendered
  69433. */
  69434. meshes?: IMesh[];
  69435. /**
  69436. * An array of nodes
  69437. */
  69438. nodes?: INode[];
  69439. /**
  69440. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  69441. */
  69442. samplers?: ISampler[];
  69443. /**
  69444. * The index of the default scene
  69445. */
  69446. scene?: number;
  69447. /**
  69448. * An array of scenes
  69449. */
  69450. scenes?: IScene[];
  69451. /**
  69452. * An array of skins. A skin is defined by joints and matrices
  69453. */
  69454. skins?: ISkin[];
  69455. /**
  69456. * An array of textures
  69457. */
  69458. textures?: ITexture[];
  69459. }
  69460. /**
  69461. * The glTF validation results
  69462. */
  69463. interface IGLTFValidationResults {
  69464. info: {
  69465. generator: string;
  69466. hasAnimations: boolean;
  69467. hasDefaultScene: boolean;
  69468. hasMaterials: boolean;
  69469. hasMorphTargets: boolean;
  69470. hasSkins: boolean;
  69471. hasTextures: boolean;
  69472. maxAttributesUsed: number;
  69473. primitivesCount: number
  69474. };
  69475. issues: {
  69476. messages: Array<string>;
  69477. numErrors: number;
  69478. numHints: number;
  69479. numInfos: number;
  69480. numWarnings: number;
  69481. truncated: boolean
  69482. };
  69483. mimeType: string;
  69484. uri: string;
  69485. validatedAt: string;
  69486. validatorVersion: string;
  69487. }
  69488. /**
  69489. * The glTF validation options
  69490. */
  69491. interface IGLTFValidationOptions {
  69492. uri?: string;
  69493. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  69494. validateAccessorData?: boolean;
  69495. maxIssues?: number;
  69496. ignoredIssues?: Array<string>;
  69497. severityOverrides?: Object;
  69498. }
  69499. /**
  69500. * The glTF validator object
  69501. */
  69502. interface IGLTFValidator {
  69503. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  69504. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  69505. }
  69506. }
  69507. declare module BABYLON {
  69508. /** @hidden */
  69509. export var cellPixelShader: {
  69510. name: string;
  69511. shader: string;
  69512. };
  69513. }
  69514. declare module BABYLON {
  69515. /** @hidden */
  69516. export var cellVertexShader: {
  69517. name: string;
  69518. shader: string;
  69519. };
  69520. }
  69521. declare module BABYLON {
  69522. export class CellMaterial extends BABYLON.PushMaterial {
  69523. private _diffuseTexture;
  69524. diffuseTexture: BABYLON.BaseTexture;
  69525. diffuseColor: BABYLON.Color3;
  69526. _computeHighLevel: boolean;
  69527. computeHighLevel: boolean;
  69528. private _disableLighting;
  69529. disableLighting: boolean;
  69530. private _maxSimultaneousLights;
  69531. maxSimultaneousLights: number;
  69532. private _renderId;
  69533. constructor(name: string, scene: BABYLON.Scene);
  69534. needAlphaBlending(): boolean;
  69535. needAlphaTesting(): boolean;
  69536. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69537. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69538. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69539. getAnimatables(): BABYLON.IAnimatable[];
  69540. getActiveTextures(): BABYLON.BaseTexture[];
  69541. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69542. dispose(forceDisposeEffect?: boolean): void;
  69543. getClassName(): string;
  69544. clone(name: string): CellMaterial;
  69545. serialize(): any;
  69546. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  69547. }
  69548. }
  69549. declare module BABYLON {
  69550. export class CustomShaderStructure {
  69551. FragmentStore: string;
  69552. VertexStore: string;
  69553. constructor();
  69554. }
  69555. export class ShaderSpecialParts {
  69556. constructor();
  69557. Fragment_Begin: string;
  69558. Fragment_Definitions: string;
  69559. Fragment_MainBegin: string;
  69560. Fragment_Custom_Diffuse: string;
  69561. Fragment_Before_Lights: string;
  69562. Fragment_Before_Fog: string;
  69563. Fragment_Custom_Alpha: string;
  69564. Fragment_Before_FragColor: string;
  69565. Vertex_Begin: string;
  69566. Vertex_Definitions: string;
  69567. Vertex_MainBegin: string;
  69568. Vertex_Before_PositionUpdated: string;
  69569. Vertex_Before_NormalUpdated: string;
  69570. Vertex_MainEnd: string;
  69571. }
  69572. export class CustomMaterial extends BABYLON.StandardMaterial {
  69573. static ShaderIndexer: number;
  69574. CustomParts: ShaderSpecialParts;
  69575. _isCreatedShader: boolean;
  69576. _createdShaderName: string;
  69577. _customUniform: string[];
  69578. _newUniforms: string[];
  69579. _newUniformInstances: any[];
  69580. _newSamplerInstances: BABYLON.Texture[];
  69581. FragmentShader: string;
  69582. VertexShader: string;
  69583. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  69584. ReviewUniform(name: string, arr: string[]): string[];
  69585. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  69586. constructor(name: string, scene: BABYLON.Scene);
  69587. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  69588. Fragment_Begin(shaderPart: string): CustomMaterial;
  69589. Fragment_Definitions(shaderPart: string): CustomMaterial;
  69590. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  69591. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  69592. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  69593. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  69594. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  69595. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  69596. Vertex_Begin(shaderPart: string): CustomMaterial;
  69597. Vertex_Definitions(shaderPart: string): CustomMaterial;
  69598. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  69599. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  69600. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  69601. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  69602. }
  69603. }
  69604. declare module BABYLON {
  69605. export class ShaderAlebdoParts {
  69606. constructor();
  69607. Fragment_Begin: string;
  69608. Fragment_Definitions: string;
  69609. Fragment_MainBegin: string;
  69610. Fragment_Custom_Albedo: string;
  69611. Fragment_Before_Lights: string;
  69612. Fragment_Custom_MetallicRoughness: string;
  69613. Fragment_Custom_MicroSurface: string;
  69614. Fragment_Before_Fog: string;
  69615. Fragment_Custom_Alpha: string;
  69616. Fragment_Before_FragColor: string;
  69617. Vertex_Begin: string;
  69618. Vertex_Definitions: string;
  69619. Vertex_MainBegin: string;
  69620. Vertex_Before_PositionUpdated: string;
  69621. Vertex_Before_NormalUpdated: string;
  69622. Vertex_MainEnd: string;
  69623. }
  69624. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  69625. static ShaderIndexer: number;
  69626. CustomParts: ShaderAlebdoParts;
  69627. _isCreatedShader: boolean;
  69628. _createdShaderName: string;
  69629. _customUniform: string[];
  69630. _newUniforms: string[];
  69631. _newUniformInstances: any[];
  69632. _newSamplerInstances: BABYLON.Texture[];
  69633. FragmentShader: string;
  69634. VertexShader: string;
  69635. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  69636. ReviewUniform(name: string, arr: string[]): string[];
  69637. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  69638. constructor(name: string, scene: BABYLON.Scene);
  69639. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  69640. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  69641. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  69642. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  69643. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  69644. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  69645. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  69646. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  69647. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  69648. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  69649. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  69650. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  69651. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  69652. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  69653. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  69654. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  69655. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  69656. }
  69657. }
  69658. declare module BABYLON {
  69659. /** @hidden */
  69660. export var firePixelShader: {
  69661. name: string;
  69662. shader: string;
  69663. };
  69664. }
  69665. declare module BABYLON {
  69666. /** @hidden */
  69667. export var fireVertexShader: {
  69668. name: string;
  69669. shader: string;
  69670. };
  69671. }
  69672. declare module BABYLON {
  69673. export class FireMaterial extends BABYLON.PushMaterial {
  69674. private _diffuseTexture;
  69675. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  69676. private _distortionTexture;
  69677. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  69678. private _opacityTexture;
  69679. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  69680. diffuseColor: BABYLON.Color3;
  69681. speed: number;
  69682. private _scaledDiffuse;
  69683. private _renderId;
  69684. private _lastTime;
  69685. constructor(name: string, scene: BABYLON.Scene);
  69686. needAlphaBlending(): boolean;
  69687. needAlphaTesting(): boolean;
  69688. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69689. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69690. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69691. getAnimatables(): BABYLON.IAnimatable[];
  69692. getActiveTextures(): BABYLON.BaseTexture[];
  69693. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69694. getClassName(): string;
  69695. dispose(forceDisposeEffect?: boolean): void;
  69696. clone(name: string): FireMaterial;
  69697. serialize(): any;
  69698. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  69699. }
  69700. }
  69701. declare module BABYLON {
  69702. /** @hidden */
  69703. export var furPixelShader: {
  69704. name: string;
  69705. shader: string;
  69706. };
  69707. }
  69708. declare module BABYLON {
  69709. /** @hidden */
  69710. export var furVertexShader: {
  69711. name: string;
  69712. shader: string;
  69713. };
  69714. }
  69715. declare module BABYLON {
  69716. export class FurMaterial extends BABYLON.PushMaterial {
  69717. private _diffuseTexture;
  69718. diffuseTexture: BABYLON.BaseTexture;
  69719. private _heightTexture;
  69720. heightTexture: BABYLON.BaseTexture;
  69721. diffuseColor: BABYLON.Color3;
  69722. furLength: number;
  69723. furAngle: number;
  69724. furColor: BABYLON.Color3;
  69725. furOffset: number;
  69726. furSpacing: number;
  69727. furGravity: BABYLON.Vector3;
  69728. furSpeed: number;
  69729. furDensity: number;
  69730. furOcclusion: number;
  69731. furTexture: BABYLON.DynamicTexture;
  69732. private _disableLighting;
  69733. disableLighting: boolean;
  69734. private _maxSimultaneousLights;
  69735. maxSimultaneousLights: number;
  69736. highLevelFur: boolean;
  69737. _meshes: BABYLON.AbstractMesh[];
  69738. private _renderId;
  69739. private _furTime;
  69740. constructor(name: string, scene: BABYLON.Scene);
  69741. furTime: number;
  69742. needAlphaBlending(): boolean;
  69743. needAlphaTesting(): boolean;
  69744. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69745. updateFur(): void;
  69746. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69747. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69748. getAnimatables(): BABYLON.IAnimatable[];
  69749. getActiveTextures(): BABYLON.BaseTexture[];
  69750. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69751. dispose(forceDisposeEffect?: boolean): void;
  69752. clone(name: string): FurMaterial;
  69753. serialize(): any;
  69754. getClassName(): string;
  69755. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  69756. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  69757. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  69758. }
  69759. }
  69760. declare module BABYLON {
  69761. /** @hidden */
  69762. export var gradientPixelShader: {
  69763. name: string;
  69764. shader: string;
  69765. };
  69766. }
  69767. declare module BABYLON {
  69768. /** @hidden */
  69769. export var gradientVertexShader: {
  69770. name: string;
  69771. shader: string;
  69772. };
  69773. }
  69774. declare module BABYLON {
  69775. export class GradientMaterial extends BABYLON.PushMaterial {
  69776. private _maxSimultaneousLights;
  69777. maxSimultaneousLights: number;
  69778. topColor: BABYLON.Color3;
  69779. topColorAlpha: number;
  69780. bottomColor: BABYLON.Color3;
  69781. bottomColorAlpha: number;
  69782. offset: number;
  69783. scale: number;
  69784. smoothness: number;
  69785. private _disableLighting;
  69786. disableLighting: boolean;
  69787. private _renderId;
  69788. constructor(name: string, scene: BABYLON.Scene);
  69789. needAlphaBlending(): boolean;
  69790. needAlphaTesting(): boolean;
  69791. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69792. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69793. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69794. getAnimatables(): BABYLON.IAnimatable[];
  69795. dispose(forceDisposeEffect?: boolean): void;
  69796. clone(name: string): GradientMaterial;
  69797. serialize(): any;
  69798. getClassName(): string;
  69799. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  69800. }
  69801. }
  69802. declare module BABYLON {
  69803. /** @hidden */
  69804. export var gridPixelShader: {
  69805. name: string;
  69806. shader: string;
  69807. };
  69808. }
  69809. declare module BABYLON {
  69810. /** @hidden */
  69811. export var gridVertexShader: {
  69812. name: string;
  69813. shader: string;
  69814. };
  69815. }
  69816. declare module BABYLON {
  69817. /**
  69818. * The grid materials allows you to wrap any shape with a grid.
  69819. * Colors are customizable.
  69820. */
  69821. export class GridMaterial extends BABYLON.PushMaterial {
  69822. /**
  69823. * Main color of the grid (e.g. between lines)
  69824. */
  69825. mainColor: BABYLON.Color3;
  69826. /**
  69827. * Color of the grid lines.
  69828. */
  69829. lineColor: BABYLON.Color3;
  69830. /**
  69831. * The scale of the grid compared to unit.
  69832. */
  69833. gridRatio: number;
  69834. /**
  69835. * Allows setting an offset for the grid lines.
  69836. */
  69837. gridOffset: BABYLON.Vector3;
  69838. /**
  69839. * The frequency of thicker lines.
  69840. */
  69841. majorUnitFrequency: number;
  69842. /**
  69843. * The visibility of minor units in the grid.
  69844. */
  69845. minorUnitVisibility: number;
  69846. /**
  69847. * The grid opacity outside of the lines.
  69848. */
  69849. opacity: number;
  69850. /**
  69851. * Determine RBG output is premultiplied by alpha value.
  69852. */
  69853. preMultiplyAlpha: boolean;
  69854. private _opacityTexture;
  69855. opacityTexture: BABYLON.BaseTexture;
  69856. private _gridControl;
  69857. private _renderId;
  69858. /**
  69859. * constructor
  69860. * @param name The name given to the material in order to identify it afterwards.
  69861. * @param scene The scene the material is used in.
  69862. */
  69863. constructor(name: string, scene: BABYLON.Scene);
  69864. /**
  69865. * Returns wehter or not the grid requires alpha blending.
  69866. */
  69867. needAlphaBlending(): boolean;
  69868. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  69869. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69870. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69871. /**
  69872. * Dispose the material and its associated resources.
  69873. * @param forceDisposeEffect will also dispose the used effect when true
  69874. */
  69875. dispose(forceDisposeEffect?: boolean): void;
  69876. clone(name: string): GridMaterial;
  69877. serialize(): any;
  69878. getClassName(): string;
  69879. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  69880. }
  69881. }
  69882. declare module BABYLON {
  69883. /** @hidden */
  69884. export var lavaPixelShader: {
  69885. name: string;
  69886. shader: string;
  69887. };
  69888. }
  69889. declare module BABYLON {
  69890. /** @hidden */
  69891. export var lavaVertexShader: {
  69892. name: string;
  69893. shader: string;
  69894. };
  69895. }
  69896. declare module BABYLON {
  69897. export class LavaMaterial extends BABYLON.PushMaterial {
  69898. private _diffuseTexture;
  69899. diffuseTexture: BABYLON.BaseTexture;
  69900. noiseTexture: BABYLON.BaseTexture;
  69901. fogColor: BABYLON.Color3;
  69902. speed: number;
  69903. movingSpeed: number;
  69904. lowFrequencySpeed: number;
  69905. fogDensity: number;
  69906. private _lastTime;
  69907. diffuseColor: BABYLON.Color3;
  69908. private _disableLighting;
  69909. disableLighting: boolean;
  69910. private _unlit;
  69911. unlit: boolean;
  69912. private _maxSimultaneousLights;
  69913. maxSimultaneousLights: number;
  69914. private _scaledDiffuse;
  69915. private _renderId;
  69916. constructor(name: string, scene: BABYLON.Scene);
  69917. needAlphaBlending(): boolean;
  69918. needAlphaTesting(): boolean;
  69919. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69920. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69921. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69922. getAnimatables(): BABYLON.IAnimatable[];
  69923. getActiveTextures(): BABYLON.BaseTexture[];
  69924. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69925. dispose(forceDisposeEffect?: boolean): void;
  69926. clone(name: string): LavaMaterial;
  69927. serialize(): any;
  69928. getClassName(): string;
  69929. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  69930. }
  69931. }
  69932. declare module BABYLON {
  69933. /** @hidden */
  69934. export var mixPixelShader: {
  69935. name: string;
  69936. shader: string;
  69937. };
  69938. }
  69939. declare module BABYLON {
  69940. /** @hidden */
  69941. export var mixVertexShader: {
  69942. name: string;
  69943. shader: string;
  69944. };
  69945. }
  69946. declare module BABYLON {
  69947. export class MixMaterial extends BABYLON.PushMaterial {
  69948. /**
  69949. * Mix textures
  69950. */
  69951. private _mixTexture1;
  69952. mixTexture1: BABYLON.BaseTexture;
  69953. private _mixTexture2;
  69954. mixTexture2: BABYLON.BaseTexture;
  69955. /**
  69956. * Diffuse textures
  69957. */
  69958. private _diffuseTexture1;
  69959. diffuseTexture1: BABYLON.Texture;
  69960. private _diffuseTexture2;
  69961. diffuseTexture2: BABYLON.Texture;
  69962. private _diffuseTexture3;
  69963. diffuseTexture3: BABYLON.Texture;
  69964. private _diffuseTexture4;
  69965. diffuseTexture4: BABYLON.Texture;
  69966. private _diffuseTexture5;
  69967. diffuseTexture5: BABYLON.Texture;
  69968. private _diffuseTexture6;
  69969. diffuseTexture6: BABYLON.Texture;
  69970. private _diffuseTexture7;
  69971. diffuseTexture7: BABYLON.Texture;
  69972. private _diffuseTexture8;
  69973. diffuseTexture8: BABYLON.Texture;
  69974. /**
  69975. * Uniforms
  69976. */
  69977. diffuseColor: BABYLON.Color3;
  69978. specularColor: BABYLON.Color3;
  69979. specularPower: number;
  69980. private _disableLighting;
  69981. disableLighting: boolean;
  69982. private _maxSimultaneousLights;
  69983. maxSimultaneousLights: number;
  69984. private _renderId;
  69985. constructor(name: string, scene: BABYLON.Scene);
  69986. needAlphaBlending(): boolean;
  69987. needAlphaTesting(): boolean;
  69988. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69989. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69990. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69991. getAnimatables(): BABYLON.IAnimatable[];
  69992. getActiveTextures(): BABYLON.BaseTexture[];
  69993. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69994. dispose(forceDisposeEffect?: boolean): void;
  69995. clone(name: string): MixMaterial;
  69996. serialize(): any;
  69997. getClassName(): string;
  69998. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  69999. }
  70000. }
  70001. declare module BABYLON {
  70002. /** @hidden */
  70003. export var normalPixelShader: {
  70004. name: string;
  70005. shader: string;
  70006. };
  70007. }
  70008. declare module BABYLON {
  70009. /** @hidden */
  70010. export var normalVertexShader: {
  70011. name: string;
  70012. shader: string;
  70013. };
  70014. }
  70015. declare module BABYLON {
  70016. export class NormalMaterial extends BABYLON.PushMaterial {
  70017. private _diffuseTexture;
  70018. diffuseTexture: BABYLON.BaseTexture;
  70019. diffuseColor: BABYLON.Color3;
  70020. private _disableLighting;
  70021. disableLighting: boolean;
  70022. private _maxSimultaneousLights;
  70023. maxSimultaneousLights: number;
  70024. private _renderId;
  70025. constructor(name: string, scene: BABYLON.Scene);
  70026. needAlphaBlending(): boolean;
  70027. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  70028. needAlphaTesting(): boolean;
  70029. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70030. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70031. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70032. getAnimatables(): BABYLON.IAnimatable[];
  70033. getActiveTextures(): BABYLON.BaseTexture[];
  70034. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70035. dispose(forceDisposeEffect?: boolean): void;
  70036. clone(name: string): NormalMaterial;
  70037. serialize(): any;
  70038. getClassName(): string;
  70039. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  70040. }
  70041. }
  70042. declare module BABYLON {
  70043. /** @hidden */
  70044. export var shadowOnlyPixelShader: {
  70045. name: string;
  70046. shader: string;
  70047. };
  70048. }
  70049. declare module BABYLON {
  70050. /** @hidden */
  70051. export var shadowOnlyVertexShader: {
  70052. name: string;
  70053. shader: string;
  70054. };
  70055. }
  70056. declare module BABYLON {
  70057. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  70058. private _renderId;
  70059. private _activeLight;
  70060. constructor(name: string, scene: BABYLON.Scene);
  70061. shadowColor: BABYLON.Color3;
  70062. needAlphaBlending(): boolean;
  70063. needAlphaTesting(): boolean;
  70064. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70065. activeLight: BABYLON.IShadowLight;
  70066. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70067. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70068. clone(name: string): ShadowOnlyMaterial;
  70069. serialize(): any;
  70070. getClassName(): string;
  70071. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  70072. }
  70073. }
  70074. declare module BABYLON {
  70075. /** @hidden */
  70076. export var simplePixelShader: {
  70077. name: string;
  70078. shader: string;
  70079. };
  70080. }
  70081. declare module BABYLON {
  70082. /** @hidden */
  70083. export var simpleVertexShader: {
  70084. name: string;
  70085. shader: string;
  70086. };
  70087. }
  70088. declare module BABYLON {
  70089. export class SimpleMaterial extends BABYLON.PushMaterial {
  70090. private _diffuseTexture;
  70091. diffuseTexture: BABYLON.BaseTexture;
  70092. diffuseColor: BABYLON.Color3;
  70093. private _disableLighting;
  70094. disableLighting: boolean;
  70095. private _maxSimultaneousLights;
  70096. maxSimultaneousLights: number;
  70097. private _renderId;
  70098. constructor(name: string, scene: BABYLON.Scene);
  70099. needAlphaBlending(): boolean;
  70100. needAlphaTesting(): boolean;
  70101. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70102. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70103. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70104. getAnimatables(): BABYLON.IAnimatable[];
  70105. getActiveTextures(): BABYLON.BaseTexture[];
  70106. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70107. dispose(forceDisposeEffect?: boolean): void;
  70108. clone(name: string): SimpleMaterial;
  70109. serialize(): any;
  70110. getClassName(): string;
  70111. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  70112. }
  70113. }
  70114. declare module BABYLON {
  70115. /** @hidden */
  70116. export var skyPixelShader: {
  70117. name: string;
  70118. shader: string;
  70119. };
  70120. }
  70121. declare module BABYLON {
  70122. /** @hidden */
  70123. export var skyVertexShader: {
  70124. name: string;
  70125. shader: string;
  70126. };
  70127. }
  70128. declare module BABYLON {
  70129. /**
  70130. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  70131. * @see https://doc.babylonjs.com/extensions/sky
  70132. */
  70133. export class SkyMaterial extends BABYLON.PushMaterial {
  70134. /**
  70135. * Defines the overall luminance of sky in interval ]0, 1[.
  70136. */
  70137. luminance: number;
  70138. /**
  70139. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  70140. */
  70141. turbidity: number;
  70142. /**
  70143. * Defines the sky appearance (light intensity).
  70144. */
  70145. rayleigh: number;
  70146. /**
  70147. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  70148. */
  70149. mieCoefficient: number;
  70150. /**
  70151. * Defines the amount of haze particles following the Mie scattering theory.
  70152. */
  70153. mieDirectionalG: number;
  70154. /**
  70155. * Defines the distance of the sun according to the active scene camera.
  70156. */
  70157. distance: number;
  70158. /**
  70159. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  70160. * "inclined".
  70161. */
  70162. inclination: number;
  70163. /**
  70164. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  70165. * an object direction and a reference direction.
  70166. */
  70167. azimuth: number;
  70168. /**
  70169. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  70170. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  70171. */
  70172. sunPosition: BABYLON.Vector3;
  70173. /**
  70174. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  70175. * .sunPosition property.
  70176. */
  70177. useSunPosition: boolean;
  70178. /**
  70179. * Defines an offset vector used to get a horizon offset.
  70180. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  70181. */
  70182. cameraOffset: BABYLON.Vector3;
  70183. private _cameraPosition;
  70184. private _renderId;
  70185. /**
  70186. * Instantiates a new sky material.
  70187. * This material allows to create dynamic and texture free
  70188. * effects for skyboxes by taking care of the atmosphere state.
  70189. * @see https://doc.babylonjs.com/extensions/sky
  70190. * @param name Define the name of the material in the scene
  70191. * @param scene Define the scene the material belong to
  70192. */
  70193. constructor(name: string, scene: BABYLON.Scene);
  70194. /**
  70195. * Specifies if the material will require alpha blending
  70196. * @returns a boolean specifying if alpha blending is needed
  70197. */
  70198. needAlphaBlending(): boolean;
  70199. /**
  70200. * Specifies if this material should be rendered in alpha test mode
  70201. * @returns false as the sky material doesn't need alpha testing.
  70202. */
  70203. needAlphaTesting(): boolean;
  70204. /**
  70205. * Get the texture used for alpha test purpose.
  70206. * @returns null as the sky material has no texture.
  70207. */
  70208. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70209. /**
  70210. * Get if the submesh is ready to be used and all its information available.
  70211. * Child classes can use it to update shaders
  70212. * @param mesh defines the mesh to check
  70213. * @param subMesh defines which submesh to check
  70214. * @param useInstances specifies that instances should be used
  70215. * @returns a boolean indicating that the submesh is ready or not
  70216. */
  70217. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70218. /**
  70219. * Binds the submesh to this material by preparing the effect and shader to draw
  70220. * @param world defines the world transformation matrix
  70221. * @param mesh defines the mesh containing the submesh
  70222. * @param subMesh defines the submesh to bind the material to
  70223. */
  70224. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70225. /**
  70226. * Get the list of animatables in the material.
  70227. * @returns the list of animatables object used in the material
  70228. */
  70229. getAnimatables(): BABYLON.IAnimatable[];
  70230. /**
  70231. * Disposes the material
  70232. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  70233. */
  70234. dispose(forceDisposeEffect?: boolean): void;
  70235. /**
  70236. * Makes a duplicate of the material, and gives it a new name
  70237. * @param name defines the new name for the duplicated material
  70238. * @returns the cloned material
  70239. */
  70240. clone(name: string): SkyMaterial;
  70241. /**
  70242. * Serializes this material in a JSON representation
  70243. * @returns the serialized material object
  70244. */
  70245. serialize(): any;
  70246. /**
  70247. * Gets the current class name of the material e.g. "SkyMaterial"
  70248. * Mainly use in serialization.
  70249. * @returns the class name
  70250. */
  70251. getClassName(): string;
  70252. /**
  70253. * Creates a sky material from parsed material data
  70254. * @param source defines the JSON representation of the material
  70255. * @param scene defines the hosting scene
  70256. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70257. * @returns a new sky material
  70258. */
  70259. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  70260. }
  70261. }
  70262. declare module BABYLON {
  70263. /** @hidden */
  70264. export var terrainPixelShader: {
  70265. name: string;
  70266. shader: string;
  70267. };
  70268. }
  70269. declare module BABYLON {
  70270. /** @hidden */
  70271. export var terrainVertexShader: {
  70272. name: string;
  70273. shader: string;
  70274. };
  70275. }
  70276. declare module BABYLON {
  70277. export class TerrainMaterial extends BABYLON.PushMaterial {
  70278. private _mixTexture;
  70279. mixTexture: BABYLON.BaseTexture;
  70280. private _diffuseTexture1;
  70281. diffuseTexture1: BABYLON.Texture;
  70282. private _diffuseTexture2;
  70283. diffuseTexture2: BABYLON.Texture;
  70284. private _diffuseTexture3;
  70285. diffuseTexture3: BABYLON.Texture;
  70286. private _bumpTexture1;
  70287. bumpTexture1: BABYLON.Texture;
  70288. private _bumpTexture2;
  70289. bumpTexture2: BABYLON.Texture;
  70290. private _bumpTexture3;
  70291. bumpTexture3: BABYLON.Texture;
  70292. diffuseColor: BABYLON.Color3;
  70293. specularColor: BABYLON.Color3;
  70294. specularPower: number;
  70295. private _disableLighting;
  70296. disableLighting: boolean;
  70297. private _maxSimultaneousLights;
  70298. maxSimultaneousLights: number;
  70299. private _renderId;
  70300. constructor(name: string, scene: BABYLON.Scene);
  70301. needAlphaBlending(): boolean;
  70302. needAlphaTesting(): boolean;
  70303. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70304. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70305. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70306. getAnimatables(): BABYLON.IAnimatable[];
  70307. getActiveTextures(): BABYLON.BaseTexture[];
  70308. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70309. dispose(forceDisposeEffect?: boolean): void;
  70310. clone(name: string): TerrainMaterial;
  70311. serialize(): any;
  70312. getClassName(): string;
  70313. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  70314. }
  70315. }
  70316. declare module BABYLON {
  70317. /** @hidden */
  70318. export var triplanarPixelShader: {
  70319. name: string;
  70320. shader: string;
  70321. };
  70322. }
  70323. declare module BABYLON {
  70324. /** @hidden */
  70325. export var triplanarVertexShader: {
  70326. name: string;
  70327. shader: string;
  70328. };
  70329. }
  70330. declare module BABYLON {
  70331. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  70332. mixTexture: BABYLON.BaseTexture;
  70333. private _diffuseTextureX;
  70334. diffuseTextureX: BABYLON.BaseTexture;
  70335. private _diffuseTextureY;
  70336. diffuseTextureY: BABYLON.BaseTexture;
  70337. private _diffuseTextureZ;
  70338. diffuseTextureZ: BABYLON.BaseTexture;
  70339. private _normalTextureX;
  70340. normalTextureX: BABYLON.BaseTexture;
  70341. private _normalTextureY;
  70342. normalTextureY: BABYLON.BaseTexture;
  70343. private _normalTextureZ;
  70344. normalTextureZ: BABYLON.BaseTexture;
  70345. tileSize: number;
  70346. diffuseColor: BABYLON.Color3;
  70347. specularColor: BABYLON.Color3;
  70348. specularPower: number;
  70349. private _disableLighting;
  70350. disableLighting: boolean;
  70351. private _maxSimultaneousLights;
  70352. maxSimultaneousLights: number;
  70353. private _renderId;
  70354. constructor(name: string, scene: BABYLON.Scene);
  70355. needAlphaBlending(): boolean;
  70356. needAlphaTesting(): boolean;
  70357. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70358. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70359. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70360. getAnimatables(): BABYLON.IAnimatable[];
  70361. getActiveTextures(): BABYLON.BaseTexture[];
  70362. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70363. dispose(forceDisposeEffect?: boolean): void;
  70364. clone(name: string): TriPlanarMaterial;
  70365. serialize(): any;
  70366. getClassName(): string;
  70367. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  70368. }
  70369. }
  70370. declare module BABYLON {
  70371. /** @hidden */
  70372. export var waterPixelShader: {
  70373. name: string;
  70374. shader: string;
  70375. };
  70376. }
  70377. declare module BABYLON {
  70378. /** @hidden */
  70379. export var waterVertexShader: {
  70380. name: string;
  70381. shader: string;
  70382. };
  70383. }
  70384. declare module BABYLON {
  70385. export class WaterMaterial extends BABYLON.PushMaterial {
  70386. renderTargetSize: BABYLON.Vector2;
  70387. private _bumpTexture;
  70388. bumpTexture: BABYLON.BaseTexture;
  70389. diffuseColor: BABYLON.Color3;
  70390. specularColor: BABYLON.Color3;
  70391. specularPower: number;
  70392. private _disableLighting;
  70393. disableLighting: boolean;
  70394. private _maxSimultaneousLights;
  70395. maxSimultaneousLights: number;
  70396. /**
  70397. * @param {number}: Represents the wind force
  70398. */
  70399. windForce: number;
  70400. /**
  70401. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  70402. */
  70403. windDirection: BABYLON.Vector2;
  70404. /**
  70405. * @param {number}: Wave height, represents the height of the waves
  70406. */
  70407. waveHeight: number;
  70408. /**
  70409. * @param {number}: Bump height, represents the bump height related to the bump map
  70410. */
  70411. bumpHeight: number;
  70412. /**
  70413. * @param {boolean}: Add a smaller moving bump to less steady waves.
  70414. */
  70415. private _bumpSuperimpose;
  70416. bumpSuperimpose: boolean;
  70417. /**
  70418. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  70419. */
  70420. private _fresnelSeparate;
  70421. fresnelSeparate: boolean;
  70422. /**
  70423. * @param {boolean}: bump Waves modify the reflection.
  70424. */
  70425. private _bumpAffectsReflection;
  70426. bumpAffectsReflection: boolean;
  70427. /**
  70428. * @param {number}: The water color blended with the refraction (near)
  70429. */
  70430. waterColor: BABYLON.Color3;
  70431. /**
  70432. * @param {number}: The blend factor related to the water color
  70433. */
  70434. colorBlendFactor: number;
  70435. /**
  70436. * @param {number}: The water color blended with the reflection (far)
  70437. */
  70438. waterColor2: BABYLON.Color3;
  70439. /**
  70440. * @param {number}: The blend factor related to the water color (reflection, far)
  70441. */
  70442. colorBlendFactor2: number;
  70443. /**
  70444. * @param {number}: Represents the maximum length of a wave
  70445. */
  70446. waveLength: number;
  70447. /**
  70448. * @param {number}: Defines the waves speed
  70449. */
  70450. waveSpeed: number;
  70451. /**
  70452. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  70453. * will avoid calculating useless pixels in the pixel shader of the water material.
  70454. */
  70455. disableClipPlane: boolean;
  70456. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  70457. private _mesh;
  70458. private _refractionRTT;
  70459. private _reflectionRTT;
  70460. private _reflectionTransform;
  70461. private _lastTime;
  70462. private _lastDeltaTime;
  70463. private _renderId;
  70464. private _useLogarithmicDepth;
  70465. private _waitingRenderList;
  70466. private _imageProcessingConfiguration;
  70467. private _imageProcessingObserver;
  70468. /**
  70469. * Gets a boolean indicating that current material needs to register RTT
  70470. */
  70471. readonly hasRenderTargetTextures: boolean;
  70472. /**
  70473. * Constructor
  70474. */
  70475. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  70476. useLogarithmicDepth: boolean;
  70477. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  70478. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  70479. addToRenderList(node: any): void;
  70480. enableRenderTargets(enable: boolean): void;
  70481. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  70482. readonly renderTargetsEnabled: boolean;
  70483. needAlphaBlending(): boolean;
  70484. needAlphaTesting(): boolean;
  70485. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70486. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70487. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70488. private _createRenderTargets;
  70489. getAnimatables(): BABYLON.IAnimatable[];
  70490. getActiveTextures(): BABYLON.BaseTexture[];
  70491. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70492. dispose(forceDisposeEffect?: boolean): void;
  70493. clone(name: string): WaterMaterial;
  70494. serialize(): any;
  70495. getClassName(): string;
  70496. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  70497. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  70498. }
  70499. }
  70500. declare module BABYLON {
  70501. /** @hidden */
  70502. export var asciiartPixelShader: {
  70503. name: string;
  70504. shader: string;
  70505. };
  70506. }
  70507. declare module BABYLON {
  70508. /**
  70509. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  70510. *
  70511. * It basically takes care rendering the font front the given font size to a texture.
  70512. * This is used later on in the postprocess.
  70513. */
  70514. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  70515. private _font;
  70516. private _text;
  70517. private _charSize;
  70518. /**
  70519. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  70520. */
  70521. readonly charSize: number;
  70522. /**
  70523. * Create a new instance of the Ascii Art FontTexture class
  70524. * @param name the name of the texture
  70525. * @param font the font to use, use the W3C CSS notation
  70526. * @param text the caracter set to use in the rendering.
  70527. * @param scene the scene that owns the texture
  70528. */
  70529. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  70530. /**
  70531. * Gets the max char width of a font.
  70532. * @param font the font to use, use the W3C CSS notation
  70533. * @return the max char width
  70534. */
  70535. private getFontWidth;
  70536. /**
  70537. * Gets the max char height of a font.
  70538. * @param font the font to use, use the W3C CSS notation
  70539. * @return the max char height
  70540. */
  70541. private getFontHeight;
  70542. /**
  70543. * Clones the current AsciiArtTexture.
  70544. * @return the clone of the texture.
  70545. */
  70546. clone(): AsciiArtFontTexture;
  70547. /**
  70548. * Parses a json object representing the texture and returns an instance of it.
  70549. * @param source the source JSON representation
  70550. * @param scene the scene to create the texture for
  70551. * @return the parsed texture
  70552. */
  70553. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  70554. }
  70555. /**
  70556. * Option available in the Ascii Art Post Process.
  70557. */
  70558. export interface IAsciiArtPostProcessOptions {
  70559. /**
  70560. * The font to use following the w3c font definition.
  70561. */
  70562. font?: string;
  70563. /**
  70564. * The character set to use in the postprocess.
  70565. */
  70566. characterSet?: string;
  70567. /**
  70568. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  70569. * This number is defined between 0 and 1;
  70570. */
  70571. mixToTile?: number;
  70572. /**
  70573. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  70574. * This number is defined between 0 and 1;
  70575. */
  70576. mixToNormal?: number;
  70577. }
  70578. /**
  70579. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  70580. *
  70581. * Simmply add it to your scene and let the nerd that lives in you have fun.
  70582. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  70583. */
  70584. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  70585. /**
  70586. * The font texture used to render the char in the post process.
  70587. */
  70588. private _asciiArtFontTexture;
  70589. /**
  70590. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  70591. * This number is defined between 0 and 1;
  70592. */
  70593. mixToTile: number;
  70594. /**
  70595. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  70596. * This number is defined between 0 and 1;
  70597. */
  70598. mixToNormal: number;
  70599. /**
  70600. * Instantiates a new Ascii Art Post Process.
  70601. * @param name the name to give to the postprocess
  70602. * @camera the camera to apply the post process to.
  70603. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  70604. */
  70605. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  70606. }
  70607. }
  70608. declare module BABYLON {
  70609. /** @hidden */
  70610. export var digitalrainPixelShader: {
  70611. name: string;
  70612. shader: string;
  70613. };
  70614. }
  70615. declare module BABYLON {
  70616. /**
  70617. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  70618. *
  70619. * It basically takes care rendering the font front the given font size to a texture.
  70620. * This is used later on in the postprocess.
  70621. */
  70622. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  70623. private _font;
  70624. private _text;
  70625. private _charSize;
  70626. /**
  70627. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  70628. */
  70629. readonly charSize: number;
  70630. /**
  70631. * Create a new instance of the Digital Rain FontTexture class
  70632. * @param name the name of the texture
  70633. * @param font the font to use, use the W3C CSS notation
  70634. * @param text the caracter set to use in the rendering.
  70635. * @param scene the scene that owns the texture
  70636. */
  70637. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  70638. /**
  70639. * Gets the max char width of a font.
  70640. * @param font the font to use, use the W3C CSS notation
  70641. * @return the max char width
  70642. */
  70643. private getFontWidth;
  70644. /**
  70645. * Gets the max char height of a font.
  70646. * @param font the font to use, use the W3C CSS notation
  70647. * @return the max char height
  70648. */
  70649. private getFontHeight;
  70650. /**
  70651. * Clones the current DigitalRainFontTexture.
  70652. * @return the clone of the texture.
  70653. */
  70654. clone(): DigitalRainFontTexture;
  70655. /**
  70656. * Parses a json object representing the texture and returns an instance of it.
  70657. * @param source the source JSON representation
  70658. * @param scene the scene to create the texture for
  70659. * @return the parsed texture
  70660. */
  70661. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  70662. }
  70663. /**
  70664. * Option available in the Digital Rain Post Process.
  70665. */
  70666. export interface IDigitalRainPostProcessOptions {
  70667. /**
  70668. * The font to use following the w3c font definition.
  70669. */
  70670. font?: string;
  70671. /**
  70672. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  70673. * This number is defined between 0 and 1;
  70674. */
  70675. mixToTile?: number;
  70676. /**
  70677. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  70678. * This number is defined between 0 and 1;
  70679. */
  70680. mixToNormal?: number;
  70681. }
  70682. /**
  70683. * DigitalRainPostProcess helps rendering everithing in digital rain.
  70684. *
  70685. * Simmply add it to your scene and let the nerd that lives in you have fun.
  70686. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  70687. */
  70688. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  70689. /**
  70690. * The font texture used to render the char in the post process.
  70691. */
  70692. private _digitalRainFontTexture;
  70693. /**
  70694. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  70695. * This number is defined between 0 and 1;
  70696. */
  70697. mixToTile: number;
  70698. /**
  70699. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  70700. * This number is defined between 0 and 1;
  70701. */
  70702. mixToNormal: number;
  70703. /**
  70704. * Instantiates a new Digital Rain Post Process.
  70705. * @param name the name to give to the postprocess
  70706. * @camera the camera to apply the post process to.
  70707. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  70708. */
  70709. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  70710. }
  70711. }
  70712. declare module BABYLON {
  70713. /** @hidden */
  70714. export var oceanPostProcessPixelShader: {
  70715. name: string;
  70716. shader: string;
  70717. };
  70718. }
  70719. declare module BABYLON {
  70720. /**
  70721. * Option available in the Ocean Post Process.
  70722. */
  70723. export interface IOceanPostProcessOptions {
  70724. /**
  70725. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  70726. */
  70727. reflectionSize?: number | {
  70728. width: number;
  70729. height: number;
  70730. } | {
  70731. ratio: number;
  70732. };
  70733. /**
  70734. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  70735. */
  70736. refractionSize?: number | {
  70737. width: number;
  70738. height: number;
  70739. } | {
  70740. ratio: number;
  70741. };
  70742. }
  70743. /**
  70744. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  70745. *
  70746. * Simmply add it to your scene and let the nerd that lives in you have fun.
  70747. * Example usage:
  70748. * var pp = new OceanPostProcess("myOcean", camera);
  70749. * pp.reflectionEnabled = true;
  70750. * pp.refractionEnabled = true;
  70751. */
  70752. export class OceanPostProcess extends BABYLON.PostProcess {
  70753. /**
  70754. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  70755. */
  70756. /**
  70757. * Sets weither or not the real-time reflection is enabled on the ocean.
  70758. * Is set to true, the reflection mirror texture will be used as reflection texture.
  70759. */
  70760. reflectionEnabled: boolean;
  70761. /**
  70762. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  70763. */
  70764. /**
  70765. * Sets weither or not the real-time refraction is enabled on the ocean.
  70766. * Is set to true, the refraction render target texture will be used as refraction texture.
  70767. */
  70768. refractionEnabled: boolean;
  70769. /**
  70770. * Gets wether or not the post-processes is supported by the running hardware.
  70771. * This requires draw buffer supports.
  70772. */
  70773. readonly isSupported: boolean;
  70774. /**
  70775. * This is the reflection mirror texture used to display reflections on the ocean.
  70776. * By default, render list is empty.
  70777. */
  70778. reflectionTexture: BABYLON.MirrorTexture;
  70779. /**
  70780. * This is the refraction render target texture used to display refraction on the ocean.
  70781. * By default, render list is empty.
  70782. */
  70783. refractionTexture: BABYLON.RenderTargetTexture;
  70784. private _time;
  70785. private _cameraRotation;
  70786. private _cameraViewMatrix;
  70787. private _reflectionEnabled;
  70788. private _refractionEnabled;
  70789. private _geometryRenderer;
  70790. /**
  70791. * Instantiates a new Ocean Post Process.
  70792. * @param name the name to give to the postprocess.
  70793. * @camera the camera to apply the post process to.
  70794. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  70795. */
  70796. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  70797. /**
  70798. * Returns the appropriate defines according to the current configuration.
  70799. */
  70800. private _getDefines;
  70801. /**
  70802. * Computes the current camera rotation as the shader requires a camera rotation.
  70803. */
  70804. private _computeCameraRotation;
  70805. }
  70806. }
  70807. declare module BABYLON {
  70808. /** @hidden */
  70809. export var brickProceduralTexturePixelShader: {
  70810. name: string;
  70811. shader: string;
  70812. };
  70813. }
  70814. declare module BABYLON {
  70815. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  70816. private _numberOfBricksHeight;
  70817. private _numberOfBricksWidth;
  70818. private _jointColor;
  70819. private _brickColor;
  70820. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70821. updateShaderUniforms(): void;
  70822. numberOfBricksHeight: number;
  70823. numberOfBricksWidth: number;
  70824. jointColor: BABYLON.Color3;
  70825. brickColor: BABYLON.Color3;
  70826. /**
  70827. * Serializes this brick procedural texture
  70828. * @returns a serialized brick procedural texture object
  70829. */
  70830. serialize(): any;
  70831. /**
  70832. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  70833. * @param parsedTexture defines parsed texture data
  70834. * @param scene defines the current scene
  70835. * @param rootUrl defines the root URL containing brick procedural texture information
  70836. * @returns a parsed Brick Procedural BABYLON.Texture
  70837. */
  70838. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  70839. }
  70840. }
  70841. declare module BABYLON {
  70842. /** @hidden */
  70843. export var cloudProceduralTexturePixelShader: {
  70844. name: string;
  70845. shader: string;
  70846. };
  70847. }
  70848. declare module BABYLON {
  70849. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  70850. private _skyColor;
  70851. private _cloudColor;
  70852. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70853. updateShaderUniforms(): void;
  70854. skyColor: BABYLON.Color4;
  70855. cloudColor: BABYLON.Color4;
  70856. /**
  70857. * Serializes this cloud procedural texture
  70858. * @returns a serialized cloud procedural texture object
  70859. */
  70860. serialize(): any;
  70861. /**
  70862. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  70863. * @param parsedTexture defines parsed texture data
  70864. * @param scene defines the current scene
  70865. * @param rootUrl defines the root URL containing cloud procedural texture information
  70866. * @returns a parsed Cloud Procedural BABYLON.Texture
  70867. */
  70868. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  70869. }
  70870. }
  70871. declare module BABYLON {
  70872. /** @hidden */
  70873. export var fireProceduralTexturePixelShader: {
  70874. name: string;
  70875. shader: string;
  70876. };
  70877. }
  70878. declare module BABYLON {
  70879. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  70880. private _time;
  70881. private _speed;
  70882. private _autoGenerateTime;
  70883. private _fireColors;
  70884. private _alphaThreshold;
  70885. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70886. updateShaderUniforms(): void;
  70887. render(useCameraPostProcess?: boolean): void;
  70888. static readonly PurpleFireColors: BABYLON.Color3[];
  70889. static readonly GreenFireColors: BABYLON.Color3[];
  70890. static readonly RedFireColors: BABYLON.Color3[];
  70891. static readonly BlueFireColors: BABYLON.Color3[];
  70892. autoGenerateTime: boolean;
  70893. fireColors: BABYLON.Color3[];
  70894. time: number;
  70895. speed: BABYLON.Vector2;
  70896. alphaThreshold: number;
  70897. /**
  70898. * Serializes this fire procedural texture
  70899. * @returns a serialized fire procedural texture object
  70900. */
  70901. serialize(): any;
  70902. /**
  70903. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  70904. * @param parsedTexture defines parsed texture data
  70905. * @param scene defines the current scene
  70906. * @param rootUrl defines the root URL containing fire procedural texture information
  70907. * @returns a parsed Fire Procedural BABYLON.Texture
  70908. */
  70909. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  70910. }
  70911. }
  70912. declare module BABYLON {
  70913. /** @hidden */
  70914. export var grassProceduralTexturePixelShader: {
  70915. name: string;
  70916. shader: string;
  70917. };
  70918. }
  70919. declare module BABYLON {
  70920. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  70921. private _grassColors;
  70922. private _groundColor;
  70923. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70924. updateShaderUniforms(): void;
  70925. grassColors: BABYLON.Color3[];
  70926. groundColor: BABYLON.Color3;
  70927. /**
  70928. * Serializes this grass procedural texture
  70929. * @returns a serialized grass procedural texture object
  70930. */
  70931. serialize(): any;
  70932. /**
  70933. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  70934. * @param parsedTexture defines parsed texture data
  70935. * @param scene defines the current scene
  70936. * @param rootUrl defines the root URL containing grass procedural texture information
  70937. * @returns a parsed Grass Procedural BABYLON.Texture
  70938. */
  70939. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  70940. }
  70941. }
  70942. declare module BABYLON {
  70943. /** @hidden */
  70944. export var marbleProceduralTexturePixelShader: {
  70945. name: string;
  70946. shader: string;
  70947. };
  70948. }
  70949. declare module BABYLON {
  70950. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  70951. private _numberOfTilesHeight;
  70952. private _numberOfTilesWidth;
  70953. private _amplitude;
  70954. private _jointColor;
  70955. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70956. updateShaderUniforms(): void;
  70957. numberOfTilesHeight: number;
  70958. amplitude: number;
  70959. numberOfTilesWidth: number;
  70960. jointColor: BABYLON.Color3;
  70961. /**
  70962. * Serializes this marble procedural texture
  70963. * @returns a serialized marble procedural texture object
  70964. */
  70965. serialize(): any;
  70966. /**
  70967. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  70968. * @param parsedTexture defines parsed texture data
  70969. * @param scene defines the current scene
  70970. * @param rootUrl defines the root URL containing marble procedural texture information
  70971. * @returns a parsed Marble Procedural BABYLON.Texture
  70972. */
  70973. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  70974. }
  70975. }
  70976. declare module BABYLON {
  70977. /** @hidden */
  70978. export var normalMapProceduralTexturePixelShader: {
  70979. name: string;
  70980. shader: string;
  70981. };
  70982. }
  70983. declare module BABYLON {
  70984. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  70985. private _baseTexture;
  70986. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70987. updateShaderUniforms(): void;
  70988. render(useCameraPostProcess?: boolean): void;
  70989. resize(size: any, generateMipMaps: any): void;
  70990. baseTexture: BABYLON.Texture;
  70991. /**
  70992. * Serializes this normal map procedural texture
  70993. * @returns a serialized normal map procedural texture object
  70994. */
  70995. serialize(): any;
  70996. /**
  70997. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  70998. * @param parsedTexture defines parsed texture data
  70999. * @param scene defines the current scene
  71000. * @param rootUrl defines the root URL containing normal map procedural texture information
  71001. * @returns a parsed Normal Map Procedural BABYLON.Texture
  71002. */
  71003. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  71004. }
  71005. }
  71006. declare module BABYLON {
  71007. /** @hidden */
  71008. export var perlinNoiseProceduralTexturePixelShader: {
  71009. name: string;
  71010. shader: string;
  71011. };
  71012. }
  71013. declare module BABYLON {
  71014. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  71015. time: number;
  71016. timeScale: number;
  71017. translationSpeed: number;
  71018. private _currentTranslation;
  71019. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71020. updateShaderUniforms(): void;
  71021. render(useCameraPostProcess?: boolean): void;
  71022. resize(size: any, generateMipMaps: any): void;
  71023. /**
  71024. * Serializes this perlin noise procedural texture
  71025. * @returns a serialized perlin noise procedural texture object
  71026. */
  71027. serialize(): any;
  71028. /**
  71029. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  71030. * @param parsedTexture defines parsed texture data
  71031. * @param scene defines the current scene
  71032. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  71033. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  71034. */
  71035. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  71036. }
  71037. }
  71038. declare module BABYLON {
  71039. /** @hidden */
  71040. export var roadProceduralTexturePixelShader: {
  71041. name: string;
  71042. shader: string;
  71043. };
  71044. }
  71045. declare module BABYLON {
  71046. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  71047. private _roadColor;
  71048. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71049. updateShaderUniforms(): void;
  71050. roadColor: BABYLON.Color3;
  71051. /**
  71052. * Serializes this road procedural texture
  71053. * @returns a serialized road procedural texture object
  71054. */
  71055. serialize(): any;
  71056. /**
  71057. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  71058. * @param parsedTexture defines parsed texture data
  71059. * @param scene defines the current scene
  71060. * @param rootUrl defines the root URL containing road procedural texture information
  71061. * @returns a parsed Road Procedural BABYLON.Texture
  71062. */
  71063. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  71064. }
  71065. }
  71066. declare module BABYLON {
  71067. /** @hidden */
  71068. export var starfieldProceduralTexturePixelShader: {
  71069. name: string;
  71070. shader: string;
  71071. };
  71072. }
  71073. declare module BABYLON {
  71074. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  71075. private _time;
  71076. private _alpha;
  71077. private _beta;
  71078. private _zoom;
  71079. private _formuparam;
  71080. private _stepsize;
  71081. private _tile;
  71082. private _brightness;
  71083. private _darkmatter;
  71084. private _distfading;
  71085. private _saturation;
  71086. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71087. updateShaderUniforms(): void;
  71088. time: number;
  71089. alpha: number;
  71090. beta: number;
  71091. formuparam: number;
  71092. stepsize: number;
  71093. zoom: number;
  71094. tile: number;
  71095. brightness: number;
  71096. darkmatter: number;
  71097. distfading: number;
  71098. saturation: number;
  71099. /**
  71100. * Serializes this starfield procedural texture
  71101. * @returns a serialized starfield procedural texture object
  71102. */
  71103. serialize(): any;
  71104. /**
  71105. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  71106. * @param parsedTexture defines parsed texture data
  71107. * @param scene defines the current scene
  71108. * @param rootUrl defines the root URL containing startfield procedural texture information
  71109. * @returns a parsed Starfield Procedural BABYLON.Texture
  71110. */
  71111. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  71112. }
  71113. }
  71114. declare module BABYLON {
  71115. /** @hidden */
  71116. export var woodProceduralTexturePixelShader: {
  71117. name: string;
  71118. shader: string;
  71119. };
  71120. }
  71121. declare module BABYLON {
  71122. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  71123. private _ampScale;
  71124. private _woodColor;
  71125. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71126. updateShaderUniforms(): void;
  71127. ampScale: number;
  71128. woodColor: BABYLON.Color3;
  71129. /**
  71130. * Serializes this wood procedural texture
  71131. * @returns a serialized wood procedural texture object
  71132. */
  71133. serialize(): any;
  71134. /**
  71135. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  71136. * @param parsedTexture defines parsed texture data
  71137. * @param scene defines the current scene
  71138. * @param rootUrl defines the root URL containing wood procedural texture information
  71139. * @returns a parsed Wood Procedural BABYLON.Texture
  71140. */
  71141. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  71142. }
  71143. }