documentation.d.ts 3.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103
  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. * Prevents the World matrix to be computed any longer.
  13835. * @returns the TransformNode.
  13836. */
  13837. freezeWorldMatrix(): TransformNode;
  13838. /**
  13839. * Allows back the World matrix computation.
  13840. * @returns the TransformNode.
  13841. */
  13842. unfreezeWorldMatrix(): this;
  13843. /**
  13844. * True if the World matrix has been frozen.
  13845. */
  13846. readonly isWorldMatrixFrozen: boolean;
  13847. /**
  13848. * Retuns the mesh absolute position in the World.
  13849. * @returns a Vector3.
  13850. */
  13851. getAbsolutePosition(): Vector3;
  13852. /**
  13853. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13854. * @param absolutePosition the absolute position to set
  13855. * @returns the TransformNode.
  13856. */
  13857. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13858. /**
  13859. * Sets the mesh position in its local space.
  13860. * @param vector3 the position to set in localspace
  13861. * @returns the TransformNode.
  13862. */
  13863. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13864. /**
  13865. * Returns the mesh position in the local space from the current World matrix values.
  13866. * @returns a new Vector3.
  13867. */
  13868. getPositionExpressedInLocalSpace(): Vector3;
  13869. /**
  13870. * Translates the mesh along the passed Vector3 in its local space.
  13871. * @param vector3 the distance to translate in localspace
  13872. * @returns the TransformNode.
  13873. */
  13874. locallyTranslate(vector3: Vector3): TransformNode;
  13875. private static _lookAtVectorCache;
  13876. /**
  13877. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13878. * @param targetPoint the position (must be in same space as current mesh) to look at
  13879. * @param yawCor optional yaw (y-axis) correction in radians
  13880. * @param pitchCor optional pitch (x-axis) correction in radians
  13881. * @param rollCor optional roll (z-axis) correction in radians
  13882. * @param space the choosen space of the target
  13883. * @returns the TransformNode.
  13884. */
  13885. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13886. /**
  13887. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13888. * This Vector3 is expressed in the World space.
  13889. * @param localAxis axis to rotate
  13890. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13891. */
  13892. getDirection(localAxis: Vector3): Vector3;
  13893. /**
  13894. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13895. * localAxis is expressed in the mesh local space.
  13896. * result is computed in the Wordl space from the mesh World matrix.
  13897. * @param localAxis axis to rotate
  13898. * @param result the resulting transformnode
  13899. * @returns this TransformNode.
  13900. */
  13901. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13902. /**
  13903. * Sets this transform node rotation to the given local axis.
  13904. * @param localAxis the axis in local space
  13905. * @param yawCor optional yaw (y-axis) correction in radians
  13906. * @param pitchCor optional pitch (x-axis) correction in radians
  13907. * @param rollCor optional roll (z-axis) correction in radians
  13908. * @returns this TransformNode
  13909. */
  13910. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13911. /**
  13912. * Sets a new pivot point to the current node
  13913. * @param point defines the new pivot point to use
  13914. * @param space defines if the point is in world or local space (local by default)
  13915. * @returns the current TransformNode
  13916. */
  13917. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13918. /**
  13919. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13920. * @returns the pivot point
  13921. */
  13922. getPivotPoint(): Vector3;
  13923. /**
  13924. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13925. * @param result the vector3 to store the result
  13926. * @returns this TransformNode.
  13927. */
  13928. getPivotPointToRef(result: Vector3): TransformNode;
  13929. /**
  13930. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13931. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13932. */
  13933. getAbsolutePivotPoint(): Vector3;
  13934. /**
  13935. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13936. * @param result vector3 to store the result
  13937. * @returns this TransformNode.
  13938. */
  13939. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13940. /**
  13941. * Defines the passed node as the parent of the current node.
  13942. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13943. * @see https://doc.babylonjs.com/how_to/parenting
  13944. * @param node the node ot set as the parent
  13945. * @returns this TransformNode.
  13946. */
  13947. setParent(node: Nullable<Node>): TransformNode;
  13948. private _nonUniformScaling;
  13949. /**
  13950. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13951. */
  13952. readonly nonUniformScaling: boolean;
  13953. /** @hidden */
  13954. _updateNonUniformScalingState(value: boolean): boolean;
  13955. /**
  13956. * Attach the current TransformNode to another TransformNode associated with a bone
  13957. * @param bone Bone affecting the TransformNode
  13958. * @param affectedTransformNode TransformNode associated with the bone
  13959. * @returns this object
  13960. */
  13961. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13962. /**
  13963. * Detach the transform node if its associated with a bone
  13964. * @returns this object
  13965. */
  13966. detachFromBone(): TransformNode;
  13967. private static _rotationAxisCache;
  13968. /**
  13969. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13970. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13971. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13972. * The passed axis is also normalized.
  13973. * @param axis the axis to rotate around
  13974. * @param amount the amount to rotate in radians
  13975. * @param space Space to rotate in (Default: local)
  13976. * @returns the TransformNode.
  13977. */
  13978. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13979. /**
  13980. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13981. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13982. * The passed axis is also normalized. .
  13983. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13984. * @param point the point to rotate around
  13985. * @param axis the axis to rotate around
  13986. * @param amount the amount to rotate in radians
  13987. * @returns the TransformNode
  13988. */
  13989. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13990. /**
  13991. * Translates the mesh along the axis vector for the passed distance in the given space.
  13992. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13993. * @param axis the axis to translate in
  13994. * @param distance the distance to translate
  13995. * @param space Space to rotate in (Default: local)
  13996. * @returns the TransformNode.
  13997. */
  13998. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13999. /**
  14000. * Adds a rotation step to the mesh current rotation.
  14001. * x, y, z are Euler angles expressed in radians.
  14002. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14003. * This means this rotation is made in the mesh local space only.
  14004. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14005. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14006. * ```javascript
  14007. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14008. * ```
  14009. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14010. * 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.
  14011. * @param x Rotation to add
  14012. * @param y Rotation to add
  14013. * @param z Rotation to add
  14014. * @returns the TransformNode.
  14015. */
  14016. addRotation(x: number, y: number, z: number): TransformNode;
  14017. /**
  14018. * @hidden
  14019. */
  14020. protected _getEffectiveParent(): Nullable<Node>;
  14021. /**
  14022. * Computes the world matrix of the node
  14023. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14024. * @returns the world matrix
  14025. */
  14026. computeWorldMatrix(force?: boolean): Matrix;
  14027. protected _afterComputeWorldMatrix(): void;
  14028. /**
  14029. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14030. * @param func callback function to add
  14031. *
  14032. * @returns the TransformNode.
  14033. */
  14034. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14035. /**
  14036. * Removes a registered callback function.
  14037. * @param func callback function to remove
  14038. * @returns the TransformNode.
  14039. */
  14040. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14041. /**
  14042. * Gets the position of the current mesh in camera space
  14043. * @param camera defines the camera to use
  14044. * @returns a position
  14045. */
  14046. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14047. /**
  14048. * Returns the distance from the mesh to the active camera
  14049. * @param camera defines the camera to use
  14050. * @returns the distance
  14051. */
  14052. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14053. /**
  14054. * Clone the current transform node
  14055. * @param name Name of the new clone
  14056. * @param newParent New parent for the clone
  14057. * @param doNotCloneChildren Do not clone children hierarchy
  14058. * @returns the new transform node
  14059. */
  14060. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14061. /**
  14062. * Serializes the objects information.
  14063. * @param currentSerializationObject defines the object to serialize in
  14064. * @returns the serialized object
  14065. */
  14066. serialize(currentSerializationObject?: any): any;
  14067. /**
  14068. * Returns a new TransformNode object parsed from the source provided.
  14069. * @param parsedTransformNode is the source.
  14070. * @param scene the scne the object belongs to
  14071. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14072. * @returns a new TransformNode object parsed from the source provided.
  14073. */
  14074. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14075. /**
  14076. * Get all child-transformNodes of this node
  14077. * @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
  14078. * @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
  14079. * @returns an array of TransformNode
  14080. */
  14081. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14082. /**
  14083. * Releases resources associated with this transform node.
  14084. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14085. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14086. */
  14087. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14088. /**
  14089. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14090. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14091. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14092. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14093. * @returns the current mesh
  14094. */
  14095. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14096. private _syncAbsoluteScalingAndRotation;
  14097. }
  14098. }
  14099. declare module BABYLON {
  14100. /**
  14101. * Defines the types of pose enabled controllers that are supported
  14102. */
  14103. export enum PoseEnabledControllerType {
  14104. /**
  14105. * HTC Vive
  14106. */
  14107. VIVE = 0,
  14108. /**
  14109. * Oculus Rift
  14110. */
  14111. OCULUS = 1,
  14112. /**
  14113. * Windows mixed reality
  14114. */
  14115. WINDOWS = 2,
  14116. /**
  14117. * Samsung gear VR
  14118. */
  14119. GEAR_VR = 3,
  14120. /**
  14121. * Google Daydream
  14122. */
  14123. DAYDREAM = 4,
  14124. /**
  14125. * Generic
  14126. */
  14127. GENERIC = 5
  14128. }
  14129. /**
  14130. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14131. */
  14132. export interface MutableGamepadButton {
  14133. /**
  14134. * Value of the button/trigger
  14135. */
  14136. value: number;
  14137. /**
  14138. * If the button/trigger is currently touched
  14139. */
  14140. touched: boolean;
  14141. /**
  14142. * If the button/trigger is currently pressed
  14143. */
  14144. pressed: boolean;
  14145. }
  14146. /**
  14147. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14148. * @hidden
  14149. */
  14150. export interface ExtendedGamepadButton extends GamepadButton {
  14151. /**
  14152. * If the button/trigger is currently pressed
  14153. */
  14154. readonly pressed: boolean;
  14155. /**
  14156. * If the button/trigger is currently touched
  14157. */
  14158. readonly touched: boolean;
  14159. /**
  14160. * Value of the button/trigger
  14161. */
  14162. readonly value: number;
  14163. }
  14164. /** @hidden */
  14165. export interface _GamePadFactory {
  14166. /**
  14167. * Returns wether or not the current gamepad can be created for this type of controller.
  14168. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14169. * @returns true if it can be created, otherwise false
  14170. */
  14171. canCreate(gamepadInfo: any): boolean;
  14172. /**
  14173. * Creates a new instance of the Gamepad.
  14174. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14175. * @returns the new gamepad instance
  14176. */
  14177. create(gamepadInfo: any): Gamepad;
  14178. }
  14179. /**
  14180. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14181. */
  14182. export class PoseEnabledControllerHelper {
  14183. /** @hidden */
  14184. static _ControllerFactories: _GamePadFactory[];
  14185. /** @hidden */
  14186. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14187. /**
  14188. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14189. * @param vrGamepad the gamepad to initialized
  14190. * @returns a vr controller of the type the gamepad identified as
  14191. */
  14192. static InitiateController(vrGamepad: any): Gamepad;
  14193. }
  14194. /**
  14195. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14196. */
  14197. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14198. /**
  14199. * If the controller is used in a webXR session
  14200. */
  14201. isXR: boolean;
  14202. private _deviceRoomPosition;
  14203. private _deviceRoomRotationQuaternion;
  14204. /**
  14205. * The device position in babylon space
  14206. */
  14207. devicePosition: Vector3;
  14208. /**
  14209. * The device rotation in babylon space
  14210. */
  14211. deviceRotationQuaternion: Quaternion;
  14212. /**
  14213. * The scale factor of the device in babylon space
  14214. */
  14215. deviceScaleFactor: number;
  14216. /**
  14217. * (Likely devicePosition should be used instead) The device position in its room space
  14218. */
  14219. position: Vector3;
  14220. /**
  14221. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14222. */
  14223. rotationQuaternion: Quaternion;
  14224. /**
  14225. * The type of controller (Eg. Windows mixed reality)
  14226. */
  14227. controllerType: PoseEnabledControllerType;
  14228. protected _calculatedPosition: Vector3;
  14229. private _calculatedRotation;
  14230. /**
  14231. * The raw pose from the device
  14232. */
  14233. rawPose: DevicePose;
  14234. private _trackPosition;
  14235. private _maxRotationDistFromHeadset;
  14236. private _draggedRoomRotation;
  14237. /**
  14238. * @hidden
  14239. */
  14240. _disableTrackPosition(fixedPosition: Vector3): void;
  14241. /**
  14242. * Internal, the mesh attached to the controller
  14243. * @hidden
  14244. */
  14245. _mesh: Nullable<AbstractMesh>;
  14246. private _poseControlledCamera;
  14247. private _leftHandSystemQuaternion;
  14248. /**
  14249. * Internal, matrix used to convert room space to babylon space
  14250. * @hidden
  14251. */
  14252. _deviceToWorld: Matrix;
  14253. /**
  14254. * Node to be used when casting a ray from the controller
  14255. * @hidden
  14256. */
  14257. _pointingPoseNode: Nullable<TransformNode>;
  14258. /**
  14259. * Name of the child mesh that can be used to cast a ray from the controller
  14260. */
  14261. static readonly POINTING_POSE: string;
  14262. /**
  14263. * Creates a new PoseEnabledController from a gamepad
  14264. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14265. */
  14266. constructor(browserGamepad: any);
  14267. private _workingMatrix;
  14268. /**
  14269. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14270. */
  14271. update(): void;
  14272. /**
  14273. * Updates only the pose device and mesh without doing any button event checking
  14274. */
  14275. protected _updatePoseAndMesh(): void;
  14276. /**
  14277. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14278. * @param poseData raw pose fromthe device
  14279. */
  14280. updateFromDevice(poseData: DevicePose): void;
  14281. /**
  14282. * @hidden
  14283. */
  14284. _meshAttachedObservable: Observable<AbstractMesh>;
  14285. /**
  14286. * Attaches a mesh to the controller
  14287. * @param mesh the mesh to be attached
  14288. */
  14289. attachToMesh(mesh: AbstractMesh): void;
  14290. /**
  14291. * Attaches the controllers mesh to a camera
  14292. * @param camera the camera the mesh should be attached to
  14293. */
  14294. attachToPoseControlledCamera(camera: TargetCamera): void;
  14295. /**
  14296. * Disposes of the controller
  14297. */
  14298. dispose(): void;
  14299. /**
  14300. * The mesh that is attached to the controller
  14301. */
  14302. readonly mesh: Nullable<AbstractMesh>;
  14303. /**
  14304. * Gets the ray of the controller in the direction the controller is pointing
  14305. * @param length the length the resulting ray should be
  14306. * @returns a ray in the direction the controller is pointing
  14307. */
  14308. getForwardRay(length?: number): Ray;
  14309. }
  14310. }
  14311. declare module BABYLON {
  14312. /**
  14313. * Defines the WebVRController object that represents controllers tracked in 3D space
  14314. */
  14315. export abstract class WebVRController extends PoseEnabledController {
  14316. /**
  14317. * Internal, the default controller model for the controller
  14318. */
  14319. protected _defaultModel: AbstractMesh;
  14320. /**
  14321. * Fired when the trigger state has changed
  14322. */
  14323. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14324. /**
  14325. * Fired when the main button state has changed
  14326. */
  14327. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14328. /**
  14329. * Fired when the secondary button state has changed
  14330. */
  14331. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14332. /**
  14333. * Fired when the pad state has changed
  14334. */
  14335. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14336. /**
  14337. * Fired when controllers stick values have changed
  14338. */
  14339. onPadValuesChangedObservable: Observable<StickValues>;
  14340. /**
  14341. * Array of button availible on the controller
  14342. */
  14343. protected _buttons: Array<MutableGamepadButton>;
  14344. private _onButtonStateChange;
  14345. /**
  14346. * Fired when a controller button's state has changed
  14347. * @param callback the callback containing the button that was modified
  14348. */
  14349. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14350. /**
  14351. * X and Y axis corresponding to the controllers joystick
  14352. */
  14353. pad: StickValues;
  14354. /**
  14355. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14356. */
  14357. hand: string;
  14358. /**
  14359. * The default controller model for the controller
  14360. */
  14361. readonly defaultModel: AbstractMesh;
  14362. /**
  14363. * Creates a new WebVRController from a gamepad
  14364. * @param vrGamepad the gamepad that the WebVRController should be created from
  14365. */
  14366. constructor(vrGamepad: any);
  14367. /**
  14368. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14369. */
  14370. update(): void;
  14371. /**
  14372. * Function to be called when a button is modified
  14373. */
  14374. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14375. /**
  14376. * Loads a mesh and attaches it to the controller
  14377. * @param scene the scene the mesh should be added to
  14378. * @param meshLoaded callback for when the mesh has been loaded
  14379. */
  14380. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14381. private _setButtonValue;
  14382. private _changes;
  14383. private _checkChanges;
  14384. /**
  14385. * Disposes of th webVRCOntroller
  14386. */
  14387. dispose(): void;
  14388. }
  14389. }
  14390. declare module BABYLON {
  14391. /**
  14392. * The HemisphericLight simulates the ambient environment light,
  14393. * so the passed direction is the light reflection direction, not the incoming direction.
  14394. */
  14395. export class HemisphericLight extends Light {
  14396. /**
  14397. * The groundColor is the light in the opposite direction to the one specified during creation.
  14398. * 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.
  14399. */
  14400. groundColor: Color3;
  14401. /**
  14402. * The light reflection direction, not the incoming direction.
  14403. */
  14404. direction: Vector3;
  14405. /**
  14406. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14407. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14408. * The HemisphericLight can't cast shadows.
  14409. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14410. * @param name The friendly name of the light
  14411. * @param direction The direction of the light reflection
  14412. * @param scene The scene the light belongs to
  14413. */
  14414. constructor(name: string, direction: Vector3, scene: Scene);
  14415. protected _buildUniformLayout(): void;
  14416. /**
  14417. * Returns the string "HemisphericLight".
  14418. * @return The class name
  14419. */
  14420. getClassName(): string;
  14421. /**
  14422. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14423. * Returns the updated direction.
  14424. * @param target The target the direction should point to
  14425. * @return The computed direction
  14426. */
  14427. setDirectionToTarget(target: Vector3): Vector3;
  14428. /**
  14429. * Returns the shadow generator associated to the light.
  14430. * @returns Always null for hemispheric lights because it does not support shadows.
  14431. */
  14432. getShadowGenerator(): Nullable<IShadowGenerator>;
  14433. /**
  14434. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14435. * @param effect The effect to update
  14436. * @param lightIndex The index of the light in the effect to update
  14437. * @returns The hemispheric light
  14438. */
  14439. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14440. /**
  14441. * Computes the world matrix of the node
  14442. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14443. * @param useWasUpdatedFlag defines a reserved property
  14444. * @returns the world matrix
  14445. */
  14446. computeWorldMatrix(): Matrix;
  14447. /**
  14448. * Returns the integer 3.
  14449. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14450. */
  14451. getTypeID(): number;
  14452. /**
  14453. * Prepares the list of defines specific to the light type.
  14454. * @param defines the list of defines
  14455. * @param lightIndex defines the index of the light for the effect
  14456. */
  14457. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14458. }
  14459. }
  14460. declare module BABYLON {
  14461. /** @hidden */
  14462. export var vrMultiviewToSingleviewPixelShader: {
  14463. name: string;
  14464. shader: string;
  14465. };
  14466. }
  14467. declare module BABYLON {
  14468. /**
  14469. * Renders to multiple views with a single draw call
  14470. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14471. */
  14472. export class MultiviewRenderTarget extends RenderTargetTexture {
  14473. /**
  14474. * Creates a multiview render target
  14475. * @param scene scene used with the render target
  14476. * @param size the size of the render target (used for each view)
  14477. */
  14478. constructor(scene: Scene, size?: number | {
  14479. width: number;
  14480. height: number;
  14481. } | {
  14482. ratio: number;
  14483. });
  14484. /**
  14485. * @hidden
  14486. * @param faceIndex the face index, if its a cube texture
  14487. */
  14488. _bindFrameBuffer(faceIndex?: number): void;
  14489. /**
  14490. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14491. * @returns the view count
  14492. */
  14493. getViewCount(): number;
  14494. }
  14495. }
  14496. declare module BABYLON {
  14497. /**
  14498. * Reprasents a camera frustum
  14499. */
  14500. export class Frustum {
  14501. /**
  14502. * Gets the planes representing the frustum
  14503. * @param transform matrix to be applied to the returned planes
  14504. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14505. */
  14506. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14507. /**
  14508. * Gets the near frustum plane transformed by the transform matrix
  14509. * @param transform transformation matrix to be applied to the resulting frustum plane
  14510. * @param frustumPlane the resuling frustum plane
  14511. */
  14512. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14513. /**
  14514. * Gets the far frustum plane transformed by the transform matrix
  14515. * @param transform transformation matrix to be applied to the resulting frustum plane
  14516. * @param frustumPlane the resuling frustum plane
  14517. */
  14518. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14519. /**
  14520. * Gets the left frustum plane transformed by the transform matrix
  14521. * @param transform transformation matrix to be applied to the resulting frustum plane
  14522. * @param frustumPlane the resuling frustum plane
  14523. */
  14524. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14525. /**
  14526. * Gets the right frustum plane transformed by the transform matrix
  14527. * @param transform transformation matrix to be applied to the resulting frustum plane
  14528. * @param frustumPlane the resuling frustum plane
  14529. */
  14530. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14531. /**
  14532. * Gets the top frustum plane transformed by the transform matrix
  14533. * @param transform transformation matrix to be applied to the resulting frustum plane
  14534. * @param frustumPlane the resuling frustum plane
  14535. */
  14536. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14537. /**
  14538. * Gets the bottom frustum plane transformed by the transform matrix
  14539. * @param transform transformation matrix to be applied to the resulting frustum plane
  14540. * @param frustumPlane the resuling frustum plane
  14541. */
  14542. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14543. /**
  14544. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14545. * @param transform transformation matrix to be applied to the resulting frustum planes
  14546. * @param frustumPlanes the resuling frustum planes
  14547. */
  14548. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14549. }
  14550. }
  14551. declare module BABYLON {
  14552. interface Engine {
  14553. /**
  14554. * Creates a new multiview render target
  14555. * @param width defines the width of the texture
  14556. * @param height defines the height of the texture
  14557. * @returns the created multiview texture
  14558. */
  14559. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14560. /**
  14561. * Binds a multiview framebuffer to be drawn to
  14562. * @param multiviewTexture texture to bind
  14563. */
  14564. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14565. }
  14566. interface Camera {
  14567. /**
  14568. * @hidden
  14569. * 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)
  14570. */
  14571. _useMultiviewToSingleView: boolean;
  14572. /**
  14573. * @hidden
  14574. * 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)
  14575. */
  14576. _multiviewTexture: Nullable<RenderTargetTexture>;
  14577. /**
  14578. * @hidden
  14579. * ensures the multiview texture of the camera exists and has the specified width/height
  14580. * @param width height to set on the multiview texture
  14581. * @param height width to set on the multiview texture
  14582. */
  14583. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14584. }
  14585. interface Scene {
  14586. /** @hidden */
  14587. _transformMatrixR: Matrix;
  14588. /** @hidden */
  14589. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14590. /** @hidden */
  14591. _createMultiviewUbo(): void;
  14592. /** @hidden */
  14593. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14594. /** @hidden */
  14595. _renderMultiviewToSingleView(camera: Camera): void;
  14596. }
  14597. }
  14598. declare module BABYLON {
  14599. /**
  14600. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14601. * This will not be used for webXR as it supports displaying texture arrays directly
  14602. */
  14603. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14604. /**
  14605. * Initializes a VRMultiviewToSingleview
  14606. * @param name name of the post process
  14607. * @param camera camera to be applied to
  14608. * @param scaleFactor scaling factor to the size of the output texture
  14609. */
  14610. constructor(name: string, camera: Camera, scaleFactor: number);
  14611. }
  14612. }
  14613. declare module BABYLON {
  14614. interface Engine {
  14615. /** @hidden */
  14616. _vrDisplay: any;
  14617. /** @hidden */
  14618. _vrSupported: boolean;
  14619. /** @hidden */
  14620. _oldSize: Size;
  14621. /** @hidden */
  14622. _oldHardwareScaleFactor: number;
  14623. /** @hidden */
  14624. _vrExclusivePointerMode: boolean;
  14625. /** @hidden */
  14626. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14627. /** @hidden */
  14628. _onVRDisplayPointerRestricted: () => void;
  14629. /** @hidden */
  14630. _onVRDisplayPointerUnrestricted: () => void;
  14631. /** @hidden */
  14632. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14633. /** @hidden */
  14634. _onVrDisplayDisconnect: Nullable<() => void>;
  14635. /** @hidden */
  14636. _onVrDisplayPresentChange: Nullable<() => void>;
  14637. /**
  14638. * Observable signaled when VR display mode changes
  14639. */
  14640. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14641. /**
  14642. * Observable signaled when VR request present is complete
  14643. */
  14644. onVRRequestPresentComplete: Observable<boolean>;
  14645. /**
  14646. * Observable signaled when VR request present starts
  14647. */
  14648. onVRRequestPresentStart: Observable<Engine>;
  14649. /**
  14650. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14651. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14652. */
  14653. isInVRExclusivePointerMode: boolean;
  14654. /**
  14655. * Gets a boolean indicating if a webVR device was detected
  14656. * @returns true if a webVR device was detected
  14657. */
  14658. isVRDevicePresent(): boolean;
  14659. /**
  14660. * Gets the current webVR device
  14661. * @returns the current webVR device (or null)
  14662. */
  14663. getVRDevice(): any;
  14664. /**
  14665. * Initializes a webVR display and starts listening to display change events
  14666. * The onVRDisplayChangedObservable will be notified upon these changes
  14667. * @returns A promise containing a VRDisplay and if vr is supported
  14668. */
  14669. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14670. /** @hidden */
  14671. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14672. /**
  14673. * Call this function to switch to webVR mode
  14674. * Will do nothing if webVR is not supported or if there is no webVR device
  14675. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14676. */
  14677. enableVR(): void;
  14678. /** @hidden */
  14679. _onVRFullScreenTriggered(): void;
  14680. }
  14681. }
  14682. declare module BABYLON {
  14683. /**
  14684. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14685. * IMPORTANT!! The data is right-hand data.
  14686. * @export
  14687. * @interface DevicePose
  14688. */
  14689. export interface DevicePose {
  14690. /**
  14691. * The position of the device, values in array are [x,y,z].
  14692. */
  14693. readonly position: Nullable<Float32Array>;
  14694. /**
  14695. * The linearVelocity of the device, values in array are [x,y,z].
  14696. */
  14697. readonly linearVelocity: Nullable<Float32Array>;
  14698. /**
  14699. * The linearAcceleration of the device, values in array are [x,y,z].
  14700. */
  14701. readonly linearAcceleration: Nullable<Float32Array>;
  14702. /**
  14703. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14704. */
  14705. readonly orientation: Nullable<Float32Array>;
  14706. /**
  14707. * The angularVelocity of the device, values in array are [x,y,z].
  14708. */
  14709. readonly angularVelocity: Nullable<Float32Array>;
  14710. /**
  14711. * The angularAcceleration of the device, values in array are [x,y,z].
  14712. */
  14713. readonly angularAcceleration: Nullable<Float32Array>;
  14714. }
  14715. /**
  14716. * Interface representing a pose controlled object in Babylon.
  14717. * A pose controlled object has both regular pose values as well as pose values
  14718. * from an external device such as a VR head mounted display
  14719. */
  14720. export interface PoseControlled {
  14721. /**
  14722. * The position of the object in babylon space.
  14723. */
  14724. position: Vector3;
  14725. /**
  14726. * The rotation quaternion of the object in babylon space.
  14727. */
  14728. rotationQuaternion: Quaternion;
  14729. /**
  14730. * The position of the device in babylon space.
  14731. */
  14732. devicePosition?: Vector3;
  14733. /**
  14734. * The rotation quaternion of the device in babylon space.
  14735. */
  14736. deviceRotationQuaternion: Quaternion;
  14737. /**
  14738. * The raw pose coming from the device.
  14739. */
  14740. rawPose: Nullable<DevicePose>;
  14741. /**
  14742. * The scale of the device to be used when translating from device space to babylon space.
  14743. */
  14744. deviceScaleFactor: number;
  14745. /**
  14746. * Updates the poseControlled values based on the input device pose.
  14747. * @param poseData the pose data to update the object with
  14748. */
  14749. updateFromDevice(poseData: DevicePose): void;
  14750. }
  14751. /**
  14752. * Set of options to customize the webVRCamera
  14753. */
  14754. export interface WebVROptions {
  14755. /**
  14756. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14757. */
  14758. trackPosition?: boolean;
  14759. /**
  14760. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14761. */
  14762. positionScale?: number;
  14763. /**
  14764. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14765. */
  14766. displayName?: string;
  14767. /**
  14768. * Should the native controller meshes be initialized. (default: true)
  14769. */
  14770. controllerMeshes?: boolean;
  14771. /**
  14772. * Creating a default HemiLight only on controllers. (default: true)
  14773. */
  14774. defaultLightingOnControllers?: boolean;
  14775. /**
  14776. * If you don't want to use the default VR button of the helper. (default: false)
  14777. */
  14778. useCustomVRButton?: boolean;
  14779. /**
  14780. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14781. */
  14782. customVRButton?: HTMLButtonElement;
  14783. /**
  14784. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14785. */
  14786. rayLength?: number;
  14787. /**
  14788. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14789. */
  14790. defaultHeight?: number;
  14791. /**
  14792. * If multiview should be used if availible (default: false)
  14793. */
  14794. useMultiview?: boolean;
  14795. }
  14796. /**
  14797. * This represents a WebVR camera.
  14798. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14799. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14800. */
  14801. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14802. private webVROptions;
  14803. /**
  14804. * @hidden
  14805. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14806. */
  14807. _vrDevice: any;
  14808. /**
  14809. * The rawPose of the vrDevice.
  14810. */
  14811. rawPose: Nullable<DevicePose>;
  14812. private _onVREnabled;
  14813. private _specsVersion;
  14814. private _attached;
  14815. private _frameData;
  14816. protected _descendants: Array<Node>;
  14817. private _deviceRoomPosition;
  14818. /** @hidden */
  14819. _deviceRoomRotationQuaternion: Quaternion;
  14820. private _standingMatrix;
  14821. /**
  14822. * Represents device position in babylon space.
  14823. */
  14824. devicePosition: Vector3;
  14825. /**
  14826. * Represents device rotation in babylon space.
  14827. */
  14828. deviceRotationQuaternion: Quaternion;
  14829. /**
  14830. * The scale of the device to be used when translating from device space to babylon space.
  14831. */
  14832. deviceScaleFactor: number;
  14833. private _deviceToWorld;
  14834. private _worldToDevice;
  14835. /**
  14836. * References to the webVR controllers for the vrDevice.
  14837. */
  14838. controllers: Array<WebVRController>;
  14839. /**
  14840. * Emits an event when a controller is attached.
  14841. */
  14842. onControllersAttachedObservable: Observable<WebVRController[]>;
  14843. /**
  14844. * Emits an event when a controller's mesh has been loaded;
  14845. */
  14846. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14847. /**
  14848. * Emits an event when the HMD's pose has been updated.
  14849. */
  14850. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14851. private _poseSet;
  14852. /**
  14853. * If the rig cameras be used as parent instead of this camera.
  14854. */
  14855. rigParenting: boolean;
  14856. private _lightOnControllers;
  14857. private _defaultHeight?;
  14858. /**
  14859. * Instantiates a WebVRFreeCamera.
  14860. * @param name The name of the WebVRFreeCamera
  14861. * @param position The starting anchor position for the camera
  14862. * @param scene The scene the camera belongs to
  14863. * @param webVROptions a set of customizable options for the webVRCamera
  14864. */
  14865. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14866. /**
  14867. * Gets the device distance from the ground in meters.
  14868. * @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.
  14869. */
  14870. deviceDistanceToRoomGround(): number;
  14871. /**
  14872. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14873. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14874. */
  14875. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14876. /**
  14877. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14878. * @returns A promise with a boolean set to if the standing matrix is supported.
  14879. */
  14880. useStandingMatrixAsync(): Promise<boolean>;
  14881. /**
  14882. * Disposes the camera
  14883. */
  14884. dispose(): void;
  14885. /**
  14886. * Gets a vrController by name.
  14887. * @param name The name of the controller to retreive
  14888. * @returns the controller matching the name specified or null if not found
  14889. */
  14890. getControllerByName(name: string): Nullable<WebVRController>;
  14891. private _leftController;
  14892. /**
  14893. * The controller corresponding to the users left hand.
  14894. */
  14895. readonly leftController: Nullable<WebVRController>;
  14896. private _rightController;
  14897. /**
  14898. * The controller corresponding to the users right hand.
  14899. */
  14900. readonly rightController: Nullable<WebVRController>;
  14901. /**
  14902. * Casts a ray forward from the vrCamera's gaze.
  14903. * @param length Length of the ray (default: 100)
  14904. * @returns the ray corresponding to the gaze
  14905. */
  14906. getForwardRay(length?: number): Ray;
  14907. /**
  14908. * @hidden
  14909. * Updates the camera based on device's frame data
  14910. */
  14911. _checkInputs(): void;
  14912. /**
  14913. * Updates the poseControlled values based on the input device pose.
  14914. * @param poseData Pose coming from the device
  14915. */
  14916. updateFromDevice(poseData: DevicePose): void;
  14917. private _htmlElementAttached;
  14918. private _detachIfAttached;
  14919. /**
  14920. * WebVR's attach control will start broadcasting frames to the device.
  14921. * Note that in certain browsers (chrome for example) this function must be called
  14922. * within a user-interaction callback. Example:
  14923. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14924. *
  14925. * @param element html element to attach the vrDevice to
  14926. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14927. */
  14928. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14929. /**
  14930. * Detaches the camera from the html element and disables VR
  14931. *
  14932. * @param element html element to detach from
  14933. */
  14934. detachControl(element: HTMLElement): void;
  14935. /**
  14936. * @returns the name of this class
  14937. */
  14938. getClassName(): string;
  14939. /**
  14940. * Calls resetPose on the vrDisplay
  14941. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  14942. */
  14943. resetToCurrentRotation(): void;
  14944. /**
  14945. * @hidden
  14946. * Updates the rig cameras (left and right eye)
  14947. */
  14948. _updateRigCameras(): void;
  14949. private _workingVector;
  14950. private _oneVector;
  14951. private _workingMatrix;
  14952. private updateCacheCalled;
  14953. private _correctPositionIfNotTrackPosition;
  14954. /**
  14955. * @hidden
  14956. * Updates the cached values of the camera
  14957. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  14958. */
  14959. _updateCache(ignoreParentClass?: boolean): void;
  14960. /**
  14961. * @hidden
  14962. * Get current device position in babylon world
  14963. */
  14964. _computeDevicePosition(): void;
  14965. /**
  14966. * Updates the current device position and rotation in the babylon world
  14967. */
  14968. update(): void;
  14969. /**
  14970. * @hidden
  14971. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  14972. * @returns an identity matrix
  14973. */
  14974. _getViewMatrix(): Matrix;
  14975. private _tmpMatrix;
  14976. /**
  14977. * This function is called by the two RIG cameras.
  14978. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  14979. * @hidden
  14980. */
  14981. _getWebVRViewMatrix(): Matrix;
  14982. /** @hidden */
  14983. _getWebVRProjectionMatrix(): Matrix;
  14984. private _onGamepadConnectedObserver;
  14985. private _onGamepadDisconnectedObserver;
  14986. private _updateCacheWhenTrackingDisabledObserver;
  14987. /**
  14988. * Initializes the controllers and their meshes
  14989. */
  14990. initControllers(): void;
  14991. }
  14992. }
  14993. declare module BABYLON {
  14994. /**
  14995. * Size options for a post process
  14996. */
  14997. export type PostProcessOptions = {
  14998. width: number;
  14999. height: number;
  15000. };
  15001. /**
  15002. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15003. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15004. */
  15005. export class PostProcess {
  15006. /** Name of the PostProcess. */
  15007. name: string;
  15008. /**
  15009. * Gets or sets the unique id of the post process
  15010. */
  15011. uniqueId: number;
  15012. /**
  15013. * Width of the texture to apply the post process on
  15014. */
  15015. width: number;
  15016. /**
  15017. * Height of the texture to apply the post process on
  15018. */
  15019. height: number;
  15020. /**
  15021. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15022. * @hidden
  15023. */
  15024. _outputTexture: Nullable<InternalTexture>;
  15025. /**
  15026. * Sampling mode used by the shader
  15027. * See https://doc.babylonjs.com/classes/3.1/texture
  15028. */
  15029. renderTargetSamplingMode: number;
  15030. /**
  15031. * Clear color to use when screen clearing
  15032. */
  15033. clearColor: Color4;
  15034. /**
  15035. * If the buffer needs to be cleared before applying the post process. (default: true)
  15036. * Should be set to false if shader will overwrite all previous pixels.
  15037. */
  15038. autoClear: boolean;
  15039. /**
  15040. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15041. */
  15042. alphaMode: number;
  15043. /**
  15044. * Sets the setAlphaBlendConstants of the babylon engine
  15045. */
  15046. alphaConstants: Color4;
  15047. /**
  15048. * Animations to be used for the post processing
  15049. */
  15050. animations: Animation[];
  15051. /**
  15052. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15053. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15054. */
  15055. enablePixelPerfectMode: boolean;
  15056. /**
  15057. * Force the postprocess to be applied without taking in account viewport
  15058. */
  15059. forceFullscreenViewport: boolean;
  15060. /**
  15061. * List of inspectable custom properties (used by the Inspector)
  15062. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15063. */
  15064. inspectableCustomProperties: IInspectable[];
  15065. /**
  15066. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15067. *
  15068. * | Value | Type | Description |
  15069. * | ----- | ----------------------------------- | ----------- |
  15070. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15071. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15072. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15073. *
  15074. */
  15075. scaleMode: number;
  15076. /**
  15077. * Force textures to be a power of two (default: false)
  15078. */
  15079. alwaysForcePOT: boolean;
  15080. private _samples;
  15081. /**
  15082. * Number of sample textures (default: 1)
  15083. */
  15084. samples: number;
  15085. /**
  15086. * Modify the scale of the post process to be the same as the viewport (default: false)
  15087. */
  15088. adaptScaleToCurrentViewport: boolean;
  15089. private _camera;
  15090. private _scene;
  15091. private _engine;
  15092. private _options;
  15093. private _reusable;
  15094. private _textureType;
  15095. /**
  15096. * Smart array of input and output textures for the post process.
  15097. * @hidden
  15098. */
  15099. _textures: SmartArray<InternalTexture>;
  15100. /**
  15101. * The index in _textures that corresponds to the output texture.
  15102. * @hidden
  15103. */
  15104. _currentRenderTextureInd: number;
  15105. private _effect;
  15106. private _samplers;
  15107. private _fragmentUrl;
  15108. private _vertexUrl;
  15109. private _parameters;
  15110. private _scaleRatio;
  15111. protected _indexParameters: any;
  15112. private _shareOutputWithPostProcess;
  15113. private _texelSize;
  15114. private _forcedOutputTexture;
  15115. /**
  15116. * Returns the fragment url or shader name used in the post process.
  15117. * @returns the fragment url or name in the shader store.
  15118. */
  15119. getEffectName(): string;
  15120. /**
  15121. * An event triggered when the postprocess is activated.
  15122. */
  15123. onActivateObservable: Observable<Camera>;
  15124. private _onActivateObserver;
  15125. /**
  15126. * A function that is added to the onActivateObservable
  15127. */
  15128. onActivate: Nullable<(camera: Camera) => void>;
  15129. /**
  15130. * An event triggered when the postprocess changes its size.
  15131. */
  15132. onSizeChangedObservable: Observable<PostProcess>;
  15133. private _onSizeChangedObserver;
  15134. /**
  15135. * A function that is added to the onSizeChangedObservable
  15136. */
  15137. onSizeChanged: (postProcess: PostProcess) => void;
  15138. /**
  15139. * An event triggered when the postprocess applies its effect.
  15140. */
  15141. onApplyObservable: Observable<Effect>;
  15142. private _onApplyObserver;
  15143. /**
  15144. * A function that is added to the onApplyObservable
  15145. */
  15146. onApply: (effect: Effect) => void;
  15147. /**
  15148. * An event triggered before rendering the postprocess
  15149. */
  15150. onBeforeRenderObservable: Observable<Effect>;
  15151. private _onBeforeRenderObserver;
  15152. /**
  15153. * A function that is added to the onBeforeRenderObservable
  15154. */
  15155. onBeforeRender: (effect: Effect) => void;
  15156. /**
  15157. * An event triggered after rendering the postprocess
  15158. */
  15159. onAfterRenderObservable: Observable<Effect>;
  15160. private _onAfterRenderObserver;
  15161. /**
  15162. * A function that is added to the onAfterRenderObservable
  15163. */
  15164. onAfterRender: (efect: Effect) => void;
  15165. /**
  15166. * 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
  15167. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15168. */
  15169. inputTexture: InternalTexture;
  15170. /**
  15171. * Gets the camera which post process is applied to.
  15172. * @returns The camera the post process is applied to.
  15173. */
  15174. getCamera(): Camera;
  15175. /**
  15176. * Gets the texel size of the postprocess.
  15177. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15178. */
  15179. readonly texelSize: Vector2;
  15180. /**
  15181. * Creates a new instance PostProcess
  15182. * @param name The name of the PostProcess.
  15183. * @param fragmentUrl The url of the fragment shader to be used.
  15184. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15185. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15186. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15187. * @param camera The camera to apply the render pass to.
  15188. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15189. * @param engine The engine which the post process will be applied. (default: current engine)
  15190. * @param reusable If the post process can be reused on the same frame. (default: false)
  15191. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15192. * @param textureType Type of textures used when performing the post process. (default: 0)
  15193. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15194. * @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
  15195. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15196. */
  15197. constructor(
  15198. /** Name of the PostProcess. */
  15199. 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);
  15200. /**
  15201. * Gets a string idenfifying the name of the class
  15202. * @returns "PostProcess" string
  15203. */
  15204. getClassName(): string;
  15205. /**
  15206. * Gets the engine which this post process belongs to.
  15207. * @returns The engine the post process was enabled with.
  15208. */
  15209. getEngine(): Engine;
  15210. /**
  15211. * The effect that is created when initializing the post process.
  15212. * @returns The created effect corresponding the the postprocess.
  15213. */
  15214. getEffect(): Effect;
  15215. /**
  15216. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15217. * @param postProcess The post process to share the output with.
  15218. * @returns This post process.
  15219. */
  15220. shareOutputWith(postProcess: PostProcess): PostProcess;
  15221. /**
  15222. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15223. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15224. */
  15225. useOwnOutput(): void;
  15226. /**
  15227. * Updates the effect with the current post process compile time values and recompiles the shader.
  15228. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15229. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15230. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15231. * @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
  15232. * @param onCompiled Called when the shader has been compiled.
  15233. * @param onError Called if there is an error when compiling a shader.
  15234. */
  15235. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15236. /**
  15237. * The post process is reusable if it can be used multiple times within one frame.
  15238. * @returns If the post process is reusable
  15239. */
  15240. isReusable(): boolean;
  15241. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15242. markTextureDirty(): void;
  15243. /**
  15244. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15245. * 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.
  15246. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15247. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15248. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15249. * @returns The target texture that was bound to be written to.
  15250. */
  15251. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15252. /**
  15253. * If the post process is supported.
  15254. */
  15255. readonly isSupported: boolean;
  15256. /**
  15257. * The aspect ratio of the output texture.
  15258. */
  15259. readonly aspectRatio: number;
  15260. /**
  15261. * Get a value indicating if the post-process is ready to be used
  15262. * @returns true if the post-process is ready (shader is compiled)
  15263. */
  15264. isReady(): boolean;
  15265. /**
  15266. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15267. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15268. */
  15269. apply(): Nullable<Effect>;
  15270. private _disposeTextures;
  15271. /**
  15272. * Disposes the post process.
  15273. * @param camera The camera to dispose the post process on.
  15274. */
  15275. dispose(camera?: Camera): void;
  15276. }
  15277. }
  15278. declare module BABYLON {
  15279. /** @hidden */
  15280. export var kernelBlurVaryingDeclaration: {
  15281. name: string;
  15282. shader: string;
  15283. };
  15284. }
  15285. declare module BABYLON {
  15286. /** @hidden */
  15287. export var kernelBlurFragment: {
  15288. name: string;
  15289. shader: string;
  15290. };
  15291. }
  15292. declare module BABYLON {
  15293. /** @hidden */
  15294. export var kernelBlurFragment2: {
  15295. name: string;
  15296. shader: string;
  15297. };
  15298. }
  15299. declare module BABYLON {
  15300. /** @hidden */
  15301. export var kernelBlurPixelShader: {
  15302. name: string;
  15303. shader: string;
  15304. };
  15305. }
  15306. declare module BABYLON {
  15307. /** @hidden */
  15308. export var kernelBlurVertex: {
  15309. name: string;
  15310. shader: string;
  15311. };
  15312. }
  15313. declare module BABYLON {
  15314. /** @hidden */
  15315. export var kernelBlurVertexShader: {
  15316. name: string;
  15317. shader: string;
  15318. };
  15319. }
  15320. declare module BABYLON {
  15321. /**
  15322. * The Blur Post Process which blurs an image based on a kernel and direction.
  15323. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15324. */
  15325. export class BlurPostProcess extends PostProcess {
  15326. /** The direction in which to blur the image. */
  15327. direction: Vector2;
  15328. private blockCompilation;
  15329. protected _kernel: number;
  15330. protected _idealKernel: number;
  15331. protected _packedFloat: boolean;
  15332. private _staticDefines;
  15333. /**
  15334. * Sets the length in pixels of the blur sample region
  15335. */
  15336. /**
  15337. * Gets the length in pixels of the blur sample region
  15338. */
  15339. kernel: number;
  15340. /**
  15341. * Sets wether or not the blur needs to unpack/repack floats
  15342. */
  15343. /**
  15344. * Gets wether or not the blur is unpacking/repacking floats
  15345. */
  15346. packedFloat: boolean;
  15347. /**
  15348. * Creates a new instance BlurPostProcess
  15349. * @param name The name of the effect.
  15350. * @param direction The direction in which to blur the image.
  15351. * @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.
  15352. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15353. * @param camera The camera to apply the render pass to.
  15354. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15355. * @param engine The engine which the post process will be applied. (default: current engine)
  15356. * @param reusable If the post process can be reused on the same frame. (default: false)
  15357. * @param textureType Type of textures used when performing the post process. (default: 0)
  15358. * @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)
  15359. */
  15360. constructor(name: string,
  15361. /** The direction in which to blur the image. */
  15362. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15363. /**
  15364. * Updates the effect with the current post process compile time values and recompiles the shader.
  15365. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15366. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15367. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15368. * @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
  15369. * @param onCompiled Called when the shader has been compiled.
  15370. * @param onError Called if there is an error when compiling a shader.
  15371. */
  15372. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15373. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15374. /**
  15375. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15376. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15377. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15378. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15379. * The gaps between physical kernels are compensated for in the weighting of the samples
  15380. * @param idealKernel Ideal blur kernel.
  15381. * @return Nearest best kernel.
  15382. */
  15383. protected _nearestBestKernel(idealKernel: number): number;
  15384. /**
  15385. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15386. * @param x The point on the Gaussian distribution to sample.
  15387. * @return the value of the Gaussian function at x.
  15388. */
  15389. protected _gaussianWeight(x: number): number;
  15390. /**
  15391. * Generates a string that can be used as a floating point number in GLSL.
  15392. * @param x Value to print.
  15393. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15394. * @return GLSL float string.
  15395. */
  15396. protected _glslFloat(x: number, decimalFigures?: number): string;
  15397. }
  15398. }
  15399. declare module BABYLON {
  15400. /**
  15401. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15402. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15403. * You can then easily use it as a reflectionTexture on a flat surface.
  15404. * In case the surface is not a plane, please consider relying on reflection probes.
  15405. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15406. */
  15407. export class MirrorTexture extends RenderTargetTexture {
  15408. private scene;
  15409. /**
  15410. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15411. * 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.
  15412. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15413. */
  15414. mirrorPlane: Plane;
  15415. /**
  15416. * Define the blur ratio used to blur the reflection if needed.
  15417. */
  15418. blurRatio: number;
  15419. /**
  15420. * Define the adaptive blur kernel used to blur the reflection if needed.
  15421. * This will autocompute the closest best match for the `blurKernel`
  15422. */
  15423. adaptiveBlurKernel: number;
  15424. /**
  15425. * Define the blur kernel used to blur the reflection if needed.
  15426. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15427. */
  15428. blurKernel: number;
  15429. /**
  15430. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15431. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15432. */
  15433. blurKernelX: number;
  15434. /**
  15435. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15436. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15437. */
  15438. blurKernelY: number;
  15439. private _autoComputeBlurKernel;
  15440. protected _onRatioRescale(): void;
  15441. private _updateGammaSpace;
  15442. private _imageProcessingConfigChangeObserver;
  15443. private _transformMatrix;
  15444. private _mirrorMatrix;
  15445. private _savedViewMatrix;
  15446. private _blurX;
  15447. private _blurY;
  15448. private _adaptiveBlurKernel;
  15449. private _blurKernelX;
  15450. private _blurKernelY;
  15451. private _blurRatio;
  15452. /**
  15453. * Instantiates a Mirror Texture.
  15454. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15455. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15456. * You can then easily use it as a reflectionTexture on a flat surface.
  15457. * In case the surface is not a plane, please consider relying on reflection probes.
  15458. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15459. * @param name
  15460. * @param size
  15461. * @param scene
  15462. * @param generateMipMaps
  15463. * @param type
  15464. * @param samplingMode
  15465. * @param generateDepthBuffer
  15466. */
  15467. constructor(name: string, size: number | {
  15468. width: number;
  15469. height: number;
  15470. } | {
  15471. ratio: number;
  15472. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15473. private _preparePostProcesses;
  15474. /**
  15475. * Clone the mirror texture.
  15476. * @returns the cloned texture
  15477. */
  15478. clone(): MirrorTexture;
  15479. /**
  15480. * Serialize the texture to a JSON representation you could use in Parse later on
  15481. * @returns the serialized JSON representation
  15482. */
  15483. serialize(): any;
  15484. /**
  15485. * Dispose the texture and release its associated resources.
  15486. */
  15487. dispose(): void;
  15488. }
  15489. }
  15490. declare module BABYLON {
  15491. /**
  15492. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15493. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15494. */
  15495. export class Texture extends BaseTexture {
  15496. /** @hidden */
  15497. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15498. /** @hidden */
  15499. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15500. /** @hidden */
  15501. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15502. /** nearest is mag = nearest and min = nearest and mip = linear */
  15503. static readonly NEAREST_SAMPLINGMODE: number;
  15504. /** nearest is mag = nearest and min = nearest and mip = linear */
  15505. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15506. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15507. static readonly BILINEAR_SAMPLINGMODE: number;
  15508. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15509. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15510. /** Trilinear is mag = linear and min = linear and mip = linear */
  15511. static readonly TRILINEAR_SAMPLINGMODE: number;
  15512. /** Trilinear is mag = linear and min = linear and mip = linear */
  15513. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15514. /** mag = nearest and min = nearest and mip = nearest */
  15515. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15516. /** mag = nearest and min = linear and mip = nearest */
  15517. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15518. /** mag = nearest and min = linear and mip = linear */
  15519. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15520. /** mag = nearest and min = linear and mip = none */
  15521. static readonly NEAREST_LINEAR: number;
  15522. /** mag = nearest and min = nearest and mip = none */
  15523. static readonly NEAREST_NEAREST: number;
  15524. /** mag = linear and min = nearest and mip = nearest */
  15525. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15526. /** mag = linear and min = nearest and mip = linear */
  15527. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15528. /** mag = linear and min = linear and mip = none */
  15529. static readonly LINEAR_LINEAR: number;
  15530. /** mag = linear and min = nearest and mip = none */
  15531. static readonly LINEAR_NEAREST: number;
  15532. /** Explicit coordinates mode */
  15533. static readonly EXPLICIT_MODE: number;
  15534. /** Spherical coordinates mode */
  15535. static readonly SPHERICAL_MODE: number;
  15536. /** Planar coordinates mode */
  15537. static readonly PLANAR_MODE: number;
  15538. /** Cubic coordinates mode */
  15539. static readonly CUBIC_MODE: number;
  15540. /** Projection coordinates mode */
  15541. static readonly PROJECTION_MODE: number;
  15542. /** Inverse Cubic coordinates mode */
  15543. static readonly SKYBOX_MODE: number;
  15544. /** Inverse Cubic coordinates mode */
  15545. static readonly INVCUBIC_MODE: number;
  15546. /** Equirectangular coordinates mode */
  15547. static readonly EQUIRECTANGULAR_MODE: number;
  15548. /** Equirectangular Fixed coordinates mode */
  15549. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15550. /** Equirectangular Fixed Mirrored coordinates mode */
  15551. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15552. /** Texture is not repeating outside of 0..1 UVs */
  15553. static readonly CLAMP_ADDRESSMODE: number;
  15554. /** Texture is repeating outside of 0..1 UVs */
  15555. static readonly WRAP_ADDRESSMODE: number;
  15556. /** Texture is repeating and mirrored */
  15557. static readonly MIRROR_ADDRESSMODE: number;
  15558. /**
  15559. * 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
  15560. */
  15561. static UseSerializedUrlIfAny: boolean;
  15562. /**
  15563. * Define the url of the texture.
  15564. */
  15565. url: Nullable<string>;
  15566. /**
  15567. * Define an offset on the texture to offset the u coordinates of the UVs
  15568. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15569. */
  15570. uOffset: number;
  15571. /**
  15572. * Define an offset on the texture to offset the v coordinates of the UVs
  15573. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15574. */
  15575. vOffset: number;
  15576. /**
  15577. * Define an offset on the texture to scale the u coordinates of the UVs
  15578. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15579. */
  15580. uScale: number;
  15581. /**
  15582. * Define an offset on the texture to scale the v coordinates of the UVs
  15583. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15584. */
  15585. vScale: number;
  15586. /**
  15587. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15588. * @see http://doc.babylonjs.com/how_to/more_materials
  15589. */
  15590. uAng: number;
  15591. /**
  15592. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15593. * @see http://doc.babylonjs.com/how_to/more_materials
  15594. */
  15595. vAng: number;
  15596. /**
  15597. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15598. * @see http://doc.babylonjs.com/how_to/more_materials
  15599. */
  15600. wAng: number;
  15601. /**
  15602. * Defines the center of rotation (U)
  15603. */
  15604. uRotationCenter: number;
  15605. /**
  15606. * Defines the center of rotation (V)
  15607. */
  15608. vRotationCenter: number;
  15609. /**
  15610. * Defines the center of rotation (W)
  15611. */
  15612. wRotationCenter: number;
  15613. /**
  15614. * Are mip maps generated for this texture or not.
  15615. */
  15616. readonly noMipmap: boolean;
  15617. /**
  15618. * List of inspectable custom properties (used by the Inspector)
  15619. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15620. */
  15621. inspectableCustomProperties: Nullable<IInspectable[]>;
  15622. private _noMipmap;
  15623. /** @hidden */
  15624. _invertY: boolean;
  15625. private _rowGenerationMatrix;
  15626. private _cachedTextureMatrix;
  15627. private _projectionModeMatrix;
  15628. private _t0;
  15629. private _t1;
  15630. private _t2;
  15631. private _cachedUOffset;
  15632. private _cachedVOffset;
  15633. private _cachedUScale;
  15634. private _cachedVScale;
  15635. private _cachedUAng;
  15636. private _cachedVAng;
  15637. private _cachedWAng;
  15638. private _cachedProjectionMatrixId;
  15639. private _cachedCoordinatesMode;
  15640. /** @hidden */
  15641. protected _initialSamplingMode: number;
  15642. /** @hidden */
  15643. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  15644. private _deleteBuffer;
  15645. protected _format: Nullable<number>;
  15646. private _delayedOnLoad;
  15647. private _delayedOnError;
  15648. /**
  15649. * Observable triggered once the texture has been loaded.
  15650. */
  15651. onLoadObservable: Observable<Texture>;
  15652. protected _isBlocking: boolean;
  15653. /**
  15654. * Is the texture preventing material to render while loading.
  15655. * If false, a default texture will be used instead of the loading one during the preparation step.
  15656. */
  15657. isBlocking: boolean;
  15658. /**
  15659. * Get the current sampling mode associated with the texture.
  15660. */
  15661. readonly samplingMode: number;
  15662. /**
  15663. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15664. */
  15665. readonly invertY: boolean;
  15666. /**
  15667. * Instantiates a new texture.
  15668. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15669. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15670. * @param url define the url of the picture to load as a texture
  15671. * @param scene define the scene or engine the texture will belong to
  15672. * @param noMipmap define if the texture will require mip maps or not
  15673. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15674. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15675. * @param onLoad define a callback triggered when the texture has been loaded
  15676. * @param onError define a callback triggered when an error occurred during the loading session
  15677. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15678. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15679. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15680. */
  15681. 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);
  15682. /**
  15683. * Update the url (and optional buffer) of this texture if url was null during construction.
  15684. * @param url the url of the texture
  15685. * @param buffer the buffer of the texture (defaults to null)
  15686. * @param onLoad callback called when the texture is loaded (defaults to null)
  15687. */
  15688. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15689. /**
  15690. * Finish the loading sequence of a texture flagged as delayed load.
  15691. * @hidden
  15692. */
  15693. delayLoad(): void;
  15694. private _prepareRowForTextureGeneration;
  15695. /**
  15696. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15697. * @returns the transform matrix of the texture.
  15698. */
  15699. getTextureMatrix(): Matrix;
  15700. /**
  15701. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15702. * @returns The reflection texture transform
  15703. */
  15704. getReflectionTextureMatrix(): Matrix;
  15705. /**
  15706. * Clones the texture.
  15707. * @returns the cloned texture
  15708. */
  15709. clone(): Texture;
  15710. /**
  15711. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15712. * @returns The JSON representation of the texture
  15713. */
  15714. serialize(): any;
  15715. /**
  15716. * Get the current class name of the texture useful for serialization or dynamic coding.
  15717. * @returns "Texture"
  15718. */
  15719. getClassName(): string;
  15720. /**
  15721. * Dispose the texture and release its associated resources.
  15722. */
  15723. dispose(): void;
  15724. /**
  15725. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15726. * @param parsedTexture Define the JSON representation of the texture
  15727. * @param scene Define the scene the parsed texture should be instantiated in
  15728. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15729. * @returns The parsed texture if successful
  15730. */
  15731. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15732. /**
  15733. * Creates a texture from its base 64 representation.
  15734. * @param data Define the base64 payload without the data: prefix
  15735. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15736. * @param scene Define the scene the texture should belong to
  15737. * @param noMipmap Forces the texture to not create mip map information if true
  15738. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15739. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15740. * @param onLoad define a callback triggered when the texture has been loaded
  15741. * @param onError define a callback triggered when an error occurred during the loading session
  15742. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15743. * @returns the created texture
  15744. */
  15745. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15746. /**
  15747. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15748. * @param data Define the base64 payload without the data: prefix
  15749. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15750. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15751. * @param scene Define the scene the texture should belong to
  15752. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15753. * @param noMipmap Forces the texture to not create mip map information if true
  15754. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15755. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15756. * @param onLoad define a callback triggered when the texture has been loaded
  15757. * @param onError define a callback triggered when an error occurred during the loading session
  15758. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15759. * @returns the created texture
  15760. */
  15761. 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;
  15762. }
  15763. }
  15764. declare module BABYLON {
  15765. /**
  15766. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15767. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15768. */
  15769. export class PostProcessManager {
  15770. private _scene;
  15771. private _indexBuffer;
  15772. private _vertexBuffers;
  15773. /**
  15774. * Creates a new instance PostProcess
  15775. * @param scene The scene that the post process is associated with.
  15776. */
  15777. constructor(scene: Scene);
  15778. private _prepareBuffers;
  15779. private _buildIndexBuffer;
  15780. /**
  15781. * Rebuilds the vertex buffers of the manager.
  15782. * @hidden
  15783. */
  15784. _rebuild(): void;
  15785. /**
  15786. * Prepares a frame to be run through a post process.
  15787. * @param sourceTexture The input texture to the post procesess. (default: null)
  15788. * @param postProcesses An array of post processes to be run. (default: null)
  15789. * @returns True if the post processes were able to be run.
  15790. * @hidden
  15791. */
  15792. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15793. /**
  15794. * Manually render a set of post processes to a texture.
  15795. * @param postProcesses An array of post processes to be run.
  15796. * @param targetTexture The target texture to render to.
  15797. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15798. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15799. * @param lodLevel defines which lod of the texture to render to
  15800. */
  15801. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15802. /**
  15803. * Finalize the result of the output of the postprocesses.
  15804. * @param doNotPresent If true the result will not be displayed to the screen.
  15805. * @param targetTexture The target texture to render to.
  15806. * @param faceIndex The index of the face to bind the target texture to.
  15807. * @param postProcesses The array of post processes to render.
  15808. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15809. * @hidden
  15810. */
  15811. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15812. /**
  15813. * Disposes of the post process manager.
  15814. */
  15815. dispose(): void;
  15816. }
  15817. }
  15818. declare module BABYLON {
  15819. /** Interface used by value gradients (color, factor, ...) */
  15820. export interface IValueGradient {
  15821. /**
  15822. * Gets or sets the gradient value (between 0 and 1)
  15823. */
  15824. gradient: number;
  15825. }
  15826. /** Class used to store color4 gradient */
  15827. export class ColorGradient implements IValueGradient {
  15828. /**
  15829. * Gets or sets the gradient value (between 0 and 1)
  15830. */
  15831. gradient: number;
  15832. /**
  15833. * Gets or sets first associated color
  15834. */
  15835. color1: Color4;
  15836. /**
  15837. * Gets or sets second associated color
  15838. */
  15839. color2?: Color4;
  15840. /**
  15841. * Will get a color picked randomly between color1 and color2.
  15842. * If color2 is undefined then color1 will be used
  15843. * @param result defines the target Color4 to store the result in
  15844. */
  15845. getColorToRef(result: Color4): void;
  15846. }
  15847. /** Class used to store color 3 gradient */
  15848. export class Color3Gradient implements IValueGradient {
  15849. /**
  15850. * Gets or sets the gradient value (between 0 and 1)
  15851. */
  15852. gradient: number;
  15853. /**
  15854. * Gets or sets the associated color
  15855. */
  15856. color: Color3;
  15857. }
  15858. /** Class used to store factor gradient */
  15859. export class FactorGradient implements IValueGradient {
  15860. /**
  15861. * Gets or sets the gradient value (between 0 and 1)
  15862. */
  15863. gradient: number;
  15864. /**
  15865. * Gets or sets first associated factor
  15866. */
  15867. factor1: number;
  15868. /**
  15869. * Gets or sets second associated factor
  15870. */
  15871. factor2?: number;
  15872. /**
  15873. * Will get a number picked randomly between factor1 and factor2.
  15874. * If factor2 is undefined then factor1 will be used
  15875. * @returns the picked number
  15876. */
  15877. getFactor(): number;
  15878. }
  15879. /**
  15880. * Helper used to simplify some generic gradient tasks
  15881. */
  15882. export class GradientHelper {
  15883. /**
  15884. * Gets the current gradient from an array of IValueGradient
  15885. * @param ratio defines the current ratio to get
  15886. * @param gradients defines the array of IValueGradient
  15887. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15888. */
  15889. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15890. }
  15891. }
  15892. declare module BABYLON {
  15893. interface AbstractScene {
  15894. /**
  15895. * The list of procedural textures added to the scene
  15896. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15897. */
  15898. proceduralTextures: Array<ProceduralTexture>;
  15899. }
  15900. /**
  15901. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  15902. * in a given scene.
  15903. */
  15904. export class ProceduralTextureSceneComponent implements ISceneComponent {
  15905. /**
  15906. * The component name helpfull to identify the component in the list of scene components.
  15907. */
  15908. readonly name: string;
  15909. /**
  15910. * The scene the component belongs to.
  15911. */
  15912. scene: Scene;
  15913. /**
  15914. * Creates a new instance of the component for the given scene
  15915. * @param scene Defines the scene to register the component in
  15916. */
  15917. constructor(scene: Scene);
  15918. /**
  15919. * Registers the component in a given scene
  15920. */
  15921. register(): void;
  15922. /**
  15923. * Rebuilds the elements related to this component in case of
  15924. * context lost for instance.
  15925. */
  15926. rebuild(): void;
  15927. /**
  15928. * Disposes the component and the associated ressources.
  15929. */
  15930. dispose(): void;
  15931. private _beforeClear;
  15932. }
  15933. }
  15934. declare module BABYLON {
  15935. interface Engine {
  15936. /**
  15937. * Creates a new render target cube texture
  15938. * @param size defines the size of the texture
  15939. * @param options defines the options used to create the texture
  15940. * @returns a new render target cube texture stored in an InternalTexture
  15941. */
  15942. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  15943. }
  15944. }
  15945. declare module BABYLON {
  15946. /** @hidden */
  15947. export var proceduralVertexShader: {
  15948. name: string;
  15949. shader: string;
  15950. };
  15951. }
  15952. declare module BABYLON {
  15953. /**
  15954. * 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.
  15955. * This is the base class of any Procedural texture and contains most of the shareable code.
  15956. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15957. */
  15958. export class ProceduralTexture extends Texture {
  15959. isCube: boolean;
  15960. /**
  15961. * Define if the texture is enabled or not (disabled texture will not render)
  15962. */
  15963. isEnabled: boolean;
  15964. /**
  15965. * Define if the texture must be cleared before rendering (default is true)
  15966. */
  15967. autoClear: boolean;
  15968. /**
  15969. * Callback called when the texture is generated
  15970. */
  15971. onGenerated: () => void;
  15972. /**
  15973. * Event raised when the texture is generated
  15974. */
  15975. onGeneratedObservable: Observable<ProceduralTexture>;
  15976. /** @hidden */
  15977. _generateMipMaps: boolean;
  15978. /** @hidden **/
  15979. _effect: Effect;
  15980. /** @hidden */
  15981. _textures: {
  15982. [key: string]: Texture;
  15983. };
  15984. private _size;
  15985. private _currentRefreshId;
  15986. private _refreshRate;
  15987. private _vertexBuffers;
  15988. private _indexBuffer;
  15989. private _uniforms;
  15990. private _samplers;
  15991. private _fragment;
  15992. private _floats;
  15993. private _ints;
  15994. private _floatsArrays;
  15995. private _colors3;
  15996. private _colors4;
  15997. private _vectors2;
  15998. private _vectors3;
  15999. private _matrices;
  16000. private _fallbackTexture;
  16001. private _fallbackTextureUsed;
  16002. private _engine;
  16003. private _cachedDefines;
  16004. private _contentUpdateId;
  16005. private _contentData;
  16006. /**
  16007. * Instantiates a new procedural texture.
  16008. * 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.
  16009. * This is the base class of any Procedural texture and contains most of the shareable code.
  16010. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16011. * @param name Define the name of the texture
  16012. * @param size Define the size of the texture to create
  16013. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16014. * @param scene Define the scene the texture belongs to
  16015. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16016. * @param generateMipMaps Define if the texture should creates mip maps or not
  16017. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16018. */
  16019. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16020. /**
  16021. * The effect that is created when initializing the post process.
  16022. * @returns The created effect corresponding the the postprocess.
  16023. */
  16024. getEffect(): Effect;
  16025. /**
  16026. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16027. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16028. */
  16029. getContent(): Nullable<ArrayBufferView>;
  16030. private _createIndexBuffer;
  16031. /** @hidden */
  16032. _rebuild(): void;
  16033. /**
  16034. * Resets the texture in order to recreate its associated resources.
  16035. * This can be called in case of context loss
  16036. */
  16037. reset(): void;
  16038. protected _getDefines(): string;
  16039. /**
  16040. * Is the texture ready to be used ? (rendered at least once)
  16041. * @returns true if ready, otherwise, false.
  16042. */
  16043. isReady(): boolean;
  16044. /**
  16045. * Resets the refresh counter of the texture and start bak from scratch.
  16046. * Could be useful to regenerate the texture if it is setup to render only once.
  16047. */
  16048. resetRefreshCounter(): void;
  16049. /**
  16050. * Set the fragment shader to use in order to render the texture.
  16051. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16052. */
  16053. setFragment(fragment: any): void;
  16054. /**
  16055. * Define the refresh rate of the texture or the rendering frequency.
  16056. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16057. */
  16058. refreshRate: number;
  16059. /** @hidden */
  16060. _shouldRender(): boolean;
  16061. /**
  16062. * Get the size the texture is rendering at.
  16063. * @returns the size (texture is always squared)
  16064. */
  16065. getRenderSize(): number;
  16066. /**
  16067. * Resize the texture to new value.
  16068. * @param size Define the new size the texture should have
  16069. * @param generateMipMaps Define whether the new texture should create mip maps
  16070. */
  16071. resize(size: number, generateMipMaps: boolean): void;
  16072. private _checkUniform;
  16073. /**
  16074. * Set a texture in the shader program used to render.
  16075. * @param name Define the name of the uniform samplers as defined in the shader
  16076. * @param texture Define the texture to bind to this sampler
  16077. * @return the texture itself allowing "fluent" like uniform updates
  16078. */
  16079. setTexture(name: string, texture: Texture): ProceduralTexture;
  16080. /**
  16081. * Set a float in the shader.
  16082. * @param name Define the name of the uniform as defined in the shader
  16083. * @param value Define the value to give to the uniform
  16084. * @return the texture itself allowing "fluent" like uniform updates
  16085. */
  16086. setFloat(name: string, value: number): ProceduralTexture;
  16087. /**
  16088. * Set a int 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. setInt(name: string, value: number): ProceduralTexture;
  16094. /**
  16095. * Set an array of floats 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. setFloats(name: string, value: number[]): ProceduralTexture;
  16101. /**
  16102. * Set a vec3 in the shader from a Color3.
  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. setColor3(name: string, value: Color3): ProceduralTexture;
  16108. /**
  16109. * Set a vec4 in the shader from a Color4.
  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. setColor4(name: string, value: Color4): ProceduralTexture;
  16115. /**
  16116. * Set a vec2 in the shader from a Vector2.
  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. setVector2(name: string, value: Vector2): ProceduralTexture;
  16122. /**
  16123. * Set a vec3 in the shader from a Vector3.
  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. setVector3(name: string, value: Vector3): ProceduralTexture;
  16129. /**
  16130. * Set a mat4 in the shader from a MAtrix.
  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. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16136. /**
  16137. * Render the texture to its associated render target.
  16138. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16139. */
  16140. render(useCameraPostProcess?: boolean): void;
  16141. /**
  16142. * Clone the texture.
  16143. * @returns the cloned texture
  16144. */
  16145. clone(): ProceduralTexture;
  16146. /**
  16147. * Dispose the texture and release its asoociated resources.
  16148. */
  16149. dispose(): void;
  16150. }
  16151. }
  16152. declare module BABYLON {
  16153. /**
  16154. * This represents the base class for particle system in Babylon.
  16155. * 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.
  16156. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16157. * @example https://doc.babylonjs.com/babylon101/particles
  16158. */
  16159. export class BaseParticleSystem {
  16160. /**
  16161. * Source color is added to the destination color without alpha affecting the result
  16162. */
  16163. static BLENDMODE_ONEONE: number;
  16164. /**
  16165. * Blend current color and particle color using particle’s alpha
  16166. */
  16167. static BLENDMODE_STANDARD: number;
  16168. /**
  16169. * Add current color and particle color multiplied by particle’s alpha
  16170. */
  16171. static BLENDMODE_ADD: number;
  16172. /**
  16173. * Multiply current color with particle color
  16174. */
  16175. static BLENDMODE_MULTIPLY: number;
  16176. /**
  16177. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16178. */
  16179. static BLENDMODE_MULTIPLYADD: number;
  16180. /**
  16181. * List of animations used by the particle system.
  16182. */
  16183. animations: Animation[];
  16184. /**
  16185. * The id of the Particle system.
  16186. */
  16187. id: string;
  16188. /**
  16189. * The friendly name of the Particle system.
  16190. */
  16191. name: string;
  16192. /**
  16193. * The rendering group used by the Particle system to chose when to render.
  16194. */
  16195. renderingGroupId: number;
  16196. /**
  16197. * The emitter represents the Mesh or position we are attaching the particle system to.
  16198. */
  16199. emitter: Nullable<AbstractMesh | Vector3>;
  16200. /**
  16201. * The maximum number of particles to emit per frame
  16202. */
  16203. emitRate: number;
  16204. /**
  16205. * If you want to launch only a few particles at once, that can be done, as well.
  16206. */
  16207. manualEmitCount: number;
  16208. /**
  16209. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16210. */
  16211. updateSpeed: number;
  16212. /**
  16213. * The amount of time the particle system is running (depends of the overall update speed).
  16214. */
  16215. targetStopDuration: number;
  16216. /**
  16217. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16218. */
  16219. disposeOnStop: boolean;
  16220. /**
  16221. * Minimum power of emitting particles.
  16222. */
  16223. minEmitPower: number;
  16224. /**
  16225. * Maximum power of emitting particles.
  16226. */
  16227. maxEmitPower: number;
  16228. /**
  16229. * Minimum life time of emitting particles.
  16230. */
  16231. minLifeTime: number;
  16232. /**
  16233. * Maximum life time of emitting particles.
  16234. */
  16235. maxLifeTime: number;
  16236. /**
  16237. * Minimum Size of emitting particles.
  16238. */
  16239. minSize: number;
  16240. /**
  16241. * Maximum Size of emitting particles.
  16242. */
  16243. maxSize: number;
  16244. /**
  16245. * Minimum scale of emitting particles on X axis.
  16246. */
  16247. minScaleX: number;
  16248. /**
  16249. * Maximum scale of emitting particles on X axis.
  16250. */
  16251. maxScaleX: number;
  16252. /**
  16253. * Minimum scale of emitting particles on Y axis.
  16254. */
  16255. minScaleY: number;
  16256. /**
  16257. * Maximum scale of emitting particles on Y axis.
  16258. */
  16259. maxScaleY: number;
  16260. /**
  16261. * Gets or sets the minimal initial rotation in radians.
  16262. */
  16263. minInitialRotation: number;
  16264. /**
  16265. * Gets or sets the maximal initial rotation in radians.
  16266. */
  16267. maxInitialRotation: number;
  16268. /**
  16269. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16270. */
  16271. minAngularSpeed: number;
  16272. /**
  16273. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16274. */
  16275. maxAngularSpeed: number;
  16276. /**
  16277. * The texture used to render each particle. (this can be a spritesheet)
  16278. */
  16279. particleTexture: Nullable<Texture>;
  16280. /**
  16281. * The layer mask we are rendering the particles through.
  16282. */
  16283. layerMask: number;
  16284. /**
  16285. * This can help using your own shader to render the particle system.
  16286. * The according effect will be created
  16287. */
  16288. customShader: any;
  16289. /**
  16290. * By default particle system starts as soon as they are created. This prevents the
  16291. * automatic start to happen and let you decide when to start emitting particles.
  16292. */
  16293. preventAutoStart: boolean;
  16294. private _noiseTexture;
  16295. /**
  16296. * Gets or sets a texture used to add random noise to particle positions
  16297. */
  16298. noiseTexture: Nullable<ProceduralTexture>;
  16299. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16300. noiseStrength: Vector3;
  16301. /**
  16302. * Callback triggered when the particle animation is ending.
  16303. */
  16304. onAnimationEnd: Nullable<() => void>;
  16305. /**
  16306. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16307. */
  16308. blendMode: number;
  16309. /**
  16310. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16311. * to override the particles.
  16312. */
  16313. forceDepthWrite: boolean;
  16314. /** 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 */
  16315. preWarmCycles: number;
  16316. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16317. preWarmStepOffset: number;
  16318. /**
  16319. * 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)
  16320. */
  16321. spriteCellChangeSpeed: number;
  16322. /**
  16323. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16324. */
  16325. startSpriteCellID: number;
  16326. /**
  16327. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16328. */
  16329. endSpriteCellID: number;
  16330. /**
  16331. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16332. */
  16333. spriteCellWidth: number;
  16334. /**
  16335. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16336. */
  16337. spriteCellHeight: number;
  16338. /**
  16339. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16340. */
  16341. spriteRandomStartCell: boolean;
  16342. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16343. translationPivot: Vector2;
  16344. /** @hidden */
  16345. protected _isAnimationSheetEnabled: boolean;
  16346. /**
  16347. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16348. */
  16349. beginAnimationOnStart: boolean;
  16350. /**
  16351. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16352. */
  16353. beginAnimationFrom: number;
  16354. /**
  16355. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16356. */
  16357. beginAnimationTo: number;
  16358. /**
  16359. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16360. */
  16361. beginAnimationLoop: boolean;
  16362. /**
  16363. * Gets or sets a world offset applied to all particles
  16364. */
  16365. worldOffset: Vector3;
  16366. /**
  16367. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16368. */
  16369. isAnimationSheetEnabled: boolean;
  16370. /**
  16371. * Get hosting scene
  16372. * @returns the scene
  16373. */
  16374. getScene(): Scene;
  16375. /**
  16376. * You can use gravity if you want to give an orientation to your particles.
  16377. */
  16378. gravity: Vector3;
  16379. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16380. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16381. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16382. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16383. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16384. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16385. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16386. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16387. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16388. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16389. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16390. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16391. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16392. /**
  16393. * Defines the delay in milliseconds before starting the system (0 by default)
  16394. */
  16395. startDelay: number;
  16396. /**
  16397. * Gets the current list of drag gradients.
  16398. * You must use addDragGradient and removeDragGradient to udpate this list
  16399. * @returns the list of drag gradients
  16400. */
  16401. getDragGradients(): Nullable<Array<FactorGradient>>;
  16402. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16403. limitVelocityDamping: number;
  16404. /**
  16405. * Gets the current list of limit velocity gradients.
  16406. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16407. * @returns the list of limit velocity gradients
  16408. */
  16409. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16410. /**
  16411. * Gets the current list of color gradients.
  16412. * You must use addColorGradient and removeColorGradient to udpate this list
  16413. * @returns the list of color gradients
  16414. */
  16415. getColorGradients(): Nullable<Array<ColorGradient>>;
  16416. /**
  16417. * Gets the current list of size gradients.
  16418. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16419. * @returns the list of size gradients
  16420. */
  16421. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16422. /**
  16423. * Gets the current list of color remap gradients.
  16424. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16425. * @returns the list of color remap gradients
  16426. */
  16427. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16428. /**
  16429. * Gets the current list of alpha remap gradients.
  16430. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16431. * @returns the list of alpha remap gradients
  16432. */
  16433. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16434. /**
  16435. * Gets the current list of life time gradients.
  16436. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16437. * @returns the list of life time gradients
  16438. */
  16439. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16440. /**
  16441. * Gets the current list of angular speed gradients.
  16442. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16443. * @returns the list of angular speed gradients
  16444. */
  16445. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16446. /**
  16447. * Gets the current list of velocity gradients.
  16448. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16449. * @returns the list of velocity gradients
  16450. */
  16451. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16452. /**
  16453. * Gets the current list of start size gradients.
  16454. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16455. * @returns the list of start size gradients
  16456. */
  16457. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16458. /**
  16459. * Gets the current list of emit rate gradients.
  16460. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16461. * @returns the list of emit rate gradients
  16462. */
  16463. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16464. /**
  16465. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16466. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16467. */
  16468. direction1: Vector3;
  16469. /**
  16470. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16471. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16472. */
  16473. direction2: Vector3;
  16474. /**
  16475. * 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.
  16476. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16477. */
  16478. minEmitBox: Vector3;
  16479. /**
  16480. * 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.
  16481. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16482. */
  16483. maxEmitBox: Vector3;
  16484. /**
  16485. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16486. */
  16487. color1: Color4;
  16488. /**
  16489. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16490. */
  16491. color2: Color4;
  16492. /**
  16493. * Color the particle will have at the end of its lifetime
  16494. */
  16495. colorDead: Color4;
  16496. /**
  16497. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16498. */
  16499. textureMask: Color4;
  16500. /**
  16501. * The particle emitter type defines the emitter used by the particle system.
  16502. * It can be for example box, sphere, or cone...
  16503. */
  16504. particleEmitterType: IParticleEmitterType;
  16505. /** @hidden */
  16506. _isSubEmitter: boolean;
  16507. /**
  16508. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16509. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16510. */
  16511. billboardMode: number;
  16512. protected _isBillboardBased: boolean;
  16513. /**
  16514. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16515. */
  16516. isBillboardBased: boolean;
  16517. /**
  16518. * The scene the particle system belongs to.
  16519. */
  16520. protected _scene: Scene;
  16521. /**
  16522. * Local cache of defines for image processing.
  16523. */
  16524. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16525. /**
  16526. * Default configuration related to image processing available in the standard Material.
  16527. */
  16528. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16529. /**
  16530. * Gets the image processing configuration used either in this material.
  16531. */
  16532. /**
  16533. * Sets the Default image processing configuration used either in the this material.
  16534. *
  16535. * If sets to null, the scene one is in use.
  16536. */
  16537. imageProcessingConfiguration: ImageProcessingConfiguration;
  16538. /**
  16539. * Attaches a new image processing configuration to the Standard Material.
  16540. * @param configuration
  16541. */
  16542. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16543. /** @hidden */
  16544. protected _reset(): void;
  16545. /** @hidden */
  16546. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16547. /**
  16548. * Instantiates a particle system.
  16549. * 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.
  16550. * @param name The name of the particle system
  16551. */
  16552. constructor(name: string);
  16553. /**
  16554. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16555. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16556. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16557. * @returns the emitter
  16558. */
  16559. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16560. /**
  16561. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16562. * @param radius The radius of the hemisphere to emit from
  16563. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16564. * @returns the emitter
  16565. */
  16566. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16567. /**
  16568. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16569. * @param radius The radius of the sphere to emit from
  16570. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16571. * @returns the emitter
  16572. */
  16573. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16574. /**
  16575. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16576. * @param radius The radius of the sphere to emit from
  16577. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16578. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16579. * @returns the emitter
  16580. */
  16581. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16582. /**
  16583. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16584. * @param radius The radius of the emission cylinder
  16585. * @param height The height of the emission cylinder
  16586. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16587. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16588. * @returns the emitter
  16589. */
  16590. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16591. /**
  16592. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16593. * @param radius The radius of the cylinder to emit from
  16594. * @param height The height of the emission cylinder
  16595. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16596. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16597. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16598. * @returns the emitter
  16599. */
  16600. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16601. /**
  16602. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16603. * @param radius The radius of the cone to emit from
  16604. * @param angle The base angle of the cone
  16605. * @returns the emitter
  16606. */
  16607. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16608. /**
  16609. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16610. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16611. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16612. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16613. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16614. * @returns the emitter
  16615. */
  16616. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16617. }
  16618. }
  16619. declare module BABYLON {
  16620. /**
  16621. * Type of sub emitter
  16622. */
  16623. export enum SubEmitterType {
  16624. /**
  16625. * Attached to the particle over it's lifetime
  16626. */
  16627. ATTACHED = 0,
  16628. /**
  16629. * Created when the particle dies
  16630. */
  16631. END = 1
  16632. }
  16633. /**
  16634. * Sub emitter class used to emit particles from an existing particle
  16635. */
  16636. export class SubEmitter {
  16637. /**
  16638. * the particle system to be used by the sub emitter
  16639. */
  16640. particleSystem: ParticleSystem;
  16641. /**
  16642. * Type of the submitter (Default: END)
  16643. */
  16644. type: SubEmitterType;
  16645. /**
  16646. * 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)
  16647. * Note: This only is supported when using an emitter of type Mesh
  16648. */
  16649. inheritDirection: boolean;
  16650. /**
  16651. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16652. */
  16653. inheritedVelocityAmount: number;
  16654. /**
  16655. * Creates a sub emitter
  16656. * @param particleSystem the particle system to be used by the sub emitter
  16657. */
  16658. constructor(
  16659. /**
  16660. * the particle system to be used by the sub emitter
  16661. */
  16662. particleSystem: ParticleSystem);
  16663. /**
  16664. * Clones the sub emitter
  16665. * @returns the cloned sub emitter
  16666. */
  16667. clone(): SubEmitter;
  16668. /**
  16669. * Serialize current object to a JSON object
  16670. * @returns the serialized object
  16671. */
  16672. serialize(): any;
  16673. /** @hidden */
  16674. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16675. /**
  16676. * Creates a new SubEmitter from a serialized JSON version
  16677. * @param serializationObject defines the JSON object to read from
  16678. * @param scene defines the hosting scene
  16679. * @param rootUrl defines the rootUrl for data loading
  16680. * @returns a new SubEmitter
  16681. */
  16682. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16683. /** Release associated resources */
  16684. dispose(): void;
  16685. }
  16686. }
  16687. declare module BABYLON {
  16688. /** @hidden */
  16689. export var clipPlaneFragmentDeclaration: {
  16690. name: string;
  16691. shader: string;
  16692. };
  16693. }
  16694. declare module BABYLON {
  16695. /** @hidden */
  16696. export var imageProcessingDeclaration: {
  16697. name: string;
  16698. shader: string;
  16699. };
  16700. }
  16701. declare module BABYLON {
  16702. /** @hidden */
  16703. export var imageProcessingFunctions: {
  16704. name: string;
  16705. shader: string;
  16706. };
  16707. }
  16708. declare module BABYLON {
  16709. /** @hidden */
  16710. export var clipPlaneFragment: {
  16711. name: string;
  16712. shader: string;
  16713. };
  16714. }
  16715. declare module BABYLON {
  16716. /** @hidden */
  16717. export var particlesPixelShader: {
  16718. name: string;
  16719. shader: string;
  16720. };
  16721. }
  16722. declare module BABYLON {
  16723. /** @hidden */
  16724. export var clipPlaneVertexDeclaration: {
  16725. name: string;
  16726. shader: string;
  16727. };
  16728. }
  16729. declare module BABYLON {
  16730. /** @hidden */
  16731. export var clipPlaneVertex: {
  16732. name: string;
  16733. shader: string;
  16734. };
  16735. }
  16736. declare module BABYLON {
  16737. /** @hidden */
  16738. export var particlesVertexShader: {
  16739. name: string;
  16740. shader: string;
  16741. };
  16742. }
  16743. declare module BABYLON {
  16744. /**
  16745. * This represents a particle system in Babylon.
  16746. * 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.
  16747. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16748. * @example https://doc.babylonjs.com/babylon101/particles
  16749. */
  16750. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16751. /**
  16752. * Billboard mode will only apply to Y axis
  16753. */
  16754. static readonly BILLBOARDMODE_Y: number;
  16755. /**
  16756. * Billboard mode will apply to all axes
  16757. */
  16758. static readonly BILLBOARDMODE_ALL: number;
  16759. /**
  16760. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16761. */
  16762. static readonly BILLBOARDMODE_STRETCHED: number;
  16763. /**
  16764. * This function can be defined to provide custom update for active particles.
  16765. * This function will be called instead of regular update (age, position, color, etc.).
  16766. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16767. */
  16768. updateFunction: (particles: Particle[]) => void;
  16769. private _emitterWorldMatrix;
  16770. /**
  16771. * This function can be defined to specify initial direction for every new particle.
  16772. * It by default use the emitterType defined function
  16773. */
  16774. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16775. /**
  16776. * This function can be defined to specify initial position for every new particle.
  16777. * It by default use the emitterType defined function
  16778. */
  16779. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16780. /**
  16781. * @hidden
  16782. */
  16783. _inheritedVelocityOffset: Vector3;
  16784. /**
  16785. * An event triggered when the system is disposed
  16786. */
  16787. onDisposeObservable: Observable<ParticleSystem>;
  16788. private _onDisposeObserver;
  16789. /**
  16790. * Sets a callback that will be triggered when the system is disposed
  16791. */
  16792. onDispose: () => void;
  16793. private _particles;
  16794. private _epsilon;
  16795. private _capacity;
  16796. private _stockParticles;
  16797. private _newPartsExcess;
  16798. private _vertexData;
  16799. private _vertexBuffer;
  16800. private _vertexBuffers;
  16801. private _spriteBuffer;
  16802. private _indexBuffer;
  16803. private _effect;
  16804. private _customEffect;
  16805. private _cachedDefines;
  16806. private _scaledColorStep;
  16807. private _colorDiff;
  16808. private _scaledDirection;
  16809. private _scaledGravity;
  16810. private _currentRenderId;
  16811. private _alive;
  16812. private _useInstancing;
  16813. private _started;
  16814. private _stopped;
  16815. private _actualFrame;
  16816. private _scaledUpdateSpeed;
  16817. private _vertexBufferSize;
  16818. /** @hidden */
  16819. _currentEmitRateGradient: Nullable<FactorGradient>;
  16820. /** @hidden */
  16821. _currentEmitRate1: number;
  16822. /** @hidden */
  16823. _currentEmitRate2: number;
  16824. /** @hidden */
  16825. _currentStartSizeGradient: Nullable<FactorGradient>;
  16826. /** @hidden */
  16827. _currentStartSize1: number;
  16828. /** @hidden */
  16829. _currentStartSize2: number;
  16830. private readonly _rawTextureWidth;
  16831. private _rampGradientsTexture;
  16832. private _useRampGradients;
  16833. /** Gets or sets a boolean indicating that ramp gradients must be used
  16834. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16835. */
  16836. useRampGradients: boolean;
  16837. /**
  16838. * 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.
  16839. * 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: [])
  16840. */
  16841. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16842. private _subEmitters;
  16843. /**
  16844. * @hidden
  16845. * If the particle systems emitter should be disposed when the particle system is disposed
  16846. */
  16847. _disposeEmitterOnDispose: boolean;
  16848. /**
  16849. * The current active Sub-systems, this property is used by the root particle system only.
  16850. */
  16851. activeSubSystems: Array<ParticleSystem>;
  16852. private _rootParticleSystem;
  16853. /**
  16854. * Gets the current list of active particles
  16855. */
  16856. readonly particles: Particle[];
  16857. /**
  16858. * Returns the string "ParticleSystem"
  16859. * @returns a string containing the class name
  16860. */
  16861. getClassName(): string;
  16862. /**
  16863. * Instantiates a particle system.
  16864. * 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.
  16865. * @param name The name of the particle system
  16866. * @param capacity The max number of particles alive at the same time
  16867. * @param scene The scene the particle system belongs to
  16868. * @param customEffect a custom effect used to change the way particles are rendered by default
  16869. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16870. * @param epsilon Offset used to render the particles
  16871. */
  16872. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16873. private _addFactorGradient;
  16874. private _removeFactorGradient;
  16875. /**
  16876. * Adds a new life time gradient
  16877. * @param gradient defines the gradient to use (between 0 and 1)
  16878. * @param factor defines the life time factor to affect to the specified gradient
  16879. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16880. * @returns the current particle system
  16881. */
  16882. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16883. /**
  16884. * Remove a specific life time gradient
  16885. * @param gradient defines the gradient to remove
  16886. * @returns the current particle system
  16887. */
  16888. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16889. /**
  16890. * Adds a new size gradient
  16891. * @param gradient defines the gradient to use (between 0 and 1)
  16892. * @param factor defines the size factor to affect to the specified gradient
  16893. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16894. * @returns the current particle system
  16895. */
  16896. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16897. /**
  16898. * Remove a specific size gradient
  16899. * @param gradient defines the gradient to remove
  16900. * @returns the current particle system
  16901. */
  16902. removeSizeGradient(gradient: number): IParticleSystem;
  16903. /**
  16904. * Adds a new color remap gradient
  16905. * @param gradient defines the gradient to use (between 0 and 1)
  16906. * @param min defines the color remap minimal range
  16907. * @param max defines the color remap maximal range
  16908. * @returns the current particle system
  16909. */
  16910. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16911. /**
  16912. * Remove a specific color remap gradient
  16913. * @param gradient defines the gradient to remove
  16914. * @returns the current particle system
  16915. */
  16916. removeColorRemapGradient(gradient: number): IParticleSystem;
  16917. /**
  16918. * Adds a new alpha remap gradient
  16919. * @param gradient defines the gradient to use (between 0 and 1)
  16920. * @param min defines the alpha remap minimal range
  16921. * @param max defines the alpha remap maximal range
  16922. * @returns the current particle system
  16923. */
  16924. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16925. /**
  16926. * Remove a specific alpha remap gradient
  16927. * @param gradient defines the gradient to remove
  16928. * @returns the current particle system
  16929. */
  16930. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  16931. /**
  16932. * Adds a new angular speed gradient
  16933. * @param gradient defines the gradient to use (between 0 and 1)
  16934. * @param factor defines the angular speed to affect to the specified gradient
  16935. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16936. * @returns the current particle system
  16937. */
  16938. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16939. /**
  16940. * Remove a specific angular speed gradient
  16941. * @param gradient defines the gradient to remove
  16942. * @returns the current particle system
  16943. */
  16944. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16945. /**
  16946. * Adds a new velocity gradient
  16947. * @param gradient defines the gradient to use (between 0 and 1)
  16948. * @param factor defines the velocity to affect to the specified gradient
  16949. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16950. * @returns the current particle system
  16951. */
  16952. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16953. /**
  16954. * Remove a specific velocity gradient
  16955. * @param gradient defines the gradient to remove
  16956. * @returns the current particle system
  16957. */
  16958. removeVelocityGradient(gradient: number): IParticleSystem;
  16959. /**
  16960. * Adds a new limit velocity gradient
  16961. * @param gradient defines the gradient to use (between 0 and 1)
  16962. * @param factor defines the limit velocity value to affect to the specified gradient
  16963. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16964. * @returns the current particle system
  16965. */
  16966. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16967. /**
  16968. * Remove a specific limit velocity gradient
  16969. * @param gradient defines the gradient to remove
  16970. * @returns the current particle system
  16971. */
  16972. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16973. /**
  16974. * Adds a new drag gradient
  16975. * @param gradient defines the gradient to use (between 0 and 1)
  16976. * @param factor defines the drag value to affect to the specified gradient
  16977. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16978. * @returns the current particle system
  16979. */
  16980. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16981. /**
  16982. * Remove a specific drag gradient
  16983. * @param gradient defines the gradient to remove
  16984. * @returns the current particle system
  16985. */
  16986. removeDragGradient(gradient: number): IParticleSystem;
  16987. /**
  16988. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16989. * @param gradient defines the gradient to use (between 0 and 1)
  16990. * @param factor defines the emit rate value to affect to the specified gradient
  16991. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16992. * @returns the current particle system
  16993. */
  16994. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16995. /**
  16996. * Remove a specific emit rate gradient
  16997. * @param gradient defines the gradient to remove
  16998. * @returns the current particle system
  16999. */
  17000. removeEmitRateGradient(gradient: number): IParticleSystem;
  17001. /**
  17002. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17003. * @param gradient defines the gradient to use (between 0 and 1)
  17004. * @param factor defines the start size value to affect to the specified gradient
  17005. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17006. * @returns the current particle system
  17007. */
  17008. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17009. /**
  17010. * Remove a specific start size gradient
  17011. * @param gradient defines the gradient to remove
  17012. * @returns the current particle system
  17013. */
  17014. removeStartSizeGradient(gradient: number): IParticleSystem;
  17015. private _createRampGradientTexture;
  17016. /**
  17017. * Gets the current list of ramp gradients.
  17018. * You must use addRampGradient and removeRampGradient to udpate this list
  17019. * @returns the list of ramp gradients
  17020. */
  17021. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17022. /**
  17023. * Adds a new ramp gradient used to remap particle colors
  17024. * @param gradient defines the gradient to use (between 0 and 1)
  17025. * @param color defines the color to affect to the specified gradient
  17026. * @returns the current particle system
  17027. */
  17028. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17029. /**
  17030. * Remove a specific ramp gradient
  17031. * @param gradient defines the gradient to remove
  17032. * @returns the current particle system
  17033. */
  17034. removeRampGradient(gradient: number): ParticleSystem;
  17035. /**
  17036. * Adds a new color gradient
  17037. * @param gradient defines the gradient to use (between 0 and 1)
  17038. * @param color1 defines the color to affect to the specified gradient
  17039. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17040. * @returns this particle system
  17041. */
  17042. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17043. /**
  17044. * Remove a specific color gradient
  17045. * @param gradient defines the gradient to remove
  17046. * @returns this particle system
  17047. */
  17048. removeColorGradient(gradient: number): IParticleSystem;
  17049. private _fetchR;
  17050. protected _reset(): void;
  17051. private _resetEffect;
  17052. private _createVertexBuffers;
  17053. private _createIndexBuffer;
  17054. /**
  17055. * Gets the maximum number of particles active at the same time.
  17056. * @returns The max number of active particles.
  17057. */
  17058. getCapacity(): number;
  17059. /**
  17060. * Gets whether there are still active particles in the system.
  17061. * @returns True if it is alive, otherwise false.
  17062. */
  17063. isAlive(): boolean;
  17064. /**
  17065. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17066. * @returns True if it has been started, otherwise false.
  17067. */
  17068. isStarted(): boolean;
  17069. private _prepareSubEmitterInternalArray;
  17070. /**
  17071. * Starts the particle system and begins to emit
  17072. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17073. */
  17074. start(delay?: number): void;
  17075. /**
  17076. * Stops the particle system.
  17077. * @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.
  17078. */
  17079. stop(stopSubEmitters?: boolean): void;
  17080. /**
  17081. * Remove all active particles
  17082. */
  17083. reset(): void;
  17084. /**
  17085. * @hidden (for internal use only)
  17086. */
  17087. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17088. /**
  17089. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17090. * Its lifetime will start back at 0.
  17091. */
  17092. recycleParticle: (particle: Particle) => void;
  17093. private _stopSubEmitters;
  17094. private _createParticle;
  17095. private _removeFromRoot;
  17096. private _emitFromParticle;
  17097. private _update;
  17098. /** @hidden */
  17099. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17100. /** @hidden */
  17101. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17102. /** @hidden */
  17103. private _getEffect;
  17104. /**
  17105. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17106. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17107. */
  17108. animate(preWarmOnly?: boolean): void;
  17109. private _appendParticleVertices;
  17110. /**
  17111. * Rebuilds the particle system.
  17112. */
  17113. rebuild(): void;
  17114. /**
  17115. * Is this system ready to be used/rendered
  17116. * @return true if the system is ready
  17117. */
  17118. isReady(): boolean;
  17119. private _render;
  17120. /**
  17121. * Renders the particle system in its current state.
  17122. * @returns the current number of particles
  17123. */
  17124. render(): number;
  17125. /**
  17126. * Disposes the particle system and free the associated resources
  17127. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17128. */
  17129. dispose(disposeTexture?: boolean): void;
  17130. /**
  17131. * Clones the particle system.
  17132. * @param name The name of the cloned object
  17133. * @param newEmitter The new emitter to use
  17134. * @returns the cloned particle system
  17135. */
  17136. clone(name: string, newEmitter: any): ParticleSystem;
  17137. /**
  17138. * Serializes the particle system to a JSON object.
  17139. * @returns the JSON object
  17140. */
  17141. serialize(): any;
  17142. /** @hidden */
  17143. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17144. /** @hidden */
  17145. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17146. /**
  17147. * Parses a JSON object to create a particle system.
  17148. * @param parsedParticleSystem The JSON object to parse
  17149. * @param scene The scene to create the particle system in
  17150. * @param rootUrl The root url to use to load external dependencies like texture
  17151. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17152. * @returns the Parsed particle system
  17153. */
  17154. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17155. }
  17156. }
  17157. declare module BABYLON {
  17158. /**
  17159. * A particle represents one of the element emitted by a particle system.
  17160. * This is mainly define by its coordinates, direction, velocity and age.
  17161. */
  17162. export class Particle {
  17163. /**
  17164. * The particle system the particle belongs to.
  17165. */
  17166. particleSystem: ParticleSystem;
  17167. private static _Count;
  17168. /**
  17169. * Unique ID of the particle
  17170. */
  17171. id: number;
  17172. /**
  17173. * The world position of the particle in the scene.
  17174. */
  17175. position: Vector3;
  17176. /**
  17177. * The world direction of the particle in the scene.
  17178. */
  17179. direction: Vector3;
  17180. /**
  17181. * The color of the particle.
  17182. */
  17183. color: Color4;
  17184. /**
  17185. * The color change of the particle per step.
  17186. */
  17187. colorStep: Color4;
  17188. /**
  17189. * Defines how long will the life of the particle be.
  17190. */
  17191. lifeTime: number;
  17192. /**
  17193. * The current age of the particle.
  17194. */
  17195. age: number;
  17196. /**
  17197. * The current size of the particle.
  17198. */
  17199. size: number;
  17200. /**
  17201. * The current scale of the particle.
  17202. */
  17203. scale: Vector2;
  17204. /**
  17205. * The current angle of the particle.
  17206. */
  17207. angle: number;
  17208. /**
  17209. * Defines how fast is the angle changing.
  17210. */
  17211. angularSpeed: number;
  17212. /**
  17213. * Defines the cell index used by the particle to be rendered from a sprite.
  17214. */
  17215. cellIndex: number;
  17216. /**
  17217. * The information required to support color remapping
  17218. */
  17219. remapData: Vector4;
  17220. /** @hidden */
  17221. _randomCellOffset?: number;
  17222. /** @hidden */
  17223. _initialDirection: Nullable<Vector3>;
  17224. /** @hidden */
  17225. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17226. /** @hidden */
  17227. _initialStartSpriteCellID: number;
  17228. /** @hidden */
  17229. _initialEndSpriteCellID: number;
  17230. /** @hidden */
  17231. _currentColorGradient: Nullable<ColorGradient>;
  17232. /** @hidden */
  17233. _currentColor1: Color4;
  17234. /** @hidden */
  17235. _currentColor2: Color4;
  17236. /** @hidden */
  17237. _currentSizeGradient: Nullable<FactorGradient>;
  17238. /** @hidden */
  17239. _currentSize1: number;
  17240. /** @hidden */
  17241. _currentSize2: number;
  17242. /** @hidden */
  17243. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17244. /** @hidden */
  17245. _currentAngularSpeed1: number;
  17246. /** @hidden */
  17247. _currentAngularSpeed2: number;
  17248. /** @hidden */
  17249. _currentVelocityGradient: Nullable<FactorGradient>;
  17250. /** @hidden */
  17251. _currentVelocity1: number;
  17252. /** @hidden */
  17253. _currentVelocity2: number;
  17254. /** @hidden */
  17255. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17256. /** @hidden */
  17257. _currentLimitVelocity1: number;
  17258. /** @hidden */
  17259. _currentLimitVelocity2: number;
  17260. /** @hidden */
  17261. _currentDragGradient: Nullable<FactorGradient>;
  17262. /** @hidden */
  17263. _currentDrag1: number;
  17264. /** @hidden */
  17265. _currentDrag2: number;
  17266. /** @hidden */
  17267. _randomNoiseCoordinates1: Vector3;
  17268. /** @hidden */
  17269. _randomNoiseCoordinates2: Vector3;
  17270. /**
  17271. * Creates a new instance Particle
  17272. * @param particleSystem the particle system the particle belongs to
  17273. */
  17274. constructor(
  17275. /**
  17276. * The particle system the particle belongs to.
  17277. */
  17278. particleSystem: ParticleSystem);
  17279. private updateCellInfoFromSystem;
  17280. /**
  17281. * Defines how the sprite cell index is updated for the particle
  17282. */
  17283. updateCellIndex(): void;
  17284. /** @hidden */
  17285. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17286. /** @hidden */
  17287. _inheritParticleInfoToSubEmitters(): void;
  17288. /** @hidden */
  17289. _reset(): void;
  17290. /**
  17291. * Copy the properties of particle to another one.
  17292. * @param other the particle to copy the information to.
  17293. */
  17294. copyTo(other: Particle): void;
  17295. }
  17296. }
  17297. declare module BABYLON {
  17298. /**
  17299. * Particle emitter represents a volume emitting particles.
  17300. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17301. */
  17302. export interface IParticleEmitterType {
  17303. /**
  17304. * Called by the particle System when the direction is computed for the created particle.
  17305. * @param worldMatrix is the world matrix of the particle system
  17306. * @param directionToUpdate is the direction vector to update with the result
  17307. * @param particle is the particle we are computed the direction for
  17308. */
  17309. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17310. /**
  17311. * Called by the particle System when the position is computed for the created particle.
  17312. * @param worldMatrix is the world matrix of the particle system
  17313. * @param positionToUpdate is the position vector to update with the result
  17314. * @param particle is the particle we are computed the position for
  17315. */
  17316. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17317. /**
  17318. * Clones the current emitter and returns a copy of it
  17319. * @returns the new emitter
  17320. */
  17321. clone(): IParticleEmitterType;
  17322. /**
  17323. * Called by the GPUParticleSystem to setup the update shader
  17324. * @param effect defines the update shader
  17325. */
  17326. applyToShader(effect: Effect): void;
  17327. /**
  17328. * Returns a string to use to update the GPU particles update shader
  17329. * @returns the effect defines string
  17330. */
  17331. getEffectDefines(): string;
  17332. /**
  17333. * Returns a string representing the class name
  17334. * @returns a string containing the class name
  17335. */
  17336. getClassName(): string;
  17337. /**
  17338. * Serializes the particle system to a JSON object.
  17339. * @returns the JSON object
  17340. */
  17341. serialize(): any;
  17342. /**
  17343. * Parse properties from a JSON object
  17344. * @param serializationObject defines the JSON object
  17345. */
  17346. parse(serializationObject: any): void;
  17347. }
  17348. }
  17349. declare module BABYLON {
  17350. /**
  17351. * Particle emitter emitting particles from the inside of a box.
  17352. * It emits the particles randomly between 2 given directions.
  17353. */
  17354. export class BoxParticleEmitter implements IParticleEmitterType {
  17355. /**
  17356. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17357. */
  17358. direction1: Vector3;
  17359. /**
  17360. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17361. */
  17362. direction2: Vector3;
  17363. /**
  17364. * 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.
  17365. */
  17366. minEmitBox: Vector3;
  17367. /**
  17368. * 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.
  17369. */
  17370. maxEmitBox: Vector3;
  17371. /**
  17372. * Creates a new instance BoxParticleEmitter
  17373. */
  17374. constructor();
  17375. /**
  17376. * Called by the particle System when the direction is computed for the created particle.
  17377. * @param worldMatrix is the world matrix of the particle system
  17378. * @param directionToUpdate is the direction vector to update with the result
  17379. * @param particle is the particle we are computed the direction for
  17380. */
  17381. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17382. /**
  17383. * Called by the particle System when the position is computed for the created particle.
  17384. * @param worldMatrix is the world matrix of the particle system
  17385. * @param positionToUpdate is the position vector to update with the result
  17386. * @param particle is the particle we are computed the position for
  17387. */
  17388. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17389. /**
  17390. * Clones the current emitter and returns a copy of it
  17391. * @returns the new emitter
  17392. */
  17393. clone(): BoxParticleEmitter;
  17394. /**
  17395. * Called by the GPUParticleSystem to setup the update shader
  17396. * @param effect defines the update shader
  17397. */
  17398. applyToShader(effect: Effect): void;
  17399. /**
  17400. * Returns a string to use to update the GPU particles update shader
  17401. * @returns a string containng the defines string
  17402. */
  17403. getEffectDefines(): string;
  17404. /**
  17405. * Returns the string "BoxParticleEmitter"
  17406. * @returns a string containing the class name
  17407. */
  17408. getClassName(): string;
  17409. /**
  17410. * Serializes the particle system to a JSON object.
  17411. * @returns the JSON object
  17412. */
  17413. serialize(): any;
  17414. /**
  17415. * Parse properties from a JSON object
  17416. * @param serializationObject defines the JSON object
  17417. */
  17418. parse(serializationObject: any): void;
  17419. }
  17420. }
  17421. declare module BABYLON {
  17422. /**
  17423. * Particle emitter emitting particles from the inside of a cone.
  17424. * It emits the particles alongside the cone volume from the base to the particle.
  17425. * The emission direction might be randomized.
  17426. */
  17427. export class ConeParticleEmitter implements IParticleEmitterType {
  17428. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17429. directionRandomizer: number;
  17430. private _radius;
  17431. private _angle;
  17432. private _height;
  17433. /**
  17434. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17435. */
  17436. radiusRange: number;
  17437. /**
  17438. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17439. */
  17440. heightRange: number;
  17441. /**
  17442. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17443. */
  17444. emitFromSpawnPointOnly: boolean;
  17445. /**
  17446. * Gets or sets the radius of the emission cone
  17447. */
  17448. radius: number;
  17449. /**
  17450. * Gets or sets the angle of the emission cone
  17451. */
  17452. angle: number;
  17453. private _buildHeight;
  17454. /**
  17455. * Creates a new instance ConeParticleEmitter
  17456. * @param radius the radius of the emission cone (1 by default)
  17457. * @param angle the cone base angle (PI by default)
  17458. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17459. */
  17460. constructor(radius?: number, angle?: number,
  17461. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17462. directionRandomizer?: number);
  17463. /**
  17464. * Called by the particle System when the direction is computed for the created particle.
  17465. * @param worldMatrix is the world matrix of the particle system
  17466. * @param directionToUpdate is the direction vector to update with the result
  17467. * @param particle is the particle we are computed the direction for
  17468. */
  17469. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17470. /**
  17471. * Called by the particle System when the position is computed for the created particle.
  17472. * @param worldMatrix is the world matrix of the particle system
  17473. * @param positionToUpdate is the position vector to update with the result
  17474. * @param particle is the particle we are computed the position for
  17475. */
  17476. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17477. /**
  17478. * Clones the current emitter and returns a copy of it
  17479. * @returns the new emitter
  17480. */
  17481. clone(): ConeParticleEmitter;
  17482. /**
  17483. * Called by the GPUParticleSystem to setup the update shader
  17484. * @param effect defines the update shader
  17485. */
  17486. applyToShader(effect: Effect): void;
  17487. /**
  17488. * Returns a string to use to update the GPU particles update shader
  17489. * @returns a string containng the defines string
  17490. */
  17491. getEffectDefines(): string;
  17492. /**
  17493. * Returns the string "ConeParticleEmitter"
  17494. * @returns a string containing the class name
  17495. */
  17496. getClassName(): string;
  17497. /**
  17498. * Serializes the particle system to a JSON object.
  17499. * @returns the JSON object
  17500. */
  17501. serialize(): any;
  17502. /**
  17503. * Parse properties from a JSON object
  17504. * @param serializationObject defines the JSON object
  17505. */
  17506. parse(serializationObject: any): void;
  17507. }
  17508. }
  17509. declare module BABYLON {
  17510. /**
  17511. * Particle emitter emitting particles from the inside of a cylinder.
  17512. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17513. */
  17514. export class CylinderParticleEmitter implements IParticleEmitterType {
  17515. /**
  17516. * The radius of the emission cylinder.
  17517. */
  17518. radius: number;
  17519. /**
  17520. * The height of the emission cylinder.
  17521. */
  17522. height: number;
  17523. /**
  17524. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17525. */
  17526. radiusRange: number;
  17527. /**
  17528. * How much to randomize the particle direction [0-1].
  17529. */
  17530. directionRandomizer: number;
  17531. /**
  17532. * Creates a new instance CylinderParticleEmitter
  17533. * @param radius the radius of the emission cylinder (1 by default)
  17534. * @param height the height of the emission cylinder (1 by default)
  17535. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17536. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17537. */
  17538. constructor(
  17539. /**
  17540. * The radius of the emission cylinder.
  17541. */
  17542. radius?: number,
  17543. /**
  17544. * The height of the emission cylinder.
  17545. */
  17546. height?: number,
  17547. /**
  17548. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17549. */
  17550. radiusRange?: number,
  17551. /**
  17552. * How much to randomize the particle direction [0-1].
  17553. */
  17554. directionRandomizer?: number);
  17555. /**
  17556. * Called by the particle System when the direction is computed for the created particle.
  17557. * @param worldMatrix is the world matrix of the particle system
  17558. * @param directionToUpdate is the direction vector to update with the result
  17559. * @param particle is the particle we are computed the direction for
  17560. */
  17561. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17562. /**
  17563. * Called by the particle System when the position is computed for the created particle.
  17564. * @param worldMatrix is the world matrix of the particle system
  17565. * @param positionToUpdate is the position vector to update with the result
  17566. * @param particle is the particle we are computed the position for
  17567. */
  17568. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17569. /**
  17570. * Clones the current emitter and returns a copy of it
  17571. * @returns the new emitter
  17572. */
  17573. clone(): CylinderParticleEmitter;
  17574. /**
  17575. * Called by the GPUParticleSystem to setup the update shader
  17576. * @param effect defines the update shader
  17577. */
  17578. applyToShader(effect: Effect): void;
  17579. /**
  17580. * Returns a string to use to update the GPU particles update shader
  17581. * @returns a string containng the defines string
  17582. */
  17583. getEffectDefines(): string;
  17584. /**
  17585. * Returns the string "CylinderParticleEmitter"
  17586. * @returns a string containing the class name
  17587. */
  17588. getClassName(): string;
  17589. /**
  17590. * Serializes the particle system to a JSON object.
  17591. * @returns the JSON object
  17592. */
  17593. serialize(): any;
  17594. /**
  17595. * Parse properties from a JSON object
  17596. * @param serializationObject defines the JSON object
  17597. */
  17598. parse(serializationObject: any): void;
  17599. }
  17600. /**
  17601. * Particle emitter emitting particles from the inside of a cylinder.
  17602. * It emits the particles randomly between two vectors.
  17603. */
  17604. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17605. /**
  17606. * The min limit of the emission direction.
  17607. */
  17608. direction1: Vector3;
  17609. /**
  17610. * The max limit of the emission direction.
  17611. */
  17612. direction2: Vector3;
  17613. /**
  17614. * Creates a new instance CylinderDirectedParticleEmitter
  17615. * @param radius the radius of the emission cylinder (1 by default)
  17616. * @param height the height of the emission cylinder (1 by default)
  17617. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17618. * @param direction1 the min limit of the emission direction (up vector by default)
  17619. * @param direction2 the max limit of the emission direction (up vector by default)
  17620. */
  17621. constructor(radius?: number, height?: number, radiusRange?: number,
  17622. /**
  17623. * The min limit of the emission direction.
  17624. */
  17625. direction1?: Vector3,
  17626. /**
  17627. * The max limit of the emission direction.
  17628. */
  17629. direction2?: Vector3);
  17630. /**
  17631. * Called by the particle System when the direction is computed for the created particle.
  17632. * @param worldMatrix is the world matrix of the particle system
  17633. * @param directionToUpdate is the direction vector to update with the result
  17634. * @param particle is the particle we are computed the direction for
  17635. */
  17636. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17637. /**
  17638. * Clones the current emitter and returns a copy of it
  17639. * @returns the new emitter
  17640. */
  17641. clone(): CylinderDirectedParticleEmitter;
  17642. /**
  17643. * Called by the GPUParticleSystem to setup the update shader
  17644. * @param effect defines the update shader
  17645. */
  17646. applyToShader(effect: Effect): void;
  17647. /**
  17648. * Returns a string to use to update the GPU particles update shader
  17649. * @returns a string containng the defines string
  17650. */
  17651. getEffectDefines(): string;
  17652. /**
  17653. * Returns the string "CylinderDirectedParticleEmitter"
  17654. * @returns a string containing the class name
  17655. */
  17656. getClassName(): string;
  17657. /**
  17658. * Serializes the particle system to a JSON object.
  17659. * @returns the JSON object
  17660. */
  17661. serialize(): any;
  17662. /**
  17663. * Parse properties from a JSON object
  17664. * @param serializationObject defines the JSON object
  17665. */
  17666. parse(serializationObject: any): void;
  17667. }
  17668. }
  17669. declare module BABYLON {
  17670. /**
  17671. * Particle emitter emitting particles from the inside of a hemisphere.
  17672. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17673. */
  17674. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17675. /**
  17676. * The radius of the emission hemisphere.
  17677. */
  17678. radius: number;
  17679. /**
  17680. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17681. */
  17682. radiusRange: number;
  17683. /**
  17684. * How much to randomize the particle direction [0-1].
  17685. */
  17686. directionRandomizer: number;
  17687. /**
  17688. * Creates a new instance HemisphericParticleEmitter
  17689. * @param radius the radius of the emission hemisphere (1 by default)
  17690. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17691. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17692. */
  17693. constructor(
  17694. /**
  17695. * The radius of the emission hemisphere.
  17696. */
  17697. radius?: number,
  17698. /**
  17699. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17700. */
  17701. radiusRange?: number,
  17702. /**
  17703. * How much to randomize the particle direction [0-1].
  17704. */
  17705. directionRandomizer?: number);
  17706. /**
  17707. * Called by the particle System when the direction is computed for the created particle.
  17708. * @param worldMatrix is the world matrix of the particle system
  17709. * @param directionToUpdate is the direction vector to update with the result
  17710. * @param particle is the particle we are computed the direction for
  17711. */
  17712. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17713. /**
  17714. * Called by the particle System when the position is computed for the created particle.
  17715. * @param worldMatrix is the world matrix of the particle system
  17716. * @param positionToUpdate is the position vector to update with the result
  17717. * @param particle is the particle we are computed the position for
  17718. */
  17719. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17720. /**
  17721. * Clones the current emitter and returns a copy of it
  17722. * @returns the new emitter
  17723. */
  17724. clone(): HemisphericParticleEmitter;
  17725. /**
  17726. * Called by the GPUParticleSystem to setup the update shader
  17727. * @param effect defines the update shader
  17728. */
  17729. applyToShader(effect: Effect): void;
  17730. /**
  17731. * Returns a string to use to update the GPU particles update shader
  17732. * @returns a string containng the defines string
  17733. */
  17734. getEffectDefines(): string;
  17735. /**
  17736. * Returns the string "HemisphericParticleEmitter"
  17737. * @returns a string containing the class name
  17738. */
  17739. getClassName(): string;
  17740. /**
  17741. * Serializes the particle system to a JSON object.
  17742. * @returns the JSON object
  17743. */
  17744. serialize(): any;
  17745. /**
  17746. * Parse properties from a JSON object
  17747. * @param serializationObject defines the JSON object
  17748. */
  17749. parse(serializationObject: any): void;
  17750. }
  17751. }
  17752. declare module BABYLON {
  17753. /**
  17754. * Particle emitter emitting particles from a point.
  17755. * It emits the particles randomly between 2 given directions.
  17756. */
  17757. export class PointParticleEmitter implements IParticleEmitterType {
  17758. /**
  17759. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17760. */
  17761. direction1: Vector3;
  17762. /**
  17763. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17764. */
  17765. direction2: Vector3;
  17766. /**
  17767. * Creates a new instance PointParticleEmitter
  17768. */
  17769. constructor();
  17770. /**
  17771. * Called by the particle System when the direction is computed for the created particle.
  17772. * @param worldMatrix is the world matrix of the particle system
  17773. * @param directionToUpdate is the direction vector to update with the result
  17774. * @param particle is the particle we are computed the direction for
  17775. */
  17776. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17777. /**
  17778. * Called by the particle System when the position is computed for the created particle.
  17779. * @param worldMatrix is the world matrix of the particle system
  17780. * @param positionToUpdate is the position vector to update with the result
  17781. * @param particle is the particle we are computed the position for
  17782. */
  17783. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17784. /**
  17785. * Clones the current emitter and returns a copy of it
  17786. * @returns the new emitter
  17787. */
  17788. clone(): PointParticleEmitter;
  17789. /**
  17790. * Called by the GPUParticleSystem to setup the update shader
  17791. * @param effect defines the update shader
  17792. */
  17793. applyToShader(effect: Effect): void;
  17794. /**
  17795. * Returns a string to use to update the GPU particles update shader
  17796. * @returns a string containng the defines string
  17797. */
  17798. getEffectDefines(): string;
  17799. /**
  17800. * Returns the string "PointParticleEmitter"
  17801. * @returns a string containing the class name
  17802. */
  17803. getClassName(): string;
  17804. /**
  17805. * Serializes the particle system to a JSON object.
  17806. * @returns the JSON object
  17807. */
  17808. serialize(): any;
  17809. /**
  17810. * Parse properties from a JSON object
  17811. * @param serializationObject defines the JSON object
  17812. */
  17813. parse(serializationObject: any): void;
  17814. }
  17815. }
  17816. declare module BABYLON {
  17817. /**
  17818. * Particle emitter emitting particles from the inside of a sphere.
  17819. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17820. */
  17821. export class SphereParticleEmitter implements IParticleEmitterType {
  17822. /**
  17823. * The radius of the emission sphere.
  17824. */
  17825. radius: number;
  17826. /**
  17827. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17828. */
  17829. radiusRange: number;
  17830. /**
  17831. * How much to randomize the particle direction [0-1].
  17832. */
  17833. directionRandomizer: number;
  17834. /**
  17835. * Creates a new instance SphereParticleEmitter
  17836. * @param radius the radius of the emission sphere (1 by default)
  17837. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17838. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17839. */
  17840. constructor(
  17841. /**
  17842. * The radius of the emission sphere.
  17843. */
  17844. radius?: number,
  17845. /**
  17846. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17847. */
  17848. radiusRange?: number,
  17849. /**
  17850. * How much to randomize the particle direction [0-1].
  17851. */
  17852. directionRandomizer?: number);
  17853. /**
  17854. * Called by the particle System when the direction is computed for the created particle.
  17855. * @param worldMatrix is the world matrix of the particle system
  17856. * @param directionToUpdate is the direction vector to update with the result
  17857. * @param particle is the particle we are computed the direction for
  17858. */
  17859. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17860. /**
  17861. * Called by the particle System when the position is computed for the created particle.
  17862. * @param worldMatrix is the world matrix of the particle system
  17863. * @param positionToUpdate is the position vector to update with the result
  17864. * @param particle is the particle we are computed the position for
  17865. */
  17866. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17867. /**
  17868. * Clones the current emitter and returns a copy of it
  17869. * @returns the new emitter
  17870. */
  17871. clone(): SphereParticleEmitter;
  17872. /**
  17873. * Called by the GPUParticleSystem to setup the update shader
  17874. * @param effect defines the update shader
  17875. */
  17876. applyToShader(effect: Effect): void;
  17877. /**
  17878. * Returns a string to use to update the GPU particles update shader
  17879. * @returns a string containng the defines string
  17880. */
  17881. getEffectDefines(): string;
  17882. /**
  17883. * Returns the string "SphereParticleEmitter"
  17884. * @returns a string containing the class name
  17885. */
  17886. getClassName(): string;
  17887. /**
  17888. * Serializes the particle system to a JSON object.
  17889. * @returns the JSON object
  17890. */
  17891. serialize(): any;
  17892. /**
  17893. * Parse properties from a JSON object
  17894. * @param serializationObject defines the JSON object
  17895. */
  17896. parse(serializationObject: any): void;
  17897. }
  17898. /**
  17899. * Particle emitter emitting particles from the inside of a sphere.
  17900. * It emits the particles randomly between two vectors.
  17901. */
  17902. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17903. /**
  17904. * The min limit of the emission direction.
  17905. */
  17906. direction1: Vector3;
  17907. /**
  17908. * The max limit of the emission direction.
  17909. */
  17910. direction2: Vector3;
  17911. /**
  17912. * Creates a new instance SphereDirectedParticleEmitter
  17913. * @param radius the radius of the emission sphere (1 by default)
  17914. * @param direction1 the min limit of the emission direction (up vector by default)
  17915. * @param direction2 the max limit of the emission direction (up vector by default)
  17916. */
  17917. constructor(radius?: number,
  17918. /**
  17919. * The min limit of the emission direction.
  17920. */
  17921. direction1?: Vector3,
  17922. /**
  17923. * The max limit of the emission direction.
  17924. */
  17925. direction2?: Vector3);
  17926. /**
  17927. * Called by the particle System when the direction is computed for the created particle.
  17928. * @param worldMatrix is the world matrix of the particle system
  17929. * @param directionToUpdate is the direction vector to update with the result
  17930. * @param particle is the particle we are computed the direction for
  17931. */
  17932. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17933. /**
  17934. * Clones the current emitter and returns a copy of it
  17935. * @returns the new emitter
  17936. */
  17937. clone(): SphereDirectedParticleEmitter;
  17938. /**
  17939. * Called by the GPUParticleSystem to setup the update shader
  17940. * @param effect defines the update shader
  17941. */
  17942. applyToShader(effect: Effect): void;
  17943. /**
  17944. * Returns a string to use to update the GPU particles update shader
  17945. * @returns a string containng the defines string
  17946. */
  17947. getEffectDefines(): string;
  17948. /**
  17949. * Returns the string "SphereDirectedParticleEmitter"
  17950. * @returns a string containing the class name
  17951. */
  17952. getClassName(): string;
  17953. /**
  17954. * Serializes the particle system to a JSON object.
  17955. * @returns the JSON object
  17956. */
  17957. serialize(): any;
  17958. /**
  17959. * Parse properties from a JSON object
  17960. * @param serializationObject defines the JSON object
  17961. */
  17962. parse(serializationObject: any): void;
  17963. }
  17964. }
  17965. declare module BABYLON {
  17966. /**
  17967. * Interface representing a particle system in Babylon.js.
  17968. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17969. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17970. */
  17971. export interface IParticleSystem {
  17972. /**
  17973. * List of animations used by the particle system.
  17974. */
  17975. animations: Animation[];
  17976. /**
  17977. * The id of the Particle system.
  17978. */
  17979. id: string;
  17980. /**
  17981. * The name of the Particle system.
  17982. */
  17983. name: string;
  17984. /**
  17985. * The emitter represents the Mesh or position we are attaching the particle system to.
  17986. */
  17987. emitter: Nullable<AbstractMesh | Vector3>;
  17988. /**
  17989. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17990. */
  17991. isBillboardBased: boolean;
  17992. /**
  17993. * The rendering group used by the Particle system to chose when to render.
  17994. */
  17995. renderingGroupId: number;
  17996. /**
  17997. * The layer mask we are rendering the particles through.
  17998. */
  17999. layerMask: number;
  18000. /**
  18001. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18002. */
  18003. updateSpeed: number;
  18004. /**
  18005. * The amount of time the particle system is running (depends of the overall update speed).
  18006. */
  18007. targetStopDuration: number;
  18008. /**
  18009. * The texture used to render each particle. (this can be a spritesheet)
  18010. */
  18011. particleTexture: Nullable<Texture>;
  18012. /**
  18013. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18014. */
  18015. blendMode: number;
  18016. /**
  18017. * Minimum life time of emitting particles.
  18018. */
  18019. minLifeTime: number;
  18020. /**
  18021. * Maximum life time of emitting particles.
  18022. */
  18023. maxLifeTime: number;
  18024. /**
  18025. * Minimum Size of emitting particles.
  18026. */
  18027. minSize: number;
  18028. /**
  18029. * Maximum Size of emitting particles.
  18030. */
  18031. maxSize: number;
  18032. /**
  18033. * Minimum scale of emitting particles on X axis.
  18034. */
  18035. minScaleX: number;
  18036. /**
  18037. * Maximum scale of emitting particles on X axis.
  18038. */
  18039. maxScaleX: number;
  18040. /**
  18041. * Minimum scale of emitting particles on Y axis.
  18042. */
  18043. minScaleY: number;
  18044. /**
  18045. * Maximum scale of emitting particles on Y axis.
  18046. */
  18047. maxScaleY: number;
  18048. /**
  18049. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18050. */
  18051. color1: Color4;
  18052. /**
  18053. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18054. */
  18055. color2: Color4;
  18056. /**
  18057. * Color the particle will have at the end of its lifetime.
  18058. */
  18059. colorDead: Color4;
  18060. /**
  18061. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18062. */
  18063. emitRate: number;
  18064. /**
  18065. * You can use gravity if you want to give an orientation to your particles.
  18066. */
  18067. gravity: Vector3;
  18068. /**
  18069. * Minimum power of emitting particles.
  18070. */
  18071. minEmitPower: number;
  18072. /**
  18073. * Maximum power of emitting particles.
  18074. */
  18075. maxEmitPower: number;
  18076. /**
  18077. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18078. */
  18079. minAngularSpeed: number;
  18080. /**
  18081. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18082. */
  18083. maxAngularSpeed: number;
  18084. /**
  18085. * Gets or sets the minimal initial rotation in radians.
  18086. */
  18087. minInitialRotation: number;
  18088. /**
  18089. * Gets or sets the maximal initial rotation in radians.
  18090. */
  18091. maxInitialRotation: number;
  18092. /**
  18093. * The particle emitter type defines the emitter used by the particle system.
  18094. * It can be for example box, sphere, or cone...
  18095. */
  18096. particleEmitterType: Nullable<IParticleEmitterType>;
  18097. /**
  18098. * Defines the delay in milliseconds before starting the system (0 by default)
  18099. */
  18100. startDelay: number;
  18101. /**
  18102. * 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
  18103. */
  18104. preWarmCycles: number;
  18105. /**
  18106. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18107. */
  18108. preWarmStepOffset: number;
  18109. /**
  18110. * 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)
  18111. */
  18112. spriteCellChangeSpeed: number;
  18113. /**
  18114. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18115. */
  18116. startSpriteCellID: number;
  18117. /**
  18118. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18119. */
  18120. endSpriteCellID: number;
  18121. /**
  18122. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18123. */
  18124. spriteCellWidth: number;
  18125. /**
  18126. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18127. */
  18128. spriteCellHeight: number;
  18129. /**
  18130. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18131. */
  18132. spriteRandomStartCell: boolean;
  18133. /**
  18134. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18135. */
  18136. isAnimationSheetEnabled: boolean;
  18137. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18138. translationPivot: Vector2;
  18139. /**
  18140. * Gets or sets a texture used to add random noise to particle positions
  18141. */
  18142. noiseTexture: Nullable<BaseTexture>;
  18143. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18144. noiseStrength: Vector3;
  18145. /**
  18146. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18147. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18148. */
  18149. billboardMode: number;
  18150. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18151. limitVelocityDamping: number;
  18152. /**
  18153. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18154. */
  18155. beginAnimationOnStart: boolean;
  18156. /**
  18157. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18158. */
  18159. beginAnimationFrom: number;
  18160. /**
  18161. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18162. */
  18163. beginAnimationTo: number;
  18164. /**
  18165. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18166. */
  18167. beginAnimationLoop: boolean;
  18168. /**
  18169. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18170. */
  18171. disposeOnStop: boolean;
  18172. /**
  18173. * Gets the maximum number of particles active at the same time.
  18174. * @returns The max number of active particles.
  18175. */
  18176. getCapacity(): number;
  18177. /**
  18178. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18179. * @returns True if it has been started, otherwise false.
  18180. */
  18181. isStarted(): boolean;
  18182. /**
  18183. * Animates the particle system for this frame.
  18184. */
  18185. animate(): void;
  18186. /**
  18187. * Renders the particle system in its current state.
  18188. * @returns the current number of particles
  18189. */
  18190. render(): number;
  18191. /**
  18192. * Dispose the particle system and frees its associated resources.
  18193. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18194. */
  18195. dispose(disposeTexture?: boolean): void;
  18196. /**
  18197. * Clones the particle system.
  18198. * @param name The name of the cloned object
  18199. * @param newEmitter The new emitter to use
  18200. * @returns the cloned particle system
  18201. */
  18202. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18203. /**
  18204. * Serializes the particle system to a JSON object.
  18205. * @returns the JSON object
  18206. */
  18207. serialize(): any;
  18208. /**
  18209. * Rebuild the particle system
  18210. */
  18211. rebuild(): void;
  18212. /**
  18213. * Starts the particle system and begins to emit
  18214. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18215. */
  18216. start(delay?: number): void;
  18217. /**
  18218. * Stops the particle system.
  18219. */
  18220. stop(): void;
  18221. /**
  18222. * Remove all active particles
  18223. */
  18224. reset(): void;
  18225. /**
  18226. * Is this system ready to be used/rendered
  18227. * @return true if the system is ready
  18228. */
  18229. isReady(): boolean;
  18230. /**
  18231. * Adds a new color gradient
  18232. * @param gradient defines the gradient to use (between 0 and 1)
  18233. * @param color1 defines the color to affect to the specified gradient
  18234. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18235. * @returns the current particle system
  18236. */
  18237. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18238. /**
  18239. * Remove a specific color gradient
  18240. * @param gradient defines the gradient to remove
  18241. * @returns the current particle system
  18242. */
  18243. removeColorGradient(gradient: number): IParticleSystem;
  18244. /**
  18245. * Adds a new size gradient
  18246. * @param gradient defines the gradient to use (between 0 and 1)
  18247. * @param factor defines the size factor to affect to the specified gradient
  18248. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18249. * @returns the current particle system
  18250. */
  18251. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18252. /**
  18253. * Remove a specific size gradient
  18254. * @param gradient defines the gradient to remove
  18255. * @returns the current particle system
  18256. */
  18257. removeSizeGradient(gradient: number): IParticleSystem;
  18258. /**
  18259. * Gets the current list of color gradients.
  18260. * You must use addColorGradient and removeColorGradient to udpate this list
  18261. * @returns the list of color gradients
  18262. */
  18263. getColorGradients(): Nullable<Array<ColorGradient>>;
  18264. /**
  18265. * Gets the current list of size gradients.
  18266. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18267. * @returns the list of size gradients
  18268. */
  18269. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18270. /**
  18271. * Gets the current list of angular speed gradients.
  18272. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18273. * @returns the list of angular speed gradients
  18274. */
  18275. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18276. /**
  18277. * Adds a new angular speed gradient
  18278. * @param gradient defines the gradient to use (between 0 and 1)
  18279. * @param factor defines the angular speed to affect to the specified gradient
  18280. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18281. * @returns the current particle system
  18282. */
  18283. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18284. /**
  18285. * Remove a specific angular speed gradient
  18286. * @param gradient defines the gradient to remove
  18287. * @returns the current particle system
  18288. */
  18289. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18290. /**
  18291. * Gets the current list of velocity gradients.
  18292. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18293. * @returns the list of velocity gradients
  18294. */
  18295. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18296. /**
  18297. * Adds a new velocity gradient
  18298. * @param gradient defines the gradient to use (between 0 and 1)
  18299. * @param factor defines the velocity to affect to the specified gradient
  18300. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18301. * @returns the current particle system
  18302. */
  18303. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18304. /**
  18305. * Remove a specific velocity gradient
  18306. * @param gradient defines the gradient to remove
  18307. * @returns the current particle system
  18308. */
  18309. removeVelocityGradient(gradient: number): IParticleSystem;
  18310. /**
  18311. * Gets the current list of limit velocity gradients.
  18312. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18313. * @returns the list of limit velocity gradients
  18314. */
  18315. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18316. /**
  18317. * Adds a new limit velocity gradient
  18318. * @param gradient defines the gradient to use (between 0 and 1)
  18319. * @param factor defines the limit velocity to affect to the specified gradient
  18320. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18321. * @returns the current particle system
  18322. */
  18323. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18324. /**
  18325. * Remove a specific limit velocity gradient
  18326. * @param gradient defines the gradient to remove
  18327. * @returns the current particle system
  18328. */
  18329. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18330. /**
  18331. * Adds a new drag gradient
  18332. * @param gradient defines the gradient to use (between 0 and 1)
  18333. * @param factor defines the drag to affect to the specified gradient
  18334. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18335. * @returns the current particle system
  18336. */
  18337. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18338. /**
  18339. * Remove a specific drag gradient
  18340. * @param gradient defines the gradient to remove
  18341. * @returns the current particle system
  18342. */
  18343. removeDragGradient(gradient: number): IParticleSystem;
  18344. /**
  18345. * Gets the current list of drag gradients.
  18346. * You must use addDragGradient and removeDragGradient to udpate this list
  18347. * @returns the list of drag gradients
  18348. */
  18349. getDragGradients(): Nullable<Array<FactorGradient>>;
  18350. /**
  18351. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18352. * @param gradient defines the gradient to use (between 0 and 1)
  18353. * @param factor defines the emit rate to affect to the specified gradient
  18354. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18355. * @returns the current particle system
  18356. */
  18357. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18358. /**
  18359. * Remove a specific emit rate gradient
  18360. * @param gradient defines the gradient to remove
  18361. * @returns the current particle system
  18362. */
  18363. removeEmitRateGradient(gradient: number): IParticleSystem;
  18364. /**
  18365. * Gets the current list of emit rate gradients.
  18366. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18367. * @returns the list of emit rate gradients
  18368. */
  18369. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18370. /**
  18371. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18372. * @param gradient defines the gradient to use (between 0 and 1)
  18373. * @param factor defines the start size to affect to the specified gradient
  18374. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18375. * @returns the current particle system
  18376. */
  18377. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18378. /**
  18379. * Remove a specific start size gradient
  18380. * @param gradient defines the gradient to remove
  18381. * @returns the current particle system
  18382. */
  18383. removeStartSizeGradient(gradient: number): IParticleSystem;
  18384. /**
  18385. * Gets the current list of start size gradients.
  18386. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18387. * @returns the list of start size gradients
  18388. */
  18389. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18390. /**
  18391. * Adds a new life time gradient
  18392. * @param gradient defines the gradient to use (between 0 and 1)
  18393. * @param factor defines the life time factor to affect to the specified gradient
  18394. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18395. * @returns the current particle system
  18396. */
  18397. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18398. /**
  18399. * Remove a specific life time gradient
  18400. * @param gradient defines the gradient to remove
  18401. * @returns the current particle system
  18402. */
  18403. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18404. /**
  18405. * Gets the current list of life time gradients.
  18406. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18407. * @returns the list of life time gradients
  18408. */
  18409. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18410. /**
  18411. * Gets the current list of color gradients.
  18412. * You must use addColorGradient and removeColorGradient to udpate this list
  18413. * @returns the list of color gradients
  18414. */
  18415. getColorGradients(): Nullable<Array<ColorGradient>>;
  18416. /**
  18417. * Adds a new ramp gradient used to remap particle colors
  18418. * @param gradient defines the gradient to use (between 0 and 1)
  18419. * @param color defines the color to affect to the specified gradient
  18420. * @returns the current particle system
  18421. */
  18422. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18423. /**
  18424. * Gets the current list of ramp gradients.
  18425. * You must use addRampGradient and removeRampGradient to udpate this list
  18426. * @returns the list of ramp gradients
  18427. */
  18428. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18429. /** Gets or sets a boolean indicating that ramp gradients must be used
  18430. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18431. */
  18432. useRampGradients: boolean;
  18433. /**
  18434. * Adds a new color remap gradient
  18435. * @param gradient defines the gradient to use (between 0 and 1)
  18436. * @param min defines the color remap minimal range
  18437. * @param max defines the color remap maximal range
  18438. * @returns the current particle system
  18439. */
  18440. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18441. /**
  18442. * Gets the current list of color remap gradients.
  18443. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18444. * @returns the list of color remap gradients
  18445. */
  18446. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18447. /**
  18448. * Adds a new alpha remap gradient
  18449. * @param gradient defines the gradient to use (between 0 and 1)
  18450. * @param min defines the alpha remap minimal range
  18451. * @param max defines the alpha remap maximal range
  18452. * @returns the current particle system
  18453. */
  18454. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18455. /**
  18456. * Gets the current list of alpha remap gradients.
  18457. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18458. * @returns the list of alpha remap gradients
  18459. */
  18460. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18461. /**
  18462. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18463. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18464. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18465. * @returns the emitter
  18466. */
  18467. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18468. /**
  18469. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18470. * @param radius The radius of the hemisphere to emit from
  18471. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18472. * @returns the emitter
  18473. */
  18474. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18475. /**
  18476. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18477. * @param radius The radius of the sphere to emit from
  18478. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18479. * @returns the emitter
  18480. */
  18481. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18482. /**
  18483. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18484. * @param radius The radius of the sphere to emit from
  18485. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18486. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18487. * @returns the emitter
  18488. */
  18489. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18490. /**
  18491. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18492. * @param radius The radius of the emission cylinder
  18493. * @param height The height of the emission cylinder
  18494. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18495. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18496. * @returns the emitter
  18497. */
  18498. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18499. /**
  18500. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18501. * @param radius The radius of the cylinder to emit from
  18502. * @param height The height of the emission cylinder
  18503. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18504. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18505. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18506. * @returns the emitter
  18507. */
  18508. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18509. /**
  18510. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18511. * @param radius The radius of the cone to emit from
  18512. * @param angle The base angle of the cone
  18513. * @returns the emitter
  18514. */
  18515. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18516. /**
  18517. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18518. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18519. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18520. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18521. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18522. * @returns the emitter
  18523. */
  18524. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18525. /**
  18526. * Get hosting scene
  18527. * @returns the scene
  18528. */
  18529. getScene(): Scene;
  18530. }
  18531. }
  18532. declare module BABYLON {
  18533. /**
  18534. * Creates an instance based on a source mesh.
  18535. */
  18536. export class InstancedMesh extends AbstractMesh {
  18537. private _sourceMesh;
  18538. private _currentLOD;
  18539. /** @hidden */
  18540. _indexInSourceMeshInstanceArray: number;
  18541. constructor(name: string, source: Mesh);
  18542. /**
  18543. * Returns the string "InstancedMesh".
  18544. */
  18545. getClassName(): string;
  18546. /** Gets the list of lights affecting that mesh */
  18547. readonly lightSources: Light[];
  18548. _resyncLightSources(): void;
  18549. _resyncLighSource(light: Light): void;
  18550. _removeLightSource(light: Light): void;
  18551. /**
  18552. * If the source mesh receives shadows
  18553. */
  18554. readonly receiveShadows: boolean;
  18555. /**
  18556. * The material of the source mesh
  18557. */
  18558. readonly material: Nullable<Material>;
  18559. /**
  18560. * Visibility of the source mesh
  18561. */
  18562. readonly visibility: number;
  18563. /**
  18564. * Skeleton of the source mesh
  18565. */
  18566. readonly skeleton: Nullable<Skeleton>;
  18567. /**
  18568. * Rendering ground id of the source mesh
  18569. */
  18570. renderingGroupId: number;
  18571. /**
  18572. * Returns the total number of vertices (integer).
  18573. */
  18574. getTotalVertices(): number;
  18575. /**
  18576. * Returns a positive integer : the total number of indices in this mesh geometry.
  18577. * @returns the numner of indices or zero if the mesh has no geometry.
  18578. */
  18579. getTotalIndices(): number;
  18580. /**
  18581. * The source mesh of the instance
  18582. */
  18583. readonly sourceMesh: Mesh;
  18584. /**
  18585. * Is this node ready to be used/rendered
  18586. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18587. * @return {boolean} is it ready
  18588. */
  18589. isReady(completeCheck?: boolean): boolean;
  18590. /**
  18591. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18592. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18593. * @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.
  18594. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18595. */
  18596. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18597. /**
  18598. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18599. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18600. * The `data` are either a numeric array either a Float32Array.
  18601. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18602. * 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).
  18603. * Note that a new underlying VertexBuffer object is created each call.
  18604. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18605. *
  18606. * Possible `kind` values :
  18607. * - VertexBuffer.PositionKind
  18608. * - VertexBuffer.UVKind
  18609. * - VertexBuffer.UV2Kind
  18610. * - VertexBuffer.UV3Kind
  18611. * - VertexBuffer.UV4Kind
  18612. * - VertexBuffer.UV5Kind
  18613. * - VertexBuffer.UV6Kind
  18614. * - VertexBuffer.ColorKind
  18615. * - VertexBuffer.MatricesIndicesKind
  18616. * - VertexBuffer.MatricesIndicesExtraKind
  18617. * - VertexBuffer.MatricesWeightsKind
  18618. * - VertexBuffer.MatricesWeightsExtraKind
  18619. *
  18620. * Returns the Mesh.
  18621. */
  18622. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  18623. /**
  18624. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18625. * If the mesh has no geometry, it is simply returned as it is.
  18626. * The `data` are either a numeric array either a Float32Array.
  18627. * No new underlying VertexBuffer object is created.
  18628. * 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.
  18629. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18630. *
  18631. * Possible `kind` values :
  18632. * - VertexBuffer.PositionKind
  18633. * - VertexBuffer.UVKind
  18634. * - VertexBuffer.UV2Kind
  18635. * - VertexBuffer.UV3Kind
  18636. * - VertexBuffer.UV4Kind
  18637. * - VertexBuffer.UV5Kind
  18638. * - VertexBuffer.UV6Kind
  18639. * - VertexBuffer.ColorKind
  18640. * - VertexBuffer.MatricesIndicesKind
  18641. * - VertexBuffer.MatricesIndicesExtraKind
  18642. * - VertexBuffer.MatricesWeightsKind
  18643. * - VertexBuffer.MatricesWeightsExtraKind
  18644. *
  18645. * Returns the Mesh.
  18646. */
  18647. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18648. /**
  18649. * Sets the mesh indices.
  18650. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18651. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18652. * This method creates a new index buffer each call.
  18653. * Returns the Mesh.
  18654. */
  18655. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18656. /**
  18657. * Boolean : True if the mesh owns the requested kind of data.
  18658. */
  18659. isVerticesDataPresent(kind: string): boolean;
  18660. /**
  18661. * Returns an array of indices (IndicesArray).
  18662. */
  18663. getIndices(): Nullable<IndicesArray>;
  18664. readonly _positions: Nullable<Vector3[]>;
  18665. /**
  18666. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18667. * This means the mesh underlying bounding box and sphere are recomputed.
  18668. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18669. * @returns the current mesh
  18670. */
  18671. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18672. /** @hidden */
  18673. _preActivate(): InstancedMesh;
  18674. /** @hidden */
  18675. _activate(renderId: number, intermediateRendering: boolean): boolean;
  18676. /** @hidden */
  18677. _postActivate(): void;
  18678. getWorldMatrix(): Matrix;
  18679. readonly isAnInstance: boolean;
  18680. /**
  18681. * Returns the current associated LOD AbstractMesh.
  18682. */
  18683. getLOD(camera: Camera): AbstractMesh;
  18684. /** @hidden */
  18685. _syncSubMeshes(): InstancedMesh;
  18686. /** @hidden */
  18687. _generatePointsArray(): boolean;
  18688. /**
  18689. * Creates a new InstancedMesh from the current mesh.
  18690. * - name (string) : the cloned mesh name
  18691. * - newParent (optional Node) : the optional Node to parent the clone to.
  18692. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18693. *
  18694. * Returns the clone.
  18695. */
  18696. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): InstancedMesh;
  18697. /**
  18698. * Disposes the InstancedMesh.
  18699. * Returns nothing.
  18700. */
  18701. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18702. }
  18703. }
  18704. declare module BABYLON {
  18705. /**
  18706. * Defines the options associated with the creation of a shader material.
  18707. */
  18708. export interface IShaderMaterialOptions {
  18709. /**
  18710. * Does the material work in alpha blend mode
  18711. */
  18712. needAlphaBlending: boolean;
  18713. /**
  18714. * Does the material work in alpha test mode
  18715. */
  18716. needAlphaTesting: boolean;
  18717. /**
  18718. * The list of attribute names used in the shader
  18719. */
  18720. attributes: string[];
  18721. /**
  18722. * The list of unifrom names used in the shader
  18723. */
  18724. uniforms: string[];
  18725. /**
  18726. * The list of UBO names used in the shader
  18727. */
  18728. uniformBuffers: string[];
  18729. /**
  18730. * The list of sampler names used in the shader
  18731. */
  18732. samplers: string[];
  18733. /**
  18734. * The list of defines used in the shader
  18735. */
  18736. defines: string[];
  18737. }
  18738. /**
  18739. * 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.
  18740. *
  18741. * This returned material effects how the mesh will look based on the code in the shaders.
  18742. *
  18743. * @see http://doc.babylonjs.com/how_to/shader_material
  18744. */
  18745. export class ShaderMaterial extends Material {
  18746. private _shaderPath;
  18747. private _options;
  18748. private _textures;
  18749. private _textureArrays;
  18750. private _floats;
  18751. private _ints;
  18752. private _floatsArrays;
  18753. private _colors3;
  18754. private _colors3Arrays;
  18755. private _colors4;
  18756. private _colors4Arrays;
  18757. private _vectors2;
  18758. private _vectors3;
  18759. private _vectors4;
  18760. private _matrices;
  18761. private _matrices3x3;
  18762. private _matrices2x2;
  18763. private _vectors2Arrays;
  18764. private _vectors3Arrays;
  18765. private _vectors4Arrays;
  18766. private _cachedWorldViewMatrix;
  18767. private _cachedWorldViewProjectionMatrix;
  18768. private _renderId;
  18769. /**
  18770. * Instantiate a new shader material.
  18771. * 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.
  18772. * This returned material effects how the mesh will look based on the code in the shaders.
  18773. * @see http://doc.babylonjs.com/how_to/shader_material
  18774. * @param name Define the name of the material in the scene
  18775. * @param scene Define the scene the material belongs to
  18776. * @param shaderPath Defines the route to the shader code in one of three ways:
  18777. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18778. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  18779. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18780. * @param options Define the options used to create the shader
  18781. */
  18782. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18783. /**
  18784. * Gets the options used to compile the shader.
  18785. * They can be modified to trigger a new compilation
  18786. */
  18787. readonly options: IShaderMaterialOptions;
  18788. /**
  18789. * Gets the current class name of the material e.g. "ShaderMaterial"
  18790. * Mainly use in serialization.
  18791. * @returns the class name
  18792. */
  18793. getClassName(): string;
  18794. /**
  18795. * Specifies if the material will require alpha blending
  18796. * @returns a boolean specifying if alpha blending is needed
  18797. */
  18798. needAlphaBlending(): boolean;
  18799. /**
  18800. * Specifies if this material should be rendered in alpha test mode
  18801. * @returns a boolean specifying if an alpha test is needed.
  18802. */
  18803. needAlphaTesting(): boolean;
  18804. private _checkUniform;
  18805. /**
  18806. * Set a texture in the shader.
  18807. * @param name Define the name of the uniform samplers as defined in the shader
  18808. * @param texture Define the texture to bind to this sampler
  18809. * @return the material itself allowing "fluent" like uniform updates
  18810. */
  18811. setTexture(name: string, texture: Texture): ShaderMaterial;
  18812. /**
  18813. * Set a texture array in the shader.
  18814. * @param name Define the name of the uniform sampler array as defined in the shader
  18815. * @param textures Define the list of textures to bind to this sampler
  18816. * @return the material itself allowing "fluent" like uniform updates
  18817. */
  18818. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18819. /**
  18820. * Set a float in the shader.
  18821. * @param name Define the name of the uniform as defined in the shader
  18822. * @param value Define the value to give to the uniform
  18823. * @return the material itself allowing "fluent" like uniform updates
  18824. */
  18825. setFloat(name: string, value: number): ShaderMaterial;
  18826. /**
  18827. * Set a int 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. setInt(name: string, value: number): ShaderMaterial;
  18833. /**
  18834. * Set an array of floats 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. setFloats(name: string, value: number[]): ShaderMaterial;
  18840. /**
  18841. * Set a vec3 in the shader from a Color3.
  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. setColor3(name: string, value: Color3): ShaderMaterial;
  18847. /**
  18848. * Set a vec3 array in the shader from a Color3 array.
  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. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18854. /**
  18855. * Set a vec4 in the shader from a Color4.
  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. setColor4(name: string, value: Color4): ShaderMaterial;
  18861. /**
  18862. * Set a vec4 array in the shader from a Color4 array.
  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. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  18868. /**
  18869. * Set a vec2 in the shader from a Vector2.
  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. setVector2(name: string, value: Vector2): ShaderMaterial;
  18875. /**
  18876. * Set a vec3 in the shader from a Vector3.
  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. setVector3(name: string, value: Vector3): ShaderMaterial;
  18882. /**
  18883. * Set a vec4 in the shader from a Vector4.
  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. setVector4(name: string, value: Vector4): ShaderMaterial;
  18889. /**
  18890. * Set a mat4 in the shader from a Matrix.
  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. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18896. /**
  18897. * Set a mat3 in the shader from a Float32Array.
  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. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18903. /**
  18904. * Set a mat2 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. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18910. /**
  18911. * Set a vec2 array in the shader from a number array.
  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. setArray2(name: string, value: number[]): ShaderMaterial;
  18917. /**
  18918. * Set a vec3 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. setArray3(name: string, value: number[]): ShaderMaterial;
  18924. /**
  18925. * Set a vec4 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. setArray4(name: string, value: number[]): ShaderMaterial;
  18931. private _checkCache;
  18932. /**
  18933. * Specifies that the submesh is ready to be used
  18934. * @param mesh defines the mesh to check
  18935. * @param subMesh defines which submesh to check
  18936. * @param useInstances specifies that instances should be used
  18937. * @returns a boolean indicating that the submesh is ready or not
  18938. */
  18939. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18940. /**
  18941. * Checks if the material is ready to render the requested mesh
  18942. * @param mesh Define the mesh to render
  18943. * @param useInstances Define whether or not the material is used with instances
  18944. * @returns true if ready, otherwise false
  18945. */
  18946. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18947. /**
  18948. * Binds the world matrix to the material
  18949. * @param world defines the world transformation matrix
  18950. */
  18951. bindOnlyWorldMatrix(world: Matrix): void;
  18952. /**
  18953. * Binds the material to the mesh
  18954. * @param world defines the world transformation matrix
  18955. * @param mesh defines the mesh to bind the material to
  18956. */
  18957. bind(world: Matrix, mesh?: Mesh): void;
  18958. /**
  18959. * Gets the active textures from the material
  18960. * @returns an array of textures
  18961. */
  18962. getActiveTextures(): BaseTexture[];
  18963. /**
  18964. * Specifies if the material uses a texture
  18965. * @param texture defines the texture to check against the material
  18966. * @returns a boolean specifying if the material uses the texture
  18967. */
  18968. hasTexture(texture: BaseTexture): boolean;
  18969. /**
  18970. * Makes a duplicate of the material, and gives it a new name
  18971. * @param name defines the new name for the duplicated material
  18972. * @returns the cloned material
  18973. */
  18974. clone(name: string): ShaderMaterial;
  18975. /**
  18976. * Disposes the material
  18977. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18978. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18979. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18980. */
  18981. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18982. /**
  18983. * Serializes this material in a JSON representation
  18984. * @returns the serialized material object
  18985. */
  18986. serialize(): any;
  18987. /**
  18988. * Creates a shader material from parsed shader material data
  18989. * @param source defines the JSON represnetation of the material
  18990. * @param scene defines the hosting scene
  18991. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18992. * @returns a new material
  18993. */
  18994. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  18995. }
  18996. }
  18997. declare module BABYLON {
  18998. /** @hidden */
  18999. export var colorPixelShader: {
  19000. name: string;
  19001. shader: string;
  19002. };
  19003. }
  19004. declare module BABYLON {
  19005. /** @hidden */
  19006. export var colorVertexShader: {
  19007. name: string;
  19008. shader: string;
  19009. };
  19010. }
  19011. declare module BABYLON {
  19012. /**
  19013. * Line mesh
  19014. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19015. */
  19016. export class LinesMesh extends Mesh {
  19017. /**
  19018. * If vertex color should be applied to the mesh
  19019. */
  19020. readonly useVertexColor?: boolean | undefined;
  19021. /**
  19022. * If vertex alpha should be applied to the mesh
  19023. */
  19024. readonly useVertexAlpha?: boolean | undefined;
  19025. /**
  19026. * Color of the line (Default: White)
  19027. */
  19028. color: Color3;
  19029. /**
  19030. * Alpha of the line (Default: 1)
  19031. */
  19032. alpha: number;
  19033. /**
  19034. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19035. * This margin is expressed in world space coordinates, so its value may vary.
  19036. * Default value is 0.1
  19037. */
  19038. intersectionThreshold: number;
  19039. private _colorShader;
  19040. private color4;
  19041. /**
  19042. * Creates a new LinesMesh
  19043. * @param name defines the name
  19044. * @param scene defines the hosting scene
  19045. * @param parent defines the parent mesh if any
  19046. * @param source defines the optional source LinesMesh used to clone data from
  19047. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19048. * When false, achieved by calling a clone(), also passing False.
  19049. * This will make creation of children, recursive.
  19050. * @param useVertexColor defines if this LinesMesh supports vertex color
  19051. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19052. */
  19053. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  19054. /**
  19055. * If vertex color should be applied to the mesh
  19056. */
  19057. useVertexColor?: boolean | undefined,
  19058. /**
  19059. * If vertex alpha should be applied to the mesh
  19060. */
  19061. useVertexAlpha?: boolean | undefined);
  19062. private _addClipPlaneDefine;
  19063. private _removeClipPlaneDefine;
  19064. isReady(): boolean;
  19065. /**
  19066. * Returns the string "LineMesh"
  19067. */
  19068. getClassName(): string;
  19069. /**
  19070. * @hidden
  19071. */
  19072. /**
  19073. * @hidden
  19074. */
  19075. material: Material;
  19076. /**
  19077. * @hidden
  19078. */
  19079. readonly checkCollisions: boolean;
  19080. /** @hidden */
  19081. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  19082. /** @hidden */
  19083. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  19084. /**
  19085. * Disposes of the line mesh
  19086. * @param doNotRecurse If children should be disposed
  19087. */
  19088. dispose(doNotRecurse?: boolean): void;
  19089. /**
  19090. * Returns a new LineMesh object cloned from the current one.
  19091. */
  19092. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  19093. /**
  19094. * Creates a new InstancedLinesMesh object from the mesh model.
  19095. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19096. * @param name defines the name of the new instance
  19097. * @returns a new InstancedLinesMesh
  19098. */
  19099. createInstance(name: string): InstancedLinesMesh;
  19100. }
  19101. /**
  19102. * Creates an instance based on a source LinesMesh
  19103. */
  19104. export class InstancedLinesMesh extends InstancedMesh {
  19105. /**
  19106. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19107. * This margin is expressed in world space coordinates, so its value may vary.
  19108. * Initilized with the intersectionThreshold value of the source LinesMesh
  19109. */
  19110. intersectionThreshold: number;
  19111. constructor(name: string, source: LinesMesh);
  19112. /**
  19113. * Returns the string "InstancedLinesMesh".
  19114. */
  19115. getClassName(): string;
  19116. }
  19117. }
  19118. declare module BABYLON {
  19119. /** @hidden */
  19120. export var linePixelShader: {
  19121. name: string;
  19122. shader: string;
  19123. };
  19124. }
  19125. declare module BABYLON {
  19126. /** @hidden */
  19127. export var lineVertexShader: {
  19128. name: string;
  19129. shader: string;
  19130. };
  19131. }
  19132. declare module BABYLON {
  19133. interface AbstractMesh {
  19134. /**
  19135. * Gets the edgesRenderer associated with the mesh
  19136. */
  19137. edgesRenderer: Nullable<EdgesRenderer>;
  19138. }
  19139. interface LinesMesh {
  19140. /**
  19141. * Enables the edge rendering mode on the mesh.
  19142. * This mode makes the mesh edges visible
  19143. * @param epsilon defines the maximal distance between two angles to detect a face
  19144. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19145. * @returns the currentAbstractMesh
  19146. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19147. */
  19148. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19149. }
  19150. interface InstancedLinesMesh {
  19151. /**
  19152. * Enables the edge rendering mode on the mesh.
  19153. * This mode makes the mesh edges visible
  19154. * @param epsilon defines the maximal distance between two angles to detect a face
  19155. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19156. * @returns the current InstancedLinesMesh
  19157. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19158. */
  19159. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19160. }
  19161. /**
  19162. * Defines the minimum contract an Edges renderer should follow.
  19163. */
  19164. export interface IEdgesRenderer extends IDisposable {
  19165. /**
  19166. * Gets or sets a boolean indicating if the edgesRenderer is active
  19167. */
  19168. isEnabled: boolean;
  19169. /**
  19170. * Renders the edges of the attached mesh,
  19171. */
  19172. render(): void;
  19173. /**
  19174. * Checks wether or not the edges renderer is ready to render.
  19175. * @return true if ready, otherwise false.
  19176. */
  19177. isReady(): boolean;
  19178. }
  19179. /**
  19180. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19181. */
  19182. export class EdgesRenderer implements IEdgesRenderer {
  19183. /**
  19184. * Define the size of the edges with an orthographic camera
  19185. */
  19186. edgesWidthScalerForOrthographic: number;
  19187. /**
  19188. * Define the size of the edges with a perspective camera
  19189. */
  19190. edgesWidthScalerForPerspective: number;
  19191. protected _source: AbstractMesh;
  19192. protected _linesPositions: number[];
  19193. protected _linesNormals: number[];
  19194. protected _linesIndices: number[];
  19195. protected _epsilon: number;
  19196. protected _indicesCount: number;
  19197. protected _lineShader: ShaderMaterial;
  19198. protected _ib: DataBuffer;
  19199. protected _buffers: {
  19200. [key: string]: Nullable<VertexBuffer>;
  19201. };
  19202. protected _checkVerticesInsteadOfIndices: boolean;
  19203. private _meshRebuildObserver;
  19204. private _meshDisposeObserver;
  19205. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19206. isEnabled: boolean;
  19207. /**
  19208. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19209. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19210. * @param source Mesh used to create edges
  19211. * @param epsilon sum of angles in adjacency to check for edge
  19212. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19213. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19214. */
  19215. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19216. protected _prepareRessources(): void;
  19217. /** @hidden */
  19218. _rebuild(): void;
  19219. /**
  19220. * Releases the required resources for the edges renderer
  19221. */
  19222. dispose(): void;
  19223. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19224. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19225. /**
  19226. * Checks if the pair of p0 and p1 is en edge
  19227. * @param faceIndex
  19228. * @param edge
  19229. * @param faceNormals
  19230. * @param p0
  19231. * @param p1
  19232. * @private
  19233. */
  19234. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19235. /**
  19236. * push line into the position, normal and index buffer
  19237. * @protected
  19238. */
  19239. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19240. /**
  19241. * Generates lines edges from adjacencjes
  19242. * @private
  19243. */
  19244. _generateEdgesLines(): void;
  19245. /**
  19246. * Checks wether or not the edges renderer is ready to render.
  19247. * @return true if ready, otherwise false.
  19248. */
  19249. isReady(): boolean;
  19250. /**
  19251. * Renders the edges of the attached mesh,
  19252. */
  19253. render(): void;
  19254. }
  19255. /**
  19256. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19257. */
  19258. export class LineEdgesRenderer extends EdgesRenderer {
  19259. /**
  19260. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19261. * @param source LineMesh used to generate edges
  19262. * @param epsilon not important (specified angle for edge detection)
  19263. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19264. */
  19265. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19266. /**
  19267. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19268. */
  19269. _generateEdgesLines(): void;
  19270. }
  19271. }
  19272. declare module BABYLON {
  19273. /**
  19274. * This represents the object necessary to create a rendering group.
  19275. * This is exclusively used and created by the rendering manager.
  19276. * To modify the behavior, you use the available helpers in your scene or meshes.
  19277. * @hidden
  19278. */
  19279. export class RenderingGroup {
  19280. index: number;
  19281. private static _zeroVector;
  19282. private _scene;
  19283. private _opaqueSubMeshes;
  19284. private _transparentSubMeshes;
  19285. private _alphaTestSubMeshes;
  19286. private _depthOnlySubMeshes;
  19287. private _particleSystems;
  19288. private _spriteManagers;
  19289. private _opaqueSortCompareFn;
  19290. private _alphaTestSortCompareFn;
  19291. private _transparentSortCompareFn;
  19292. private _renderOpaque;
  19293. private _renderAlphaTest;
  19294. private _renderTransparent;
  19295. /** @hidden */
  19296. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19297. onBeforeTransparentRendering: () => void;
  19298. /**
  19299. * Set the opaque sort comparison function.
  19300. * If null the sub meshes will be render in the order they were created
  19301. */
  19302. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19303. /**
  19304. * Set the alpha test sort comparison function.
  19305. * If null the sub meshes will be render in the order they were created
  19306. */
  19307. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19308. /**
  19309. * Set the transparent sort comparison function.
  19310. * If null the sub meshes will be render in the order they were created
  19311. */
  19312. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19313. /**
  19314. * Creates a new rendering group.
  19315. * @param index The rendering group index
  19316. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19317. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19318. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19319. */
  19320. 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>);
  19321. /**
  19322. * Render all the sub meshes contained in the group.
  19323. * @param customRenderFunction Used to override the default render behaviour of the group.
  19324. * @returns true if rendered some submeshes.
  19325. */
  19326. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19327. /**
  19328. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19329. * @param subMeshes The submeshes to render
  19330. */
  19331. private renderOpaqueSorted;
  19332. /**
  19333. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19334. * @param subMeshes The submeshes to render
  19335. */
  19336. private renderAlphaTestSorted;
  19337. /**
  19338. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19339. * @param subMeshes The submeshes to render
  19340. */
  19341. private renderTransparentSorted;
  19342. /**
  19343. * Renders the submeshes in a specified order.
  19344. * @param subMeshes The submeshes to sort before render
  19345. * @param sortCompareFn The comparison function use to sort
  19346. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19347. * @param transparent Specifies to activate blending if true
  19348. */
  19349. private static renderSorted;
  19350. /**
  19351. * Renders the submeshes in the order they were dispatched (no sort applied).
  19352. * @param subMeshes The submeshes to render
  19353. */
  19354. private static renderUnsorted;
  19355. /**
  19356. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19357. * are rendered back to front if in the same alpha index.
  19358. *
  19359. * @param a The first submesh
  19360. * @param b The second submesh
  19361. * @returns The result of the comparison
  19362. */
  19363. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19364. /**
  19365. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19366. * are rendered back to front.
  19367. *
  19368. * @param a The first submesh
  19369. * @param b The second submesh
  19370. * @returns The result of the comparison
  19371. */
  19372. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19373. /**
  19374. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19375. * are rendered front to back (prevent overdraw).
  19376. *
  19377. * @param a The first submesh
  19378. * @param b The second submesh
  19379. * @returns The result of the comparison
  19380. */
  19381. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19382. /**
  19383. * Resets the different lists of submeshes to prepare a new frame.
  19384. */
  19385. prepare(): void;
  19386. dispose(): void;
  19387. /**
  19388. * Inserts the submesh in its correct queue depending on its material.
  19389. * @param subMesh The submesh to dispatch
  19390. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19391. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19392. */
  19393. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19394. dispatchSprites(spriteManager: ISpriteManager): void;
  19395. dispatchParticles(particleSystem: IParticleSystem): void;
  19396. private _renderParticles;
  19397. private _renderSprites;
  19398. }
  19399. }
  19400. declare module BABYLON {
  19401. /**
  19402. * Interface describing the different options available in the rendering manager
  19403. * regarding Auto Clear between groups.
  19404. */
  19405. export interface IRenderingManagerAutoClearSetup {
  19406. /**
  19407. * Defines whether or not autoclear is enable.
  19408. */
  19409. autoClear: boolean;
  19410. /**
  19411. * Defines whether or not to autoclear the depth buffer.
  19412. */
  19413. depth: boolean;
  19414. /**
  19415. * Defines whether or not to autoclear the stencil buffer.
  19416. */
  19417. stencil: boolean;
  19418. }
  19419. /**
  19420. * This class is used by the onRenderingGroupObservable
  19421. */
  19422. export class RenderingGroupInfo {
  19423. /**
  19424. * The Scene that being rendered
  19425. */
  19426. scene: Scene;
  19427. /**
  19428. * The camera currently used for the rendering pass
  19429. */
  19430. camera: Nullable<Camera>;
  19431. /**
  19432. * The ID of the renderingGroup being processed
  19433. */
  19434. renderingGroupId: number;
  19435. }
  19436. /**
  19437. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19438. * It is enable to manage the different groups as well as the different necessary sort functions.
  19439. * This should not be used directly aside of the few static configurations
  19440. */
  19441. export class RenderingManager {
  19442. /**
  19443. * The max id used for rendering groups (not included)
  19444. */
  19445. static MAX_RENDERINGGROUPS: number;
  19446. /**
  19447. * The min id used for rendering groups (included)
  19448. */
  19449. static MIN_RENDERINGGROUPS: number;
  19450. /**
  19451. * Used to globally prevent autoclearing scenes.
  19452. */
  19453. static AUTOCLEAR: boolean;
  19454. /**
  19455. * @hidden
  19456. */
  19457. _useSceneAutoClearSetup: boolean;
  19458. private _scene;
  19459. private _renderingGroups;
  19460. private _depthStencilBufferAlreadyCleaned;
  19461. private _autoClearDepthStencil;
  19462. private _customOpaqueSortCompareFn;
  19463. private _customAlphaTestSortCompareFn;
  19464. private _customTransparentSortCompareFn;
  19465. private _renderingGroupInfo;
  19466. /**
  19467. * Instantiates a new rendering group for a particular scene
  19468. * @param scene Defines the scene the groups belongs to
  19469. */
  19470. constructor(scene: Scene);
  19471. private _clearDepthStencilBuffer;
  19472. /**
  19473. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19474. * @hidden
  19475. */
  19476. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19477. /**
  19478. * Resets the different information of the group to prepare a new frame
  19479. * @hidden
  19480. */
  19481. reset(): void;
  19482. /**
  19483. * Dispose and release the group and its associated resources.
  19484. * @hidden
  19485. */
  19486. dispose(): void;
  19487. /**
  19488. * Clear the info related to rendering groups preventing retention points during dispose.
  19489. */
  19490. freeRenderingGroups(): void;
  19491. private _prepareRenderingGroup;
  19492. /**
  19493. * Add a sprite manager to the rendering manager in order to render it this frame.
  19494. * @param spriteManager Define the sprite manager to render
  19495. */
  19496. dispatchSprites(spriteManager: ISpriteManager): void;
  19497. /**
  19498. * Add a particle system to the rendering manager in order to render it this frame.
  19499. * @param particleSystem Define the particle system to render
  19500. */
  19501. dispatchParticles(particleSystem: IParticleSystem): void;
  19502. /**
  19503. * Add a submesh to the manager in order to render it this frame
  19504. * @param subMesh The submesh to dispatch
  19505. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19506. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19507. */
  19508. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19509. /**
  19510. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19511. * This allowed control for front to back rendering or reversly depending of the special needs.
  19512. *
  19513. * @param renderingGroupId The rendering group id corresponding to its index
  19514. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19515. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19516. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19517. */
  19518. 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;
  19519. /**
  19520. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19521. *
  19522. * @param renderingGroupId The rendering group id corresponding to its index
  19523. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19524. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19525. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19526. */
  19527. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19528. /**
  19529. * Gets the current auto clear configuration for one rendering group of the rendering
  19530. * manager.
  19531. * @param index the rendering group index to get the information for
  19532. * @returns The auto clear setup for the requested rendering group
  19533. */
  19534. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19535. }
  19536. }
  19537. declare module BABYLON {
  19538. /**
  19539. * This Helps creating a texture that will be created from a camera in your scene.
  19540. * It is basically a dynamic texture that could be used to create special effects for instance.
  19541. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19542. */
  19543. export class RenderTargetTexture extends Texture {
  19544. isCube: boolean;
  19545. /**
  19546. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19547. */
  19548. static readonly REFRESHRATE_RENDER_ONCE: number;
  19549. /**
  19550. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19551. */
  19552. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19553. /**
  19554. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19555. * the central point of your effect and can save a lot of performances.
  19556. */
  19557. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19558. /**
  19559. * Use this predicate to dynamically define the list of mesh you want to render.
  19560. * If set, the renderList property will be overwritten.
  19561. */
  19562. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19563. private _renderList;
  19564. /**
  19565. * Use this list to define the list of mesh you want to render.
  19566. */
  19567. renderList: Nullable<Array<AbstractMesh>>;
  19568. private _hookArray;
  19569. /**
  19570. * Define if particles should be rendered in your texture.
  19571. */
  19572. renderParticles: boolean;
  19573. /**
  19574. * Define if sprites should be rendered in your texture.
  19575. */
  19576. renderSprites: boolean;
  19577. /**
  19578. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19579. */
  19580. coordinatesMode: number;
  19581. /**
  19582. * Define the camera used to render the texture.
  19583. */
  19584. activeCamera: Nullable<Camera>;
  19585. /**
  19586. * Override the render function of the texture with your own one.
  19587. */
  19588. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19589. /**
  19590. * Define if camera post processes should be use while rendering the texture.
  19591. */
  19592. useCameraPostProcesses: boolean;
  19593. /**
  19594. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19595. */
  19596. ignoreCameraViewport: boolean;
  19597. private _postProcessManager;
  19598. private _postProcesses;
  19599. private _resizeObserver;
  19600. /**
  19601. * An event triggered when the texture is unbind.
  19602. */
  19603. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19604. /**
  19605. * An event triggered when the texture is unbind.
  19606. */
  19607. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19608. private _onAfterUnbindObserver;
  19609. /**
  19610. * Set a after unbind callback in the texture.
  19611. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19612. */
  19613. onAfterUnbind: () => void;
  19614. /**
  19615. * An event triggered before rendering the texture
  19616. */
  19617. onBeforeRenderObservable: Observable<number>;
  19618. private _onBeforeRenderObserver;
  19619. /**
  19620. * Set a before render callback in the texture.
  19621. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19622. */
  19623. onBeforeRender: (faceIndex: number) => void;
  19624. /**
  19625. * An event triggered after rendering the texture
  19626. */
  19627. onAfterRenderObservable: Observable<number>;
  19628. private _onAfterRenderObserver;
  19629. /**
  19630. * Set a after render callback in the texture.
  19631. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19632. */
  19633. onAfterRender: (faceIndex: number) => void;
  19634. /**
  19635. * An event triggered after the texture clear
  19636. */
  19637. onClearObservable: Observable<Engine>;
  19638. private _onClearObserver;
  19639. /**
  19640. * Set a clear callback in the texture.
  19641. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19642. */
  19643. onClear: (Engine: Engine) => void;
  19644. /**
  19645. * An event triggered when the texture is resized.
  19646. */
  19647. onResizeObservable: Observable<RenderTargetTexture>;
  19648. /**
  19649. * Define the clear color of the Render Target if it should be different from the scene.
  19650. */
  19651. clearColor: Color4;
  19652. protected _size: number | {
  19653. width: number;
  19654. height: number;
  19655. };
  19656. protected _initialSizeParameter: number | {
  19657. width: number;
  19658. height: number;
  19659. } | {
  19660. ratio: number;
  19661. };
  19662. protected _sizeRatio: Nullable<number>;
  19663. /** @hidden */
  19664. _generateMipMaps: boolean;
  19665. protected _renderingManager: RenderingManager;
  19666. /** @hidden */
  19667. _waitingRenderList: string[];
  19668. protected _doNotChangeAspectRatio: boolean;
  19669. protected _currentRefreshId: number;
  19670. protected _refreshRate: number;
  19671. protected _textureMatrix: Matrix;
  19672. protected _samples: number;
  19673. protected _renderTargetOptions: RenderTargetCreationOptions;
  19674. /**
  19675. * Gets render target creation options that were used.
  19676. */
  19677. readonly renderTargetOptions: RenderTargetCreationOptions;
  19678. protected _engine: Engine;
  19679. protected _onRatioRescale(): void;
  19680. /**
  19681. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19682. * It must define where the camera used to render the texture is set
  19683. */
  19684. boundingBoxPosition: Vector3;
  19685. private _boundingBoxSize;
  19686. /**
  19687. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19688. * When defined, the cubemap will switch to local mode
  19689. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19690. * @example https://www.babylonjs-playground.com/#RNASML
  19691. */
  19692. boundingBoxSize: Vector3;
  19693. /**
  19694. * In case the RTT has been created with a depth texture, get the associated
  19695. * depth texture.
  19696. * Otherwise, return null.
  19697. */
  19698. depthStencilTexture: Nullable<InternalTexture>;
  19699. /**
  19700. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19701. * or used a shadow, depth texture...
  19702. * @param name The friendly name of the texture
  19703. * @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)
  19704. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19705. * @param generateMipMaps True if mip maps need to be generated after render.
  19706. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19707. * @param type The type of the buffer in the RTT (int, half float, float...)
  19708. * @param isCube True if a cube texture needs to be created
  19709. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19710. * @param generateDepthBuffer True to generate a depth buffer
  19711. * @param generateStencilBuffer True to generate a stencil buffer
  19712. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19713. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19714. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19715. */
  19716. constructor(name: string, size: number | {
  19717. width: number;
  19718. height: number;
  19719. } | {
  19720. ratio: number;
  19721. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19722. /**
  19723. * Creates a depth stencil texture.
  19724. * This is only available in WebGL 2 or with the depth texture extension available.
  19725. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19726. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19727. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19728. */
  19729. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19730. private _processSizeParameter;
  19731. /**
  19732. * Define the number of samples to use in case of MSAA.
  19733. * It defaults to one meaning no MSAA has been enabled.
  19734. */
  19735. samples: number;
  19736. /**
  19737. * Resets the refresh counter of the texture and start bak from scratch.
  19738. * Could be useful to regenerate the texture if it is setup to render only once.
  19739. */
  19740. resetRefreshCounter(): void;
  19741. /**
  19742. * Define the refresh rate of the texture or the rendering frequency.
  19743. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19744. */
  19745. refreshRate: number;
  19746. /**
  19747. * Adds a post process to the render target rendering passes.
  19748. * @param postProcess define the post process to add
  19749. */
  19750. addPostProcess(postProcess: PostProcess): void;
  19751. /**
  19752. * Clear all the post processes attached to the render target
  19753. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19754. */
  19755. clearPostProcesses(dispose?: boolean): void;
  19756. /**
  19757. * Remove one of the post process from the list of attached post processes to the texture
  19758. * @param postProcess define the post process to remove from the list
  19759. */
  19760. removePostProcess(postProcess: PostProcess): void;
  19761. /** @hidden */
  19762. _shouldRender(): boolean;
  19763. /**
  19764. * Gets the actual render size of the texture.
  19765. * @returns the width of the render size
  19766. */
  19767. getRenderSize(): number;
  19768. /**
  19769. * Gets the actual render width of the texture.
  19770. * @returns the width of the render size
  19771. */
  19772. getRenderWidth(): number;
  19773. /**
  19774. * Gets the actual render height of the texture.
  19775. * @returns the height of the render size
  19776. */
  19777. getRenderHeight(): number;
  19778. /**
  19779. * Get if the texture can be rescaled or not.
  19780. */
  19781. readonly canRescale: boolean;
  19782. /**
  19783. * Resize the texture using a ratio.
  19784. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19785. */
  19786. scale(ratio: number): void;
  19787. /**
  19788. * Get the texture reflection matrix used to rotate/transform the reflection.
  19789. * @returns the reflection matrix
  19790. */
  19791. getReflectionTextureMatrix(): Matrix;
  19792. /**
  19793. * Resize the texture to a new desired size.
  19794. * Be carrefull as it will recreate all the data in the new texture.
  19795. * @param size Define the new size. It can be:
  19796. * - a number for squared texture,
  19797. * - an object containing { width: number, height: number }
  19798. * - or an object containing a ratio { ratio: number }
  19799. */
  19800. resize(size: number | {
  19801. width: number;
  19802. height: number;
  19803. } | {
  19804. ratio: number;
  19805. }): void;
  19806. /**
  19807. * Renders all the objects from the render list into the texture.
  19808. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  19809. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  19810. */
  19811. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  19812. private _bestReflectionRenderTargetDimension;
  19813. /**
  19814. * @hidden
  19815. * @param faceIndex face index to bind to if this is a cubetexture
  19816. */
  19817. _bindFrameBuffer(faceIndex?: number): void;
  19818. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19819. private renderToTarget;
  19820. /**
  19821. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19822. * This allowed control for front to back rendering or reversly depending of the special needs.
  19823. *
  19824. * @param renderingGroupId The rendering group id corresponding to its index
  19825. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19826. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19827. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19828. */
  19829. 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;
  19830. /**
  19831. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19832. *
  19833. * @param renderingGroupId The rendering group id corresponding to its index
  19834. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19835. */
  19836. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19837. /**
  19838. * Clones the texture.
  19839. * @returns the cloned texture
  19840. */
  19841. clone(): RenderTargetTexture;
  19842. /**
  19843. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19844. * @returns The JSON representation of the texture
  19845. */
  19846. serialize(): any;
  19847. /**
  19848. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  19849. */
  19850. disposeFramebufferObjects(): void;
  19851. /**
  19852. * Dispose the texture and release its associated resources.
  19853. */
  19854. dispose(): void;
  19855. /** @hidden */
  19856. _rebuild(): void;
  19857. /**
  19858. * Clear the info related to rendering groups preventing retention point in material dispose.
  19859. */
  19860. freeRenderingGroups(): void;
  19861. /**
  19862. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19863. * @returns the view count
  19864. */
  19865. getViewCount(): number;
  19866. }
  19867. }
  19868. declare module BABYLON {
  19869. /**
  19870. * Base class for the main features of a material in Babylon.js
  19871. */
  19872. export class Material implements IAnimatable {
  19873. /**
  19874. * Returns the triangle fill mode
  19875. */
  19876. static readonly TriangleFillMode: number;
  19877. /**
  19878. * Returns the wireframe mode
  19879. */
  19880. static readonly WireFrameFillMode: number;
  19881. /**
  19882. * Returns the point fill mode
  19883. */
  19884. static readonly PointFillMode: number;
  19885. /**
  19886. * Returns the point list draw mode
  19887. */
  19888. static readonly PointListDrawMode: number;
  19889. /**
  19890. * Returns the line list draw mode
  19891. */
  19892. static readonly LineListDrawMode: number;
  19893. /**
  19894. * Returns the line loop draw mode
  19895. */
  19896. static readonly LineLoopDrawMode: number;
  19897. /**
  19898. * Returns the line strip draw mode
  19899. */
  19900. static readonly LineStripDrawMode: number;
  19901. /**
  19902. * Returns the triangle strip draw mode
  19903. */
  19904. static readonly TriangleStripDrawMode: number;
  19905. /**
  19906. * Returns the triangle fan draw mode
  19907. */
  19908. static readonly TriangleFanDrawMode: number;
  19909. /**
  19910. * Stores the clock-wise side orientation
  19911. */
  19912. static readonly ClockWiseSideOrientation: number;
  19913. /**
  19914. * Stores the counter clock-wise side orientation
  19915. */
  19916. static readonly CounterClockWiseSideOrientation: number;
  19917. /**
  19918. * The dirty texture flag value
  19919. */
  19920. static readonly TextureDirtyFlag: number;
  19921. /**
  19922. * The dirty light flag value
  19923. */
  19924. static readonly LightDirtyFlag: number;
  19925. /**
  19926. * The dirty fresnel flag value
  19927. */
  19928. static readonly FresnelDirtyFlag: number;
  19929. /**
  19930. * The dirty attribute flag value
  19931. */
  19932. static readonly AttributesDirtyFlag: number;
  19933. /**
  19934. * The dirty misc flag value
  19935. */
  19936. static readonly MiscDirtyFlag: number;
  19937. /**
  19938. * The all dirty flag value
  19939. */
  19940. static readonly AllDirtyFlag: number;
  19941. /**
  19942. * The ID of the material
  19943. */
  19944. id: string;
  19945. /**
  19946. * Gets or sets the unique id of the material
  19947. */
  19948. uniqueId: number;
  19949. /**
  19950. * The name of the material
  19951. */
  19952. name: string;
  19953. /**
  19954. * Gets or sets user defined metadata
  19955. */
  19956. metadata: any;
  19957. /**
  19958. * For internal use only. Please do not use.
  19959. */
  19960. reservedDataStore: any;
  19961. /**
  19962. * Specifies if the ready state should be checked on each call
  19963. */
  19964. checkReadyOnEveryCall: boolean;
  19965. /**
  19966. * Specifies if the ready state should be checked once
  19967. */
  19968. checkReadyOnlyOnce: boolean;
  19969. /**
  19970. * The state of the material
  19971. */
  19972. state: string;
  19973. /**
  19974. * The alpha value of the material
  19975. */
  19976. protected _alpha: number;
  19977. /**
  19978. * List of inspectable custom properties (used by the Inspector)
  19979. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19980. */
  19981. inspectableCustomProperties: IInspectable[];
  19982. /**
  19983. * Sets the alpha value of the material
  19984. */
  19985. /**
  19986. * Gets the alpha value of the material
  19987. */
  19988. alpha: number;
  19989. /**
  19990. * Specifies if back face culling is enabled
  19991. */
  19992. protected _backFaceCulling: boolean;
  19993. /**
  19994. * Sets the back-face culling state
  19995. */
  19996. /**
  19997. * Gets the back-face culling state
  19998. */
  19999. backFaceCulling: boolean;
  20000. /**
  20001. * Stores the value for side orientation
  20002. */
  20003. sideOrientation: number;
  20004. /**
  20005. * Callback triggered when the material is compiled
  20006. */
  20007. onCompiled: Nullable<(effect: Effect) => void>;
  20008. /**
  20009. * Callback triggered when an error occurs
  20010. */
  20011. onError: Nullable<(effect: Effect, errors: string) => void>;
  20012. /**
  20013. * Callback triggered to get the render target textures
  20014. */
  20015. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20016. /**
  20017. * Gets a boolean indicating that current material needs to register RTT
  20018. */
  20019. readonly hasRenderTargetTextures: boolean;
  20020. /**
  20021. * Specifies if the material should be serialized
  20022. */
  20023. doNotSerialize: boolean;
  20024. /**
  20025. * @hidden
  20026. */
  20027. _storeEffectOnSubMeshes: boolean;
  20028. /**
  20029. * Stores the animations for the material
  20030. */
  20031. animations: Nullable<Array<Animation>>;
  20032. /**
  20033. * An event triggered when the material is disposed
  20034. */
  20035. onDisposeObservable: Observable<Material>;
  20036. /**
  20037. * An observer which watches for dispose events
  20038. */
  20039. private _onDisposeObserver;
  20040. private _onUnBindObservable;
  20041. /**
  20042. * Called during a dispose event
  20043. */
  20044. onDispose: () => void;
  20045. private _onBindObservable;
  20046. /**
  20047. * An event triggered when the material is bound
  20048. */
  20049. readonly onBindObservable: Observable<AbstractMesh>;
  20050. /**
  20051. * An observer which watches for bind events
  20052. */
  20053. private _onBindObserver;
  20054. /**
  20055. * Called during a bind event
  20056. */
  20057. onBind: (Mesh: AbstractMesh) => void;
  20058. /**
  20059. * An event triggered when the material is unbound
  20060. */
  20061. readonly onUnBindObservable: Observable<Material>;
  20062. /**
  20063. * Stores the value of the alpha mode
  20064. */
  20065. private _alphaMode;
  20066. /**
  20067. * Sets the value of the alpha mode.
  20068. *
  20069. * | Value | Type | Description |
  20070. * | --- | --- | --- |
  20071. * | 0 | ALPHA_DISABLE | |
  20072. * | 1 | ALPHA_ADD | |
  20073. * | 2 | ALPHA_COMBINE | |
  20074. * | 3 | ALPHA_SUBTRACT | |
  20075. * | 4 | ALPHA_MULTIPLY | |
  20076. * | 5 | ALPHA_MAXIMIZED | |
  20077. * | 6 | ALPHA_ONEONE | |
  20078. * | 7 | ALPHA_PREMULTIPLIED | |
  20079. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20080. * | 9 | ALPHA_INTERPOLATE | |
  20081. * | 10 | ALPHA_SCREENMODE | |
  20082. *
  20083. */
  20084. /**
  20085. * Gets the value of the alpha mode
  20086. */
  20087. alphaMode: number;
  20088. /**
  20089. * Stores the state of the need depth pre-pass value
  20090. */
  20091. private _needDepthPrePass;
  20092. /**
  20093. * Sets the need depth pre-pass value
  20094. */
  20095. /**
  20096. * Gets the depth pre-pass value
  20097. */
  20098. needDepthPrePass: boolean;
  20099. /**
  20100. * Specifies if depth writing should be disabled
  20101. */
  20102. disableDepthWrite: boolean;
  20103. /**
  20104. * Specifies if depth writing should be forced
  20105. */
  20106. forceDepthWrite: boolean;
  20107. /**
  20108. * Specifies if there should be a separate pass for culling
  20109. */
  20110. separateCullingPass: boolean;
  20111. /**
  20112. * Stores the state specifing if fog should be enabled
  20113. */
  20114. private _fogEnabled;
  20115. /**
  20116. * Sets the state for enabling fog
  20117. */
  20118. /**
  20119. * Gets the value of the fog enabled state
  20120. */
  20121. fogEnabled: boolean;
  20122. /**
  20123. * Stores the size of points
  20124. */
  20125. pointSize: number;
  20126. /**
  20127. * Stores the z offset value
  20128. */
  20129. zOffset: number;
  20130. /**
  20131. * Gets a value specifying if wireframe mode is enabled
  20132. */
  20133. /**
  20134. * Sets the state of wireframe mode
  20135. */
  20136. wireframe: boolean;
  20137. /**
  20138. * Gets the value specifying if point clouds are enabled
  20139. */
  20140. /**
  20141. * Sets the state of point cloud mode
  20142. */
  20143. pointsCloud: boolean;
  20144. /**
  20145. * Gets the material fill mode
  20146. */
  20147. /**
  20148. * Sets the material fill mode
  20149. */
  20150. fillMode: number;
  20151. /**
  20152. * @hidden
  20153. * Stores the effects for the material
  20154. */
  20155. _effect: Nullable<Effect>;
  20156. /**
  20157. * @hidden
  20158. * Specifies if the material was previously ready
  20159. */
  20160. _wasPreviouslyReady: boolean;
  20161. /**
  20162. * Specifies if uniform buffers should be used
  20163. */
  20164. private _useUBO;
  20165. /**
  20166. * Stores a reference to the scene
  20167. */
  20168. private _scene;
  20169. /**
  20170. * Stores the fill mode state
  20171. */
  20172. private _fillMode;
  20173. /**
  20174. * Specifies if the depth write state should be cached
  20175. */
  20176. private _cachedDepthWriteState;
  20177. /**
  20178. * Stores the uniform buffer
  20179. */
  20180. protected _uniformBuffer: UniformBuffer;
  20181. /** @hidden */
  20182. _indexInSceneMaterialArray: number;
  20183. /** @hidden */
  20184. meshMap: Nullable<{
  20185. [id: string]: AbstractMesh | undefined;
  20186. }>;
  20187. /**
  20188. * Creates a material instance
  20189. * @param name defines the name of the material
  20190. * @param scene defines the scene to reference
  20191. * @param doNotAdd specifies if the material should be added to the scene
  20192. */
  20193. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20194. /**
  20195. * Returns a string representation of the current material
  20196. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20197. * @returns a string with material information
  20198. */
  20199. toString(fullDetails?: boolean): string;
  20200. /**
  20201. * Gets the class name of the material
  20202. * @returns a string with the class name of the material
  20203. */
  20204. getClassName(): string;
  20205. /**
  20206. * Specifies if updates for the material been locked
  20207. */
  20208. readonly isFrozen: boolean;
  20209. /**
  20210. * Locks updates for the material
  20211. */
  20212. freeze(): void;
  20213. /**
  20214. * Unlocks updates for the material
  20215. */
  20216. unfreeze(): void;
  20217. /**
  20218. * Specifies if the material is ready to be used
  20219. * @param mesh defines the mesh to check
  20220. * @param useInstances specifies if instances should be used
  20221. * @returns a boolean indicating if the material is ready to be used
  20222. */
  20223. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20224. /**
  20225. * Specifies that the submesh is ready to be used
  20226. * @param mesh defines the mesh to check
  20227. * @param subMesh defines which submesh to check
  20228. * @param useInstances specifies that instances should be used
  20229. * @returns a boolean indicating that the submesh is ready or not
  20230. */
  20231. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20232. /**
  20233. * Returns the material effect
  20234. * @returns the effect associated with the material
  20235. */
  20236. getEffect(): Nullable<Effect>;
  20237. /**
  20238. * Returns the current scene
  20239. * @returns a Scene
  20240. */
  20241. getScene(): Scene;
  20242. /**
  20243. * Specifies if the material will require alpha blending
  20244. * @returns a boolean specifying if alpha blending is needed
  20245. */
  20246. needAlphaBlending(): boolean;
  20247. /**
  20248. * Specifies if the mesh will require alpha blending
  20249. * @param mesh defines the mesh to check
  20250. * @returns a boolean specifying if alpha blending is needed for the mesh
  20251. */
  20252. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20253. /**
  20254. * Specifies if this material should be rendered in alpha test mode
  20255. * @returns a boolean specifying if an alpha test is needed.
  20256. */
  20257. needAlphaTesting(): boolean;
  20258. /**
  20259. * Gets the texture used for the alpha test
  20260. * @returns the texture to use for alpha testing
  20261. */
  20262. getAlphaTestTexture(): Nullable<BaseTexture>;
  20263. /**
  20264. * Marks the material to indicate that it needs to be re-calculated
  20265. */
  20266. markDirty(): void;
  20267. /** @hidden */
  20268. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20269. /**
  20270. * Binds the material to the mesh
  20271. * @param world defines the world transformation matrix
  20272. * @param mesh defines the mesh to bind the material to
  20273. */
  20274. bind(world: Matrix, mesh?: Mesh): void;
  20275. /**
  20276. * Binds the submesh to the material
  20277. * @param world defines the world transformation matrix
  20278. * @param mesh defines the mesh containing the submesh
  20279. * @param subMesh defines the submesh to bind the material to
  20280. */
  20281. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20282. /**
  20283. * Binds the world matrix to the material
  20284. * @param world defines the world transformation matrix
  20285. */
  20286. bindOnlyWorldMatrix(world: Matrix): void;
  20287. /**
  20288. * Binds the scene's uniform buffer to the effect.
  20289. * @param effect defines the effect to bind to the scene uniform buffer
  20290. * @param sceneUbo defines the uniform buffer storing scene data
  20291. */
  20292. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20293. /**
  20294. * Binds the view matrix to the effect
  20295. * @param effect defines the effect to bind the view matrix to
  20296. */
  20297. bindView(effect: Effect): void;
  20298. /**
  20299. * Binds the view projection matrix to the effect
  20300. * @param effect defines the effect to bind the view projection matrix to
  20301. */
  20302. bindViewProjection(effect: Effect): void;
  20303. /**
  20304. * Specifies if material alpha testing should be turned on for the mesh
  20305. * @param mesh defines the mesh to check
  20306. */
  20307. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20308. /**
  20309. * Processes to execute after binding the material to a mesh
  20310. * @param mesh defines the rendered mesh
  20311. */
  20312. protected _afterBind(mesh?: Mesh): void;
  20313. /**
  20314. * Unbinds the material from the mesh
  20315. */
  20316. unbind(): void;
  20317. /**
  20318. * Gets the active textures from the material
  20319. * @returns an array of textures
  20320. */
  20321. getActiveTextures(): BaseTexture[];
  20322. /**
  20323. * Specifies if the material uses a texture
  20324. * @param texture defines the texture to check against the material
  20325. * @returns a boolean specifying if the material uses the texture
  20326. */
  20327. hasTexture(texture: BaseTexture): boolean;
  20328. /**
  20329. * Makes a duplicate of the material, and gives it a new name
  20330. * @param name defines the new name for the duplicated material
  20331. * @returns the cloned material
  20332. */
  20333. clone(name: string): Nullable<Material>;
  20334. /**
  20335. * Gets the meshes bound to the material
  20336. * @returns an array of meshes bound to the material
  20337. */
  20338. getBindedMeshes(): AbstractMesh[];
  20339. /**
  20340. * Force shader compilation
  20341. * @param mesh defines the mesh associated with this material
  20342. * @param onCompiled defines a function to execute once the material is compiled
  20343. * @param options defines the options to configure the compilation
  20344. */
  20345. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20346. clipPlane: boolean;
  20347. }>): void;
  20348. /**
  20349. * Force shader compilation
  20350. * @param mesh defines the mesh that will use this material
  20351. * @param options defines additional options for compiling the shaders
  20352. * @returns a promise that resolves when the compilation completes
  20353. */
  20354. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20355. clipPlane: boolean;
  20356. }>): Promise<void>;
  20357. private static readonly _AllDirtyCallBack;
  20358. private static readonly _ImageProcessingDirtyCallBack;
  20359. private static readonly _TextureDirtyCallBack;
  20360. private static readonly _FresnelDirtyCallBack;
  20361. private static readonly _MiscDirtyCallBack;
  20362. private static readonly _LightsDirtyCallBack;
  20363. private static readonly _AttributeDirtyCallBack;
  20364. private static _FresnelAndMiscDirtyCallBack;
  20365. private static _TextureAndMiscDirtyCallBack;
  20366. private static readonly _DirtyCallbackArray;
  20367. private static readonly _RunDirtyCallBacks;
  20368. /**
  20369. * Marks a define in the material to indicate that it needs to be re-computed
  20370. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20371. */
  20372. markAsDirty(flag: number): void;
  20373. /**
  20374. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20375. * @param func defines a function which checks material defines against the submeshes
  20376. */
  20377. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20378. /**
  20379. * Indicates that we need to re-calculated for all submeshes
  20380. */
  20381. protected _markAllSubMeshesAsAllDirty(): void;
  20382. /**
  20383. * Indicates that image processing needs to be re-calculated for all submeshes
  20384. */
  20385. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20386. /**
  20387. * Indicates that textures need to be re-calculated for all submeshes
  20388. */
  20389. protected _markAllSubMeshesAsTexturesDirty(): void;
  20390. /**
  20391. * Indicates that fresnel needs to be re-calculated for all submeshes
  20392. */
  20393. protected _markAllSubMeshesAsFresnelDirty(): void;
  20394. /**
  20395. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20396. */
  20397. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20398. /**
  20399. * Indicates that lights need to be re-calculated for all submeshes
  20400. */
  20401. protected _markAllSubMeshesAsLightsDirty(): void;
  20402. /**
  20403. * Indicates that attributes need to be re-calculated for all submeshes
  20404. */
  20405. protected _markAllSubMeshesAsAttributesDirty(): void;
  20406. /**
  20407. * Indicates that misc needs to be re-calculated for all submeshes
  20408. */
  20409. protected _markAllSubMeshesAsMiscDirty(): void;
  20410. /**
  20411. * Indicates that textures and misc need to be re-calculated for all submeshes
  20412. */
  20413. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20414. /**
  20415. * Disposes the material
  20416. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20417. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20418. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20419. */
  20420. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20421. /** @hidden */
  20422. private releaseVertexArrayObject;
  20423. /**
  20424. * Serializes this material
  20425. * @returns the serialized material object
  20426. */
  20427. serialize(): any;
  20428. /**
  20429. * Creates a material from parsed material data
  20430. * @param parsedMaterial defines parsed material data
  20431. * @param scene defines the hosting scene
  20432. * @param rootUrl defines the root URL to use to load textures
  20433. * @returns a new material
  20434. */
  20435. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20436. }
  20437. }
  20438. declare module BABYLON {
  20439. /**
  20440. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20441. * separate meshes. This can be use to improve performances.
  20442. * @see http://doc.babylonjs.com/how_to/multi_materials
  20443. */
  20444. export class MultiMaterial extends Material {
  20445. private _subMaterials;
  20446. /**
  20447. * Gets or Sets the list of Materials used within the multi material.
  20448. * They need to be ordered according to the submeshes order in the associated mesh
  20449. */
  20450. subMaterials: Nullable<Material>[];
  20451. /**
  20452. * Function used to align with Node.getChildren()
  20453. * @returns the list of Materials used within the multi material
  20454. */
  20455. getChildren(): Nullable<Material>[];
  20456. /**
  20457. * Instantiates a new Multi Material
  20458. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20459. * separate meshes. This can be use to improve performances.
  20460. * @see http://doc.babylonjs.com/how_to/multi_materials
  20461. * @param name Define the name in the scene
  20462. * @param scene Define the scene the material belongs to
  20463. */
  20464. constructor(name: string, scene: Scene);
  20465. private _hookArray;
  20466. /**
  20467. * Get one of the submaterial by its index in the submaterials array
  20468. * @param index The index to look the sub material at
  20469. * @returns The Material if the index has been defined
  20470. */
  20471. getSubMaterial(index: number): Nullable<Material>;
  20472. /**
  20473. * Get the list of active textures for the whole sub materials list.
  20474. * @returns All the textures that will be used during the rendering
  20475. */
  20476. getActiveTextures(): BaseTexture[];
  20477. /**
  20478. * Gets the current class name of the material e.g. "MultiMaterial"
  20479. * Mainly use in serialization.
  20480. * @returns the class name
  20481. */
  20482. getClassName(): string;
  20483. /**
  20484. * Checks if the material is ready to render the requested sub mesh
  20485. * @param mesh Define the mesh the submesh belongs to
  20486. * @param subMesh Define the sub mesh to look readyness for
  20487. * @param useInstances Define whether or not the material is used with instances
  20488. * @returns true if ready, otherwise false
  20489. */
  20490. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20491. /**
  20492. * Clones the current material and its related sub materials
  20493. * @param name Define the name of the newly cloned material
  20494. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20495. * @returns the cloned material
  20496. */
  20497. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20498. /**
  20499. * Serializes the materials into a JSON representation.
  20500. * @returns the JSON representation
  20501. */
  20502. serialize(): any;
  20503. /**
  20504. * Dispose the material and release its associated resources
  20505. * @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)
  20506. * @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)
  20507. * @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)
  20508. */
  20509. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20510. /**
  20511. * Creates a MultiMaterial from parsed MultiMaterial data.
  20512. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20513. * @param scene defines the hosting scene
  20514. * @returns a new MultiMaterial
  20515. */
  20516. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20517. }
  20518. }
  20519. declare module BABYLON {
  20520. /**
  20521. * Base class for submeshes
  20522. */
  20523. export class BaseSubMesh {
  20524. /** @hidden */
  20525. _materialDefines: Nullable<MaterialDefines>;
  20526. /** @hidden */
  20527. _materialEffect: Nullable<Effect>;
  20528. /**
  20529. * Gets associated effect
  20530. */
  20531. readonly effect: Nullable<Effect>;
  20532. /**
  20533. * Sets associated effect (effect used to render this submesh)
  20534. * @param effect defines the effect to associate with
  20535. * @param defines defines the set of defines used to compile this effect
  20536. */
  20537. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20538. }
  20539. /**
  20540. * Defines a subdivision inside a mesh
  20541. */
  20542. export class SubMesh extends BaseSubMesh implements ICullable {
  20543. /** the material index to use */
  20544. materialIndex: number;
  20545. /** vertex index start */
  20546. verticesStart: number;
  20547. /** vertices count */
  20548. verticesCount: number;
  20549. /** index start */
  20550. indexStart: number;
  20551. /** indices count */
  20552. indexCount: number;
  20553. /** @hidden */
  20554. _linesIndexCount: number;
  20555. private _mesh;
  20556. private _renderingMesh;
  20557. private _boundingInfo;
  20558. private _linesIndexBuffer;
  20559. /** @hidden */
  20560. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20561. /** @hidden */
  20562. _trianglePlanes: Plane[];
  20563. /** @hidden */
  20564. _lastColliderTransformMatrix: Nullable<Matrix>;
  20565. /** @hidden */
  20566. _renderId: number;
  20567. /** @hidden */
  20568. _alphaIndex: number;
  20569. /** @hidden */
  20570. _distanceToCamera: number;
  20571. /** @hidden */
  20572. _id: number;
  20573. private _currentMaterial;
  20574. /**
  20575. * Add a new submesh to a mesh
  20576. * @param materialIndex defines the material index to use
  20577. * @param verticesStart defines vertex index start
  20578. * @param verticesCount defines vertices count
  20579. * @param indexStart defines index start
  20580. * @param indexCount defines indices count
  20581. * @param mesh defines the parent mesh
  20582. * @param renderingMesh defines an optional rendering mesh
  20583. * @param createBoundingBox defines if bounding box should be created for this submesh
  20584. * @returns the new submesh
  20585. */
  20586. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20587. /**
  20588. * Creates a new submesh
  20589. * @param materialIndex defines the material index to use
  20590. * @param verticesStart defines vertex index start
  20591. * @param verticesCount defines vertices count
  20592. * @param indexStart defines index start
  20593. * @param indexCount defines indices count
  20594. * @param mesh defines the parent mesh
  20595. * @param renderingMesh defines an optional rendering mesh
  20596. * @param createBoundingBox defines if bounding box should be created for this submesh
  20597. */
  20598. constructor(
  20599. /** the material index to use */
  20600. materialIndex: number,
  20601. /** vertex index start */
  20602. verticesStart: number,
  20603. /** vertices count */
  20604. verticesCount: number,
  20605. /** index start */
  20606. indexStart: number,
  20607. /** indices count */
  20608. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20609. /**
  20610. * Returns true if this submesh covers the entire parent mesh
  20611. * @ignorenaming
  20612. */
  20613. readonly IsGlobal: boolean;
  20614. /**
  20615. * Returns the submesh BoudingInfo object
  20616. * @returns current bounding info (or mesh's one if the submesh is global)
  20617. */
  20618. getBoundingInfo(): BoundingInfo;
  20619. /**
  20620. * Sets the submesh BoundingInfo
  20621. * @param boundingInfo defines the new bounding info to use
  20622. * @returns the SubMesh
  20623. */
  20624. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20625. /**
  20626. * Returns the mesh of the current submesh
  20627. * @return the parent mesh
  20628. */
  20629. getMesh(): AbstractMesh;
  20630. /**
  20631. * Returns the rendering mesh of the submesh
  20632. * @returns the rendering mesh (could be different from parent mesh)
  20633. */
  20634. getRenderingMesh(): Mesh;
  20635. /**
  20636. * Returns the submesh material
  20637. * @returns null or the current material
  20638. */
  20639. getMaterial(): Nullable<Material>;
  20640. /**
  20641. * Sets a new updated BoundingInfo object to the submesh
  20642. * @param data defines an optional position array to use to determine the bounding info
  20643. * @returns the SubMesh
  20644. */
  20645. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20646. /** @hidden */
  20647. _checkCollision(collider: Collider): boolean;
  20648. /**
  20649. * Updates the submesh BoundingInfo
  20650. * @param world defines the world matrix to use to update the bounding info
  20651. * @returns the submesh
  20652. */
  20653. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20654. /**
  20655. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20656. * @param frustumPlanes defines the frustum planes
  20657. * @returns true if the submesh is intersecting with the frustum
  20658. */
  20659. isInFrustum(frustumPlanes: Plane[]): boolean;
  20660. /**
  20661. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20662. * @param frustumPlanes defines the frustum planes
  20663. * @returns true if the submesh is inside the frustum
  20664. */
  20665. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20666. /**
  20667. * Renders the submesh
  20668. * @param enableAlphaMode defines if alpha needs to be used
  20669. * @returns the submesh
  20670. */
  20671. render(enableAlphaMode: boolean): SubMesh;
  20672. /**
  20673. * @hidden
  20674. */
  20675. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20676. /**
  20677. * Checks if the submesh intersects with a ray
  20678. * @param ray defines the ray to test
  20679. * @returns true is the passed ray intersects the submesh bounding box
  20680. */
  20681. canIntersects(ray: Ray): boolean;
  20682. /**
  20683. * Intersects current submesh with a ray
  20684. * @param ray defines the ray to test
  20685. * @param positions defines mesh's positions array
  20686. * @param indices defines mesh's indices array
  20687. * @param fastCheck defines if only bounding info should be used
  20688. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20689. * @returns intersection info or null if no intersection
  20690. */
  20691. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20692. /** @hidden */
  20693. private _intersectLines;
  20694. /** @hidden */
  20695. private _intersectUnIndexedLines;
  20696. /** @hidden */
  20697. private _intersectTriangles;
  20698. /** @hidden */
  20699. private _intersectUnIndexedTriangles;
  20700. /** @hidden */
  20701. _rebuild(): void;
  20702. /**
  20703. * Creates a new submesh from the passed mesh
  20704. * @param newMesh defines the new hosting mesh
  20705. * @param newRenderingMesh defines an optional rendering mesh
  20706. * @returns the new submesh
  20707. */
  20708. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20709. /**
  20710. * Release associated resources
  20711. */
  20712. dispose(): void;
  20713. /**
  20714. * Gets the class name
  20715. * @returns the string "SubMesh".
  20716. */
  20717. getClassName(): string;
  20718. /**
  20719. * Creates a new submesh from indices data
  20720. * @param materialIndex the index of the main mesh material
  20721. * @param startIndex the index where to start the copy in the mesh indices array
  20722. * @param indexCount the number of indices to copy then from the startIndex
  20723. * @param mesh the main mesh to create the submesh from
  20724. * @param renderingMesh the optional rendering mesh
  20725. * @returns a new submesh
  20726. */
  20727. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20728. }
  20729. }
  20730. declare module BABYLON {
  20731. /**
  20732. * Class used to represent data loading progression
  20733. */
  20734. export class SceneLoaderFlags {
  20735. private static _ForceFullSceneLoadingForIncremental;
  20736. private static _ShowLoadingScreen;
  20737. private static _CleanBoneMatrixWeights;
  20738. private static _loggingLevel;
  20739. /**
  20740. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20741. */
  20742. static ForceFullSceneLoadingForIncremental: boolean;
  20743. /**
  20744. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20745. */
  20746. static ShowLoadingScreen: boolean;
  20747. /**
  20748. * Defines the current logging level (while loading the scene)
  20749. * @ignorenaming
  20750. */
  20751. static loggingLevel: number;
  20752. /**
  20753. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20754. */
  20755. static CleanBoneMatrixWeights: boolean;
  20756. }
  20757. }
  20758. declare module BABYLON {
  20759. /**
  20760. * Class used to store geometry data (vertex buffers + index buffer)
  20761. */
  20762. export class Geometry implements IGetSetVerticesData {
  20763. /**
  20764. * Gets or sets the ID of the geometry
  20765. */
  20766. id: string;
  20767. /**
  20768. * Gets or sets the unique ID of the geometry
  20769. */
  20770. uniqueId: number;
  20771. /**
  20772. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20773. */
  20774. delayLoadState: number;
  20775. /**
  20776. * Gets the file containing the data to load when running in delay load state
  20777. */
  20778. delayLoadingFile: Nullable<string>;
  20779. /**
  20780. * Callback called when the geometry is updated
  20781. */
  20782. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20783. private _scene;
  20784. private _engine;
  20785. private _meshes;
  20786. private _totalVertices;
  20787. /** @hidden */
  20788. _indices: IndicesArray;
  20789. /** @hidden */
  20790. _vertexBuffers: {
  20791. [key: string]: VertexBuffer;
  20792. };
  20793. private _isDisposed;
  20794. private _extend;
  20795. private _boundingBias;
  20796. /** @hidden */
  20797. _delayInfo: Array<string>;
  20798. private _indexBuffer;
  20799. private _indexBufferIsUpdatable;
  20800. /** @hidden */
  20801. _boundingInfo: Nullable<BoundingInfo>;
  20802. /** @hidden */
  20803. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20804. /** @hidden */
  20805. _softwareSkinningFrameId: number;
  20806. private _vertexArrayObjects;
  20807. private _updatable;
  20808. /** @hidden */
  20809. _positions: Nullable<Vector3[]>;
  20810. /**
  20811. * 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
  20812. */
  20813. /**
  20814. * 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
  20815. */
  20816. boundingBias: Vector2;
  20817. /**
  20818. * Static function used to attach a new empty geometry to a mesh
  20819. * @param mesh defines the mesh to attach the geometry to
  20820. * @returns the new Geometry
  20821. */
  20822. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20823. /**
  20824. * Creates a new geometry
  20825. * @param id defines the unique ID
  20826. * @param scene defines the hosting scene
  20827. * @param vertexData defines the VertexData used to get geometry data
  20828. * @param updatable defines if geometry must be updatable (false by default)
  20829. * @param mesh defines the mesh that will be associated with the geometry
  20830. */
  20831. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20832. /**
  20833. * Gets the current extend of the geometry
  20834. */
  20835. readonly extend: {
  20836. minimum: Vector3;
  20837. maximum: Vector3;
  20838. };
  20839. /**
  20840. * Gets the hosting scene
  20841. * @returns the hosting Scene
  20842. */
  20843. getScene(): Scene;
  20844. /**
  20845. * Gets the hosting engine
  20846. * @returns the hosting Engine
  20847. */
  20848. getEngine(): Engine;
  20849. /**
  20850. * Defines if the geometry is ready to use
  20851. * @returns true if the geometry is ready to be used
  20852. */
  20853. isReady(): boolean;
  20854. /**
  20855. * Gets a value indicating that the geometry should not be serialized
  20856. */
  20857. readonly doNotSerialize: boolean;
  20858. /** @hidden */
  20859. _rebuild(): void;
  20860. /**
  20861. * Affects all geometry data in one call
  20862. * @param vertexData defines the geometry data
  20863. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20864. */
  20865. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20866. /**
  20867. * Set specific vertex data
  20868. * @param kind defines the data kind (Position, normal, etc...)
  20869. * @param data defines the vertex data to use
  20870. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20871. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20872. */
  20873. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20874. /**
  20875. * Removes a specific vertex data
  20876. * @param kind defines the data kind (Position, normal, etc...)
  20877. */
  20878. removeVerticesData(kind: string): void;
  20879. /**
  20880. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20881. * @param buffer defines the vertex buffer to use
  20882. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20883. */
  20884. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20885. /**
  20886. * Update a specific vertex buffer
  20887. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  20888. * It will do nothing if the buffer is not updatable
  20889. * @param kind defines the data kind (Position, normal, etc...)
  20890. * @param data defines the data to use
  20891. * @param offset defines the offset in the target buffer where to store the data
  20892. * @param useBytes set to true if the offset is in bytes
  20893. */
  20894. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20895. /**
  20896. * Update a specific vertex buffer
  20897. * This function will create a new buffer if the current one is not updatable
  20898. * @param kind defines the data kind (Position, normal, etc...)
  20899. * @param data defines the data to use
  20900. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20901. */
  20902. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20903. private _updateBoundingInfo;
  20904. /** @hidden */
  20905. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  20906. /**
  20907. * Gets total number of vertices
  20908. * @returns the total number of vertices
  20909. */
  20910. getTotalVertices(): number;
  20911. /**
  20912. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20913. * @param kind defines the data kind (Position, normal, etc...)
  20914. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20915. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20916. * @returns a float array containing vertex data
  20917. */
  20918. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20919. /**
  20920. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20921. * @param kind defines the data kind (Position, normal, etc...)
  20922. * @returns true if the vertex buffer with the specified kind is updatable
  20923. */
  20924. isVertexBufferUpdatable(kind: string): boolean;
  20925. /**
  20926. * Gets a specific vertex buffer
  20927. * @param kind defines the data kind (Position, normal, etc...)
  20928. * @returns a VertexBuffer
  20929. */
  20930. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20931. /**
  20932. * Returns all vertex buffers
  20933. * @return an object holding all vertex buffers indexed by kind
  20934. */
  20935. getVertexBuffers(): Nullable<{
  20936. [key: string]: VertexBuffer;
  20937. }>;
  20938. /**
  20939. * Gets a boolean indicating if specific vertex buffer is present
  20940. * @param kind defines the data kind (Position, normal, etc...)
  20941. * @returns true if data is present
  20942. */
  20943. isVerticesDataPresent(kind: string): boolean;
  20944. /**
  20945. * Gets a list of all attached data kinds (Position, normal, etc...)
  20946. * @returns a list of string containing all kinds
  20947. */
  20948. getVerticesDataKinds(): string[];
  20949. /**
  20950. * Update index buffer
  20951. * @param indices defines the indices to store in the index buffer
  20952. * @param offset defines the offset in the target buffer where to store the data
  20953. * @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)
  20954. */
  20955. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  20956. /**
  20957. * Creates a new index buffer
  20958. * @param indices defines the indices to store in the index buffer
  20959. * @param totalVertices defines the total number of vertices (could be null)
  20960. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20961. */
  20962. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20963. /**
  20964. * Return the total number of indices
  20965. * @returns the total number of indices
  20966. */
  20967. getTotalIndices(): number;
  20968. /**
  20969. * Gets the index buffer array
  20970. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20971. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20972. * @returns the index buffer array
  20973. */
  20974. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20975. /**
  20976. * Gets the index buffer
  20977. * @return the index buffer
  20978. */
  20979. getIndexBuffer(): Nullable<DataBuffer>;
  20980. /** @hidden */
  20981. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  20982. /**
  20983. * Release the associated resources for a specific mesh
  20984. * @param mesh defines the source mesh
  20985. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20986. */
  20987. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20988. /**
  20989. * Apply current geometry to a given mesh
  20990. * @param mesh defines the mesh to apply geometry to
  20991. */
  20992. applyToMesh(mesh: Mesh): void;
  20993. private _updateExtend;
  20994. private _applyToMesh;
  20995. private notifyUpdate;
  20996. /**
  20997. * Load the geometry if it was flagged as delay loaded
  20998. * @param scene defines the hosting scene
  20999. * @param onLoaded defines a callback called when the geometry is loaded
  21000. */
  21001. load(scene: Scene, onLoaded?: () => void): void;
  21002. private _queueLoad;
  21003. /**
  21004. * Invert the geometry to move from a right handed system to a left handed one.
  21005. */
  21006. toLeftHanded(): void;
  21007. /** @hidden */
  21008. _resetPointsArrayCache(): void;
  21009. /** @hidden */
  21010. _generatePointsArray(): boolean;
  21011. /**
  21012. * Gets a value indicating if the geometry is disposed
  21013. * @returns true if the geometry was disposed
  21014. */
  21015. isDisposed(): boolean;
  21016. private _disposeVertexArrayObjects;
  21017. /**
  21018. * Free all associated resources
  21019. */
  21020. dispose(): void;
  21021. /**
  21022. * Clone the current geometry into a new geometry
  21023. * @param id defines the unique ID of the new geometry
  21024. * @returns a new geometry object
  21025. */
  21026. copy(id: string): Geometry;
  21027. /**
  21028. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21029. * @return a JSON representation of the current geometry data (without the vertices data)
  21030. */
  21031. serialize(): any;
  21032. private toNumberArray;
  21033. /**
  21034. * Serialize all vertices data into a JSON oject
  21035. * @returns a JSON representation of the current geometry data
  21036. */
  21037. serializeVerticeData(): any;
  21038. /**
  21039. * Extracts a clone of a mesh geometry
  21040. * @param mesh defines the source mesh
  21041. * @param id defines the unique ID of the new geometry object
  21042. * @returns the new geometry object
  21043. */
  21044. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21045. /**
  21046. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21047. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21048. * Be aware Math.random() could cause collisions, but:
  21049. * "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"
  21050. * @returns a string containing a new GUID
  21051. */
  21052. static RandomId(): string;
  21053. /** @hidden */
  21054. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21055. private static _CleanMatricesWeights;
  21056. /**
  21057. * Create a new geometry from persisted data (Using .babylon file format)
  21058. * @param parsedVertexData defines the persisted data
  21059. * @param scene defines the hosting scene
  21060. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21061. * @returns the new geometry object
  21062. */
  21063. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21064. }
  21065. }
  21066. declare module BABYLON {
  21067. /**
  21068. * Define an interface for all classes that will get and set the data on vertices
  21069. */
  21070. export interface IGetSetVerticesData {
  21071. /**
  21072. * Gets a boolean indicating if specific vertex data is present
  21073. * @param kind defines the vertex data kind to use
  21074. * @returns true is data kind is present
  21075. */
  21076. isVerticesDataPresent(kind: string): boolean;
  21077. /**
  21078. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21079. * @param kind defines the data kind (Position, normal, etc...)
  21080. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21081. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21082. * @returns a float array containing vertex data
  21083. */
  21084. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21085. /**
  21086. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21087. * @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.
  21088. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21089. * @returns the indices array or an empty array if the mesh has no geometry
  21090. */
  21091. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21092. /**
  21093. * Set specific vertex data
  21094. * @param kind defines the data kind (Position, normal, etc...)
  21095. * @param data defines the vertex data to use
  21096. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21097. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21098. */
  21099. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21100. /**
  21101. * Update a specific associated vertex buffer
  21102. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21103. * - VertexBuffer.PositionKind
  21104. * - VertexBuffer.UVKind
  21105. * - VertexBuffer.UV2Kind
  21106. * - VertexBuffer.UV3Kind
  21107. * - VertexBuffer.UV4Kind
  21108. * - VertexBuffer.UV5Kind
  21109. * - VertexBuffer.UV6Kind
  21110. * - VertexBuffer.ColorKind
  21111. * - VertexBuffer.MatricesIndicesKind
  21112. * - VertexBuffer.MatricesIndicesExtraKind
  21113. * - VertexBuffer.MatricesWeightsKind
  21114. * - VertexBuffer.MatricesWeightsExtraKind
  21115. * @param data defines the data source
  21116. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21117. * @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)
  21118. */
  21119. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21120. /**
  21121. * Creates a new index buffer
  21122. * @param indices defines the indices to store in the index buffer
  21123. * @param totalVertices defines the total number of vertices (could be null)
  21124. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21125. */
  21126. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21127. }
  21128. /**
  21129. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21130. */
  21131. export class VertexData {
  21132. /**
  21133. * Mesh side orientation : usually the external or front surface
  21134. */
  21135. static readonly FRONTSIDE: number;
  21136. /**
  21137. * Mesh side orientation : usually the internal or back surface
  21138. */
  21139. static readonly BACKSIDE: number;
  21140. /**
  21141. * Mesh side orientation : both internal and external or front and back surfaces
  21142. */
  21143. static readonly DOUBLESIDE: number;
  21144. /**
  21145. * Mesh side orientation : by default, `FRONTSIDE`
  21146. */
  21147. static readonly DEFAULTSIDE: number;
  21148. /**
  21149. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21150. */
  21151. positions: Nullable<FloatArray>;
  21152. /**
  21153. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21154. */
  21155. normals: Nullable<FloatArray>;
  21156. /**
  21157. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21158. */
  21159. tangents: Nullable<FloatArray>;
  21160. /**
  21161. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21162. */
  21163. uvs: Nullable<FloatArray>;
  21164. /**
  21165. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21166. */
  21167. uvs2: Nullable<FloatArray>;
  21168. /**
  21169. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21170. */
  21171. uvs3: Nullable<FloatArray>;
  21172. /**
  21173. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21174. */
  21175. uvs4: Nullable<FloatArray>;
  21176. /**
  21177. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21178. */
  21179. uvs5: Nullable<FloatArray>;
  21180. /**
  21181. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21182. */
  21183. uvs6: Nullable<FloatArray>;
  21184. /**
  21185. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21186. */
  21187. colors: Nullable<FloatArray>;
  21188. /**
  21189. * 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).
  21190. */
  21191. matricesIndices: Nullable<FloatArray>;
  21192. /**
  21193. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21194. */
  21195. matricesWeights: Nullable<FloatArray>;
  21196. /**
  21197. * An array extending the number of possible indices
  21198. */
  21199. matricesIndicesExtra: Nullable<FloatArray>;
  21200. /**
  21201. * An array extending the number of possible weights when the number of indices is extended
  21202. */
  21203. matricesWeightsExtra: Nullable<FloatArray>;
  21204. /**
  21205. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21206. */
  21207. indices: Nullable<IndicesArray>;
  21208. /**
  21209. * Uses the passed data array to set the set the values for the specified kind of data
  21210. * @param data a linear array of floating numbers
  21211. * @param kind the type of data that is being set, eg positions, colors etc
  21212. */
  21213. set(data: FloatArray, kind: string): void;
  21214. /**
  21215. * Associates the vertexData to the passed Mesh.
  21216. * Sets it as updatable or not (default `false`)
  21217. * @param mesh the mesh the vertexData is applied to
  21218. * @param updatable when used and having the value true allows new data to update the vertexData
  21219. * @returns the VertexData
  21220. */
  21221. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21222. /**
  21223. * Associates the vertexData to the passed Geometry.
  21224. * Sets it as updatable or not (default `false`)
  21225. * @param geometry the geometry the vertexData is applied to
  21226. * @param updatable when used and having the value true allows new data to update the vertexData
  21227. * @returns VertexData
  21228. */
  21229. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21230. /**
  21231. * Updates the associated mesh
  21232. * @param mesh the mesh to be updated
  21233. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21234. * @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
  21235. * @returns VertexData
  21236. */
  21237. updateMesh(mesh: Mesh): VertexData;
  21238. /**
  21239. * Updates the associated geometry
  21240. * @param geometry the geometry to be updated
  21241. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21242. * @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
  21243. * @returns VertexData.
  21244. */
  21245. updateGeometry(geometry: Geometry): VertexData;
  21246. private _applyTo;
  21247. private _update;
  21248. /**
  21249. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21250. * @param matrix the transforming matrix
  21251. * @returns the VertexData
  21252. */
  21253. transform(matrix: Matrix): VertexData;
  21254. /**
  21255. * Merges the passed VertexData into the current one
  21256. * @param other the VertexData to be merged into the current one
  21257. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21258. * @returns the modified VertexData
  21259. */
  21260. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21261. private _mergeElement;
  21262. private _validate;
  21263. /**
  21264. * Serializes the VertexData
  21265. * @returns a serialized object
  21266. */
  21267. serialize(): any;
  21268. /**
  21269. * Extracts the vertexData from a mesh
  21270. * @param mesh the mesh from which to extract the VertexData
  21271. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21272. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21273. * @returns the object VertexData associated to the passed mesh
  21274. */
  21275. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21276. /**
  21277. * Extracts the vertexData from the geometry
  21278. * @param geometry the geometry from which to extract the VertexData
  21279. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21280. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21281. * @returns the object VertexData associated to the passed mesh
  21282. */
  21283. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21284. private static _ExtractFrom;
  21285. /**
  21286. * Creates the VertexData for a Ribbon
  21287. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21288. * * pathArray array of paths, each of which an array of successive Vector3
  21289. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21290. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21291. * * 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
  21292. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21293. * * 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)
  21294. * * 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)
  21295. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21296. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21297. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21298. * @returns the VertexData of the ribbon
  21299. */
  21300. static CreateRibbon(options: {
  21301. pathArray: Vector3[][];
  21302. closeArray?: boolean;
  21303. closePath?: boolean;
  21304. offset?: number;
  21305. sideOrientation?: number;
  21306. frontUVs?: Vector4;
  21307. backUVs?: Vector4;
  21308. invertUV?: boolean;
  21309. uvs?: Vector2[];
  21310. colors?: Color4[];
  21311. }): VertexData;
  21312. /**
  21313. * Creates the VertexData for a box
  21314. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21315. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21316. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21317. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21318. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21319. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21320. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21321. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21322. * * 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)
  21323. * * 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)
  21324. * @returns the VertexData of the box
  21325. */
  21326. static CreateBox(options: {
  21327. size?: number;
  21328. width?: number;
  21329. height?: number;
  21330. depth?: number;
  21331. faceUV?: Vector4[];
  21332. faceColors?: Color4[];
  21333. sideOrientation?: number;
  21334. frontUVs?: Vector4;
  21335. backUVs?: Vector4;
  21336. }): VertexData;
  21337. /**
  21338. * Creates the VertexData for a tiled box
  21339. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21340. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21341. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21342. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21343. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21344. * @returns the VertexData of the box
  21345. */
  21346. static CreateTiledBox(options: {
  21347. pattern?: number;
  21348. width?: number;
  21349. height?: number;
  21350. depth?: number;
  21351. tileSize?: number;
  21352. tileWidth?: number;
  21353. tileHeight?: number;
  21354. alignHorizontal?: number;
  21355. alignVertical?: number;
  21356. faceUV?: Vector4[];
  21357. faceColors?: Color4[];
  21358. sideOrientation?: number;
  21359. }): VertexData;
  21360. /**
  21361. * Creates the VertexData for a tiled plane
  21362. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21363. * * pattern a limited pattern arrangement depending on the number
  21364. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21365. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21366. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21367. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21368. * * 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)
  21369. * * 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)
  21370. * @returns the VertexData of the tiled plane
  21371. */
  21372. static CreateTiledPlane(options: {
  21373. pattern?: number;
  21374. tileSize?: number;
  21375. tileWidth?: number;
  21376. tileHeight?: number;
  21377. size?: number;
  21378. width?: number;
  21379. height?: number;
  21380. alignHorizontal?: number;
  21381. alignVertical?: number;
  21382. sideOrientation?: number;
  21383. frontUVs?: Vector4;
  21384. backUVs?: Vector4;
  21385. }): VertexData;
  21386. /**
  21387. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21388. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21389. * * segments sets the number of horizontal strips optional, default 32
  21390. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21391. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21392. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21393. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21394. * * 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
  21395. * * 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
  21396. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21397. * * 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)
  21398. * * 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)
  21399. * @returns the VertexData of the ellipsoid
  21400. */
  21401. static CreateSphere(options: {
  21402. segments?: number;
  21403. diameter?: number;
  21404. diameterX?: number;
  21405. diameterY?: number;
  21406. diameterZ?: number;
  21407. arc?: number;
  21408. slice?: number;
  21409. sideOrientation?: number;
  21410. frontUVs?: Vector4;
  21411. backUVs?: Vector4;
  21412. }): VertexData;
  21413. /**
  21414. * Creates the VertexData for a cylinder, cone or prism
  21415. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21416. * * height sets the height (y direction) of the cylinder, optional, default 2
  21417. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21418. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21419. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21420. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21421. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21422. * * 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
  21423. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21424. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21425. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21426. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21427. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21428. * * 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)
  21429. * * 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)
  21430. * @returns the VertexData of the cylinder, cone or prism
  21431. */
  21432. static CreateCylinder(options: {
  21433. height?: number;
  21434. diameterTop?: number;
  21435. diameterBottom?: number;
  21436. diameter?: number;
  21437. tessellation?: number;
  21438. subdivisions?: number;
  21439. arc?: number;
  21440. faceColors?: Color4[];
  21441. faceUV?: Vector4[];
  21442. hasRings?: boolean;
  21443. enclose?: boolean;
  21444. sideOrientation?: number;
  21445. frontUVs?: Vector4;
  21446. backUVs?: Vector4;
  21447. }): VertexData;
  21448. /**
  21449. * Creates the VertexData for a torus
  21450. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21451. * * diameter the diameter of the torus, optional default 1
  21452. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21453. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21454. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21455. * * 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)
  21456. * * 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)
  21457. * @returns the VertexData of the torus
  21458. */
  21459. static CreateTorus(options: {
  21460. diameter?: number;
  21461. thickness?: number;
  21462. tessellation?: number;
  21463. sideOrientation?: number;
  21464. frontUVs?: Vector4;
  21465. backUVs?: Vector4;
  21466. }): VertexData;
  21467. /**
  21468. * Creates the VertexData of the LineSystem
  21469. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21470. * - lines an array of lines, each line being an array of successive Vector3
  21471. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21472. * @returns the VertexData of the LineSystem
  21473. */
  21474. static CreateLineSystem(options: {
  21475. lines: Vector3[][];
  21476. colors?: Nullable<Color4[][]>;
  21477. }): VertexData;
  21478. /**
  21479. * Create the VertexData for a DashedLines
  21480. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21481. * - points an array successive Vector3
  21482. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21483. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21484. * - dashNb the intended total number of dashes, optional, default 200
  21485. * @returns the VertexData for the DashedLines
  21486. */
  21487. static CreateDashedLines(options: {
  21488. points: Vector3[];
  21489. dashSize?: number;
  21490. gapSize?: number;
  21491. dashNb?: number;
  21492. }): VertexData;
  21493. /**
  21494. * Creates the VertexData for a Ground
  21495. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21496. * - width the width (x direction) of the ground, optional, default 1
  21497. * - height the height (z direction) of the ground, optional, default 1
  21498. * - subdivisions the number of subdivisions per side, optional, default 1
  21499. * @returns the VertexData of the Ground
  21500. */
  21501. static CreateGround(options: {
  21502. width?: number;
  21503. height?: number;
  21504. subdivisions?: number;
  21505. subdivisionsX?: number;
  21506. subdivisionsY?: number;
  21507. }): VertexData;
  21508. /**
  21509. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21510. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21511. * * xmin the ground minimum X coordinate, optional, default -1
  21512. * * zmin the ground minimum Z coordinate, optional, default -1
  21513. * * xmax the ground maximum X coordinate, optional, default 1
  21514. * * zmax the ground maximum Z coordinate, optional, default 1
  21515. * * 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}
  21516. * * 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}
  21517. * @returns the VertexData of the TiledGround
  21518. */
  21519. static CreateTiledGround(options: {
  21520. xmin: number;
  21521. zmin: number;
  21522. xmax: number;
  21523. zmax: number;
  21524. subdivisions?: {
  21525. w: number;
  21526. h: number;
  21527. };
  21528. precision?: {
  21529. w: number;
  21530. h: number;
  21531. };
  21532. }): VertexData;
  21533. /**
  21534. * Creates the VertexData of the Ground designed from a heightmap
  21535. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21536. * * width the width (x direction) of the ground
  21537. * * height the height (z direction) of the ground
  21538. * * subdivisions the number of subdivisions per side
  21539. * * minHeight the minimum altitude on the ground, optional, default 0
  21540. * * maxHeight the maximum altitude on the ground, optional default 1
  21541. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21542. * * buffer the array holding the image color data
  21543. * * bufferWidth the width of image
  21544. * * bufferHeight the height of image
  21545. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21546. * @returns the VertexData of the Ground designed from a heightmap
  21547. */
  21548. static CreateGroundFromHeightMap(options: {
  21549. width: number;
  21550. height: number;
  21551. subdivisions: number;
  21552. minHeight: number;
  21553. maxHeight: number;
  21554. colorFilter: Color3;
  21555. buffer: Uint8Array;
  21556. bufferWidth: number;
  21557. bufferHeight: number;
  21558. alphaFilter: number;
  21559. }): VertexData;
  21560. /**
  21561. * Creates the VertexData for a Plane
  21562. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21563. * * size sets the width and height of the plane to the value of size, optional default 1
  21564. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21565. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21566. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21567. * * 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)
  21568. * * 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)
  21569. * @returns the VertexData of the box
  21570. */
  21571. static CreatePlane(options: {
  21572. size?: number;
  21573. width?: number;
  21574. height?: number;
  21575. sideOrientation?: number;
  21576. frontUVs?: Vector4;
  21577. backUVs?: Vector4;
  21578. }): VertexData;
  21579. /**
  21580. * Creates the VertexData of the Disc or regular Polygon
  21581. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21582. * * radius the radius of the disc, optional default 0.5
  21583. * * tessellation the number of polygon sides, optional, default 64
  21584. * * 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
  21585. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21586. * * 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)
  21587. * * 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)
  21588. * @returns the VertexData of the box
  21589. */
  21590. static CreateDisc(options: {
  21591. radius?: number;
  21592. tessellation?: number;
  21593. arc?: number;
  21594. sideOrientation?: number;
  21595. frontUVs?: Vector4;
  21596. backUVs?: Vector4;
  21597. }): VertexData;
  21598. /**
  21599. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21600. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21601. * @param polygon a mesh built from polygonTriangulation.build()
  21602. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21603. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21604. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21605. * @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)
  21606. * @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)
  21607. * @returns the VertexData of the Polygon
  21608. */
  21609. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21610. /**
  21611. * Creates the VertexData of the IcoSphere
  21612. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21613. * * radius the radius of the IcoSphere, optional default 1
  21614. * * radiusX allows stretching in the x direction, optional, default radius
  21615. * * radiusY allows stretching in the y direction, optional, default radius
  21616. * * radiusZ allows stretching in the z direction, optional, default radius
  21617. * * flat when true creates a flat shaded mesh, optional, default true
  21618. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21619. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21620. * * 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)
  21621. * * 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)
  21622. * @returns the VertexData of the IcoSphere
  21623. */
  21624. static CreateIcoSphere(options: {
  21625. radius?: number;
  21626. radiusX?: number;
  21627. radiusY?: number;
  21628. radiusZ?: number;
  21629. flat?: boolean;
  21630. subdivisions?: number;
  21631. sideOrientation?: number;
  21632. frontUVs?: Vector4;
  21633. backUVs?: Vector4;
  21634. }): VertexData;
  21635. /**
  21636. * Creates the VertexData for a Polyhedron
  21637. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21638. * * type provided types are:
  21639. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21640. * * 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)
  21641. * * size the size of the IcoSphere, optional default 1
  21642. * * sizeX allows stretching in the x direction, optional, default size
  21643. * * sizeY allows stretching in the y direction, optional, default size
  21644. * * sizeZ allows stretching in the z direction, optional, default size
  21645. * * 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
  21646. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21647. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21648. * * flat when true creates a flat shaded mesh, optional, default true
  21649. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21650. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21651. * * 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)
  21652. * * 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)
  21653. * @returns the VertexData of the Polyhedron
  21654. */
  21655. static CreatePolyhedron(options: {
  21656. type?: number;
  21657. size?: number;
  21658. sizeX?: number;
  21659. sizeY?: number;
  21660. sizeZ?: number;
  21661. custom?: any;
  21662. faceUV?: Vector4[];
  21663. faceColors?: Color4[];
  21664. flat?: boolean;
  21665. sideOrientation?: number;
  21666. frontUVs?: Vector4;
  21667. backUVs?: Vector4;
  21668. }): VertexData;
  21669. /**
  21670. * Creates the VertexData for a TorusKnot
  21671. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21672. * * radius the radius of the torus knot, optional, default 2
  21673. * * tube the thickness of the tube, optional, default 0.5
  21674. * * radialSegments the number of sides on each tube segments, optional, default 32
  21675. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21676. * * p the number of windings around the z axis, optional, default 2
  21677. * * q the number of windings around the x axis, optional, default 3
  21678. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21679. * * 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)
  21680. * * 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)
  21681. * @returns the VertexData of the Torus Knot
  21682. */
  21683. static CreateTorusKnot(options: {
  21684. radius?: number;
  21685. tube?: number;
  21686. radialSegments?: number;
  21687. tubularSegments?: number;
  21688. p?: number;
  21689. q?: number;
  21690. sideOrientation?: number;
  21691. frontUVs?: Vector4;
  21692. backUVs?: Vector4;
  21693. }): VertexData;
  21694. /**
  21695. * Compute normals for given positions and indices
  21696. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21697. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21698. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21699. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21700. * * facetNormals : optional array of facet normals (vector3)
  21701. * * facetPositions : optional array of facet positions (vector3)
  21702. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21703. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21704. * * bInfo : optional bounding info, required for facetPartitioning computation
  21705. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21706. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21707. * * useRightHandedSystem: optional boolean to for right handed system computation
  21708. * * depthSort : optional boolean to enable the facet depth sort computation
  21709. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21710. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21711. */
  21712. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21713. facetNormals?: any;
  21714. facetPositions?: any;
  21715. facetPartitioning?: any;
  21716. ratio?: number;
  21717. bInfo?: any;
  21718. bbSize?: Vector3;
  21719. subDiv?: any;
  21720. useRightHandedSystem?: boolean;
  21721. depthSort?: boolean;
  21722. distanceTo?: Vector3;
  21723. depthSortedFacets?: any;
  21724. }): void;
  21725. /** @hidden */
  21726. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21727. /**
  21728. * Applies VertexData created from the imported parameters to the geometry
  21729. * @param parsedVertexData the parsed data from an imported file
  21730. * @param geometry the geometry to apply the VertexData to
  21731. */
  21732. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21733. }
  21734. }
  21735. declare module BABYLON {
  21736. /**
  21737. * Defines a target to use with MorphTargetManager
  21738. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21739. */
  21740. export class MorphTarget implements IAnimatable {
  21741. /** defines the name of the target */
  21742. name: string;
  21743. /**
  21744. * Gets or sets the list of animations
  21745. */
  21746. animations: Animation[];
  21747. private _scene;
  21748. private _positions;
  21749. private _normals;
  21750. private _tangents;
  21751. private _uvs;
  21752. private _influence;
  21753. /**
  21754. * Observable raised when the influence changes
  21755. */
  21756. onInfluenceChanged: Observable<boolean>;
  21757. /** @hidden */
  21758. _onDataLayoutChanged: Observable<void>;
  21759. /**
  21760. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21761. */
  21762. influence: number;
  21763. /**
  21764. * Gets or sets the id of the morph Target
  21765. */
  21766. id: string;
  21767. private _animationPropertiesOverride;
  21768. /**
  21769. * Gets or sets the animation properties override
  21770. */
  21771. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21772. /**
  21773. * Creates a new MorphTarget
  21774. * @param name defines the name of the target
  21775. * @param influence defines the influence to use
  21776. * @param scene defines the scene the morphtarget belongs to
  21777. */
  21778. constructor(
  21779. /** defines the name of the target */
  21780. name: string, influence?: number, scene?: Nullable<Scene>);
  21781. /**
  21782. * Gets a boolean defining if the target contains position data
  21783. */
  21784. readonly hasPositions: boolean;
  21785. /**
  21786. * Gets a boolean defining if the target contains normal data
  21787. */
  21788. readonly hasNormals: boolean;
  21789. /**
  21790. * Gets a boolean defining if the target contains tangent data
  21791. */
  21792. readonly hasTangents: boolean;
  21793. /**
  21794. * Gets a boolean defining if the target contains texture coordinates data
  21795. */
  21796. readonly hasUVs: boolean;
  21797. /**
  21798. * Affects position data to this target
  21799. * @param data defines the position data to use
  21800. */
  21801. setPositions(data: Nullable<FloatArray>): void;
  21802. /**
  21803. * Gets the position data stored in this target
  21804. * @returns a FloatArray containing the position data (or null if not present)
  21805. */
  21806. getPositions(): Nullable<FloatArray>;
  21807. /**
  21808. * Affects normal data to this target
  21809. * @param data defines the normal data to use
  21810. */
  21811. setNormals(data: Nullable<FloatArray>): void;
  21812. /**
  21813. * Gets the normal data stored in this target
  21814. * @returns a FloatArray containing the normal data (or null if not present)
  21815. */
  21816. getNormals(): Nullable<FloatArray>;
  21817. /**
  21818. * Affects tangent data to this target
  21819. * @param data defines the tangent data to use
  21820. */
  21821. setTangents(data: Nullable<FloatArray>): void;
  21822. /**
  21823. * Gets the tangent data stored in this target
  21824. * @returns a FloatArray containing the tangent data (or null if not present)
  21825. */
  21826. getTangents(): Nullable<FloatArray>;
  21827. /**
  21828. * Affects texture coordinates data to this target
  21829. * @param data defines the texture coordinates data to use
  21830. */
  21831. setUVs(data: Nullable<FloatArray>): void;
  21832. /**
  21833. * Gets the texture coordinates data stored in this target
  21834. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  21835. */
  21836. getUVs(): Nullable<FloatArray>;
  21837. /**
  21838. * Serializes the current target into a Serialization object
  21839. * @returns the serialized object
  21840. */
  21841. serialize(): any;
  21842. /**
  21843. * Returns the string "MorphTarget"
  21844. * @returns "MorphTarget"
  21845. */
  21846. getClassName(): string;
  21847. /**
  21848. * Creates a new target from serialized data
  21849. * @param serializationObject defines the serialized data to use
  21850. * @returns a new MorphTarget
  21851. */
  21852. static Parse(serializationObject: any): MorphTarget;
  21853. /**
  21854. * Creates a MorphTarget from mesh data
  21855. * @param mesh defines the source mesh
  21856. * @param name defines the name to use for the new target
  21857. * @param influence defines the influence to attach to the target
  21858. * @returns a new MorphTarget
  21859. */
  21860. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  21861. }
  21862. }
  21863. declare module BABYLON {
  21864. /**
  21865. * This class is used to deform meshes using morphing between different targets
  21866. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21867. */
  21868. export class MorphTargetManager {
  21869. private _targets;
  21870. private _targetInfluenceChangedObservers;
  21871. private _targetDataLayoutChangedObservers;
  21872. private _activeTargets;
  21873. private _scene;
  21874. private _influences;
  21875. private _supportsNormals;
  21876. private _supportsTangents;
  21877. private _supportsUVs;
  21878. private _vertexCount;
  21879. private _uniqueId;
  21880. private _tempInfluences;
  21881. /**
  21882. * Gets or sets a boolean indicating if normals must be morphed
  21883. */
  21884. enableNormalMorphing: boolean;
  21885. /**
  21886. * Gets or sets a boolean indicating if tangents must be morphed
  21887. */
  21888. enableTangentMorphing: boolean;
  21889. /**
  21890. * Gets or sets a boolean indicating if UV must be morphed
  21891. */
  21892. enableUVMorphing: boolean;
  21893. /**
  21894. * Creates a new MorphTargetManager
  21895. * @param scene defines the current scene
  21896. */
  21897. constructor(scene?: Nullable<Scene>);
  21898. /**
  21899. * Gets the unique ID of this manager
  21900. */
  21901. readonly uniqueId: number;
  21902. /**
  21903. * Gets the number of vertices handled by this manager
  21904. */
  21905. readonly vertexCount: number;
  21906. /**
  21907. * Gets a boolean indicating if this manager supports morphing of normals
  21908. */
  21909. readonly supportsNormals: boolean;
  21910. /**
  21911. * Gets a boolean indicating if this manager supports morphing of tangents
  21912. */
  21913. readonly supportsTangents: boolean;
  21914. /**
  21915. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  21916. */
  21917. readonly supportsUVs: boolean;
  21918. /**
  21919. * Gets the number of targets stored in this manager
  21920. */
  21921. readonly numTargets: number;
  21922. /**
  21923. * Gets the number of influencers (ie. the number of targets with influences > 0)
  21924. */
  21925. readonly numInfluencers: number;
  21926. /**
  21927. * Gets the list of influences (one per target)
  21928. */
  21929. readonly influences: Float32Array;
  21930. /**
  21931. * Gets the active target at specified index. An active target is a target with an influence > 0
  21932. * @param index defines the index to check
  21933. * @returns the requested target
  21934. */
  21935. getActiveTarget(index: number): MorphTarget;
  21936. /**
  21937. * Gets the target at specified index
  21938. * @param index defines the index to check
  21939. * @returns the requested target
  21940. */
  21941. getTarget(index: number): MorphTarget;
  21942. /**
  21943. * Add a new target to this manager
  21944. * @param target defines the target to add
  21945. */
  21946. addTarget(target: MorphTarget): void;
  21947. /**
  21948. * Removes a target from the manager
  21949. * @param target defines the target to remove
  21950. */
  21951. removeTarget(target: MorphTarget): void;
  21952. /**
  21953. * Serializes the current manager into a Serialization object
  21954. * @returns the serialized object
  21955. */
  21956. serialize(): any;
  21957. private _syncActiveTargets;
  21958. /**
  21959. * Syncrhonize the targets with all the meshes using this morph target manager
  21960. */
  21961. synchronize(): void;
  21962. /**
  21963. * Creates a new MorphTargetManager from serialized data
  21964. * @param serializationObject defines the serialized data
  21965. * @param scene defines the hosting scene
  21966. * @returns the new MorphTargetManager
  21967. */
  21968. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  21969. }
  21970. }
  21971. declare module BABYLON {
  21972. /**
  21973. * Class used to represent a specific level of detail of a mesh
  21974. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21975. */
  21976. export class MeshLODLevel {
  21977. /** Defines the distance where this level should star being displayed */
  21978. distance: number;
  21979. /** Defines the mesh to use to render this level */
  21980. mesh: Nullable<Mesh>;
  21981. /**
  21982. * Creates a new LOD level
  21983. * @param distance defines the distance where this level should star being displayed
  21984. * @param mesh defines the mesh to use to render this level
  21985. */
  21986. constructor(
  21987. /** Defines the distance where this level should star being displayed */
  21988. distance: number,
  21989. /** Defines the mesh to use to render this level */
  21990. mesh: Nullable<Mesh>);
  21991. }
  21992. }
  21993. declare module BABYLON {
  21994. /**
  21995. * Mesh representing the gorund
  21996. */
  21997. export class GroundMesh extends Mesh {
  21998. /** If octree should be generated */
  21999. generateOctree: boolean;
  22000. private _heightQuads;
  22001. /** @hidden */
  22002. _subdivisionsX: number;
  22003. /** @hidden */
  22004. _subdivisionsY: number;
  22005. /** @hidden */
  22006. _width: number;
  22007. /** @hidden */
  22008. _height: number;
  22009. /** @hidden */
  22010. _minX: number;
  22011. /** @hidden */
  22012. _maxX: number;
  22013. /** @hidden */
  22014. _minZ: number;
  22015. /** @hidden */
  22016. _maxZ: number;
  22017. constructor(name: string, scene: Scene);
  22018. /**
  22019. * "GroundMesh"
  22020. * @returns "GroundMesh"
  22021. */
  22022. getClassName(): string;
  22023. /**
  22024. * The minimum of x and y subdivisions
  22025. */
  22026. readonly subdivisions: number;
  22027. /**
  22028. * X subdivisions
  22029. */
  22030. readonly subdivisionsX: number;
  22031. /**
  22032. * Y subdivisions
  22033. */
  22034. readonly subdivisionsY: number;
  22035. /**
  22036. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22037. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22038. * @param chunksCount the number of subdivisions for x and y
  22039. * @param octreeBlocksSize (Default: 32)
  22040. */
  22041. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22042. /**
  22043. * Returns a height (y) value in the Worl system :
  22044. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22045. * @param x x coordinate
  22046. * @param z z coordinate
  22047. * @returns the ground y position if (x, z) are outside the ground surface.
  22048. */
  22049. getHeightAtCoordinates(x: number, z: number): number;
  22050. /**
  22051. * Returns a normalized vector (Vector3) orthogonal to the ground
  22052. * at the ground coordinates (x, z) expressed in the World system.
  22053. * @param x x coordinate
  22054. * @param z z coordinate
  22055. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22056. */
  22057. getNormalAtCoordinates(x: number, z: number): Vector3;
  22058. /**
  22059. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22060. * at the ground coordinates (x, z) expressed in the World system.
  22061. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22062. * @param x x coordinate
  22063. * @param z z coordinate
  22064. * @param ref vector to store the result
  22065. * @returns the GroundMesh.
  22066. */
  22067. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22068. /**
  22069. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22070. * if the ground has been updated.
  22071. * This can be used in the render loop.
  22072. * @returns the GroundMesh.
  22073. */
  22074. updateCoordinateHeights(): GroundMesh;
  22075. private _getFacetAt;
  22076. private _initHeightQuads;
  22077. private _computeHeightQuads;
  22078. /**
  22079. * Serializes this ground mesh
  22080. * @param serializationObject object to write serialization to
  22081. */
  22082. serialize(serializationObject: any): void;
  22083. /**
  22084. * Parses a serialized ground mesh
  22085. * @param parsedMesh the serialized mesh
  22086. * @param scene the scene to create the ground mesh in
  22087. * @returns the created ground mesh
  22088. */
  22089. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22090. }
  22091. }
  22092. declare module BABYLON {
  22093. /**
  22094. * Interface for Physics-Joint data
  22095. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22096. */
  22097. export interface PhysicsJointData {
  22098. /**
  22099. * The main pivot of the joint
  22100. */
  22101. mainPivot?: Vector3;
  22102. /**
  22103. * The connected pivot of the joint
  22104. */
  22105. connectedPivot?: Vector3;
  22106. /**
  22107. * The main axis of the joint
  22108. */
  22109. mainAxis?: Vector3;
  22110. /**
  22111. * The connected axis of the joint
  22112. */
  22113. connectedAxis?: Vector3;
  22114. /**
  22115. * The collision of the joint
  22116. */
  22117. collision?: boolean;
  22118. /**
  22119. * Native Oimo/Cannon/Energy data
  22120. */
  22121. nativeParams?: any;
  22122. }
  22123. /**
  22124. * This is a holder class for the physics joint created by the physics plugin
  22125. * It holds a set of functions to control the underlying joint
  22126. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22127. */
  22128. export class PhysicsJoint {
  22129. /**
  22130. * The type of the physics joint
  22131. */
  22132. type: number;
  22133. /**
  22134. * The data for the physics joint
  22135. */
  22136. jointData: PhysicsJointData;
  22137. private _physicsJoint;
  22138. protected _physicsPlugin: IPhysicsEnginePlugin;
  22139. /**
  22140. * Initializes the physics joint
  22141. * @param type The type of the physics joint
  22142. * @param jointData The data for the physics joint
  22143. */
  22144. constructor(
  22145. /**
  22146. * The type of the physics joint
  22147. */
  22148. type: number,
  22149. /**
  22150. * The data for the physics joint
  22151. */
  22152. jointData: PhysicsJointData);
  22153. /**
  22154. * Gets the physics joint
  22155. */
  22156. /**
  22157. * Sets the physics joint
  22158. */
  22159. physicsJoint: any;
  22160. /**
  22161. * Sets the physics plugin
  22162. */
  22163. physicsPlugin: IPhysicsEnginePlugin;
  22164. /**
  22165. * Execute a function that is physics-plugin specific.
  22166. * @param {Function} func the function that will be executed.
  22167. * It accepts two parameters: the physics world and the physics joint
  22168. */
  22169. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22170. /**
  22171. * Distance-Joint type
  22172. */
  22173. static DistanceJoint: number;
  22174. /**
  22175. * Hinge-Joint type
  22176. */
  22177. static HingeJoint: number;
  22178. /**
  22179. * Ball-and-Socket joint type
  22180. */
  22181. static BallAndSocketJoint: number;
  22182. /**
  22183. * Wheel-Joint type
  22184. */
  22185. static WheelJoint: number;
  22186. /**
  22187. * Slider-Joint type
  22188. */
  22189. static SliderJoint: number;
  22190. /**
  22191. * Prismatic-Joint type
  22192. */
  22193. static PrismaticJoint: number;
  22194. /**
  22195. * Universal-Joint type
  22196. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22197. */
  22198. static UniversalJoint: number;
  22199. /**
  22200. * Hinge-Joint 2 type
  22201. */
  22202. static Hinge2Joint: number;
  22203. /**
  22204. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22205. */
  22206. static PointToPointJoint: number;
  22207. /**
  22208. * Spring-Joint type
  22209. */
  22210. static SpringJoint: number;
  22211. /**
  22212. * Lock-Joint type
  22213. */
  22214. static LockJoint: number;
  22215. }
  22216. /**
  22217. * A class representing a physics distance joint
  22218. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22219. */
  22220. export class DistanceJoint extends PhysicsJoint {
  22221. /**
  22222. *
  22223. * @param jointData The data for the Distance-Joint
  22224. */
  22225. constructor(jointData: DistanceJointData);
  22226. /**
  22227. * Update the predefined distance.
  22228. * @param maxDistance The maximum preferred distance
  22229. * @param minDistance The minimum preferred distance
  22230. */
  22231. updateDistance(maxDistance: number, minDistance?: number): void;
  22232. }
  22233. /**
  22234. * Represents a Motor-Enabled Joint
  22235. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22236. */
  22237. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22238. /**
  22239. * Initializes the Motor-Enabled Joint
  22240. * @param type The type of the joint
  22241. * @param jointData The physica joint data for the joint
  22242. */
  22243. constructor(type: number, jointData: PhysicsJointData);
  22244. /**
  22245. * Set the motor values.
  22246. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22247. * @param force the force to apply
  22248. * @param maxForce max force for this motor.
  22249. */
  22250. setMotor(force?: number, maxForce?: number): void;
  22251. /**
  22252. * Set the motor's limits.
  22253. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22254. * @param upperLimit The upper limit of the motor
  22255. * @param lowerLimit The lower limit of the motor
  22256. */
  22257. setLimit(upperLimit: number, lowerLimit?: number): void;
  22258. }
  22259. /**
  22260. * This class represents a single physics Hinge-Joint
  22261. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22262. */
  22263. export class HingeJoint extends MotorEnabledJoint {
  22264. /**
  22265. * Initializes the Hinge-Joint
  22266. * @param jointData The joint data for the Hinge-Joint
  22267. */
  22268. constructor(jointData: PhysicsJointData);
  22269. /**
  22270. * Set the motor values.
  22271. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22272. * @param {number} force the force to apply
  22273. * @param {number} maxForce max force for this motor.
  22274. */
  22275. setMotor(force?: number, maxForce?: number): void;
  22276. /**
  22277. * Set the motor's limits.
  22278. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22279. * @param upperLimit The upper limit of the motor
  22280. * @param lowerLimit The lower limit of the motor
  22281. */
  22282. setLimit(upperLimit: number, lowerLimit?: number): void;
  22283. }
  22284. /**
  22285. * This class represents a dual hinge physics joint (same as wheel joint)
  22286. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22287. */
  22288. export class Hinge2Joint extends MotorEnabledJoint {
  22289. /**
  22290. * Initializes the Hinge2-Joint
  22291. * @param jointData The joint data for the Hinge2-Joint
  22292. */
  22293. constructor(jointData: PhysicsJointData);
  22294. /**
  22295. * Set the motor values.
  22296. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22297. * @param {number} targetSpeed the speed the motor is to reach
  22298. * @param {number} maxForce max force for this motor.
  22299. * @param {motorIndex} the motor's index, 0 or 1.
  22300. */
  22301. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22302. /**
  22303. * Set the motor limits.
  22304. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22305. * @param {number} upperLimit the upper limit
  22306. * @param {number} lowerLimit lower limit
  22307. * @param {motorIndex} the motor's index, 0 or 1.
  22308. */
  22309. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22310. }
  22311. /**
  22312. * Interface for a motor enabled joint
  22313. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22314. */
  22315. export interface IMotorEnabledJoint {
  22316. /**
  22317. * Physics joint
  22318. */
  22319. physicsJoint: any;
  22320. /**
  22321. * Sets the motor of the motor-enabled joint
  22322. * @param force The force of the motor
  22323. * @param maxForce The maximum force of the motor
  22324. * @param motorIndex The index of the motor
  22325. */
  22326. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22327. /**
  22328. * Sets the limit of the motor
  22329. * @param upperLimit The upper limit of the motor
  22330. * @param lowerLimit The lower limit of the motor
  22331. * @param motorIndex The index of the motor
  22332. */
  22333. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22334. }
  22335. /**
  22336. * Joint data for a Distance-Joint
  22337. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22338. */
  22339. export interface DistanceJointData extends PhysicsJointData {
  22340. /**
  22341. * Max distance the 2 joint objects can be apart
  22342. */
  22343. maxDistance: number;
  22344. }
  22345. /**
  22346. * Joint data from a spring joint
  22347. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22348. */
  22349. export interface SpringJointData extends PhysicsJointData {
  22350. /**
  22351. * Length of the spring
  22352. */
  22353. length: number;
  22354. /**
  22355. * Stiffness of the spring
  22356. */
  22357. stiffness: number;
  22358. /**
  22359. * Damping of the spring
  22360. */
  22361. damping: number;
  22362. /** this callback will be called when applying the force to the impostors. */
  22363. forceApplicationCallback: () => void;
  22364. }
  22365. }
  22366. declare module BABYLON {
  22367. /**
  22368. * Holds the data for the raycast result
  22369. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22370. */
  22371. export class PhysicsRaycastResult {
  22372. private _hasHit;
  22373. private _hitDistance;
  22374. private _hitNormalWorld;
  22375. private _hitPointWorld;
  22376. private _rayFromWorld;
  22377. private _rayToWorld;
  22378. /**
  22379. * Gets if there was a hit
  22380. */
  22381. readonly hasHit: boolean;
  22382. /**
  22383. * Gets the distance from the hit
  22384. */
  22385. readonly hitDistance: number;
  22386. /**
  22387. * Gets the hit normal/direction in the world
  22388. */
  22389. readonly hitNormalWorld: Vector3;
  22390. /**
  22391. * Gets the hit point in the world
  22392. */
  22393. readonly hitPointWorld: Vector3;
  22394. /**
  22395. * Gets the ray "start point" of the ray in the world
  22396. */
  22397. readonly rayFromWorld: Vector3;
  22398. /**
  22399. * Gets the ray "end point" of the ray in the world
  22400. */
  22401. readonly rayToWorld: Vector3;
  22402. /**
  22403. * Sets the hit data (normal & point in world space)
  22404. * @param hitNormalWorld defines the normal in world space
  22405. * @param hitPointWorld defines the point in world space
  22406. */
  22407. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22408. /**
  22409. * Sets the distance from the start point to the hit point
  22410. * @param distance
  22411. */
  22412. setHitDistance(distance: number): void;
  22413. /**
  22414. * Calculates the distance manually
  22415. */
  22416. calculateHitDistance(): void;
  22417. /**
  22418. * Resets all the values to default
  22419. * @param from The from point on world space
  22420. * @param to The to point on world space
  22421. */
  22422. reset(from?: Vector3, to?: Vector3): void;
  22423. }
  22424. /**
  22425. * Interface for the size containing width and height
  22426. */
  22427. interface IXYZ {
  22428. /**
  22429. * X
  22430. */
  22431. x: number;
  22432. /**
  22433. * Y
  22434. */
  22435. y: number;
  22436. /**
  22437. * Z
  22438. */
  22439. z: number;
  22440. }
  22441. }
  22442. declare module BABYLON {
  22443. /**
  22444. * Interface used to describe a physics joint
  22445. */
  22446. export interface PhysicsImpostorJoint {
  22447. /** Defines the main impostor to which the joint is linked */
  22448. mainImpostor: PhysicsImpostor;
  22449. /** Defines the impostor that is connected to the main impostor using this joint */
  22450. connectedImpostor: PhysicsImpostor;
  22451. /** Defines the joint itself */
  22452. joint: PhysicsJoint;
  22453. }
  22454. /** @hidden */
  22455. export interface IPhysicsEnginePlugin {
  22456. world: any;
  22457. name: string;
  22458. setGravity(gravity: Vector3): void;
  22459. setTimeStep(timeStep: number): void;
  22460. getTimeStep(): number;
  22461. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22462. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22463. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22464. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22465. removePhysicsBody(impostor: PhysicsImpostor): void;
  22466. generateJoint(joint: PhysicsImpostorJoint): void;
  22467. removeJoint(joint: PhysicsImpostorJoint): void;
  22468. isSupported(): boolean;
  22469. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22470. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22471. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22472. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22473. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22474. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22475. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22476. getBodyMass(impostor: PhysicsImpostor): number;
  22477. getBodyFriction(impostor: PhysicsImpostor): number;
  22478. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22479. getBodyRestitution(impostor: PhysicsImpostor): number;
  22480. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22481. getBodyPressure?(impostor: PhysicsImpostor): number;
  22482. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22483. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22484. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22485. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22486. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22487. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22488. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22489. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22490. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22491. sleepBody(impostor: PhysicsImpostor): void;
  22492. wakeUpBody(impostor: PhysicsImpostor): void;
  22493. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22494. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22495. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22496. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22497. getRadius(impostor: PhysicsImpostor): number;
  22498. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22499. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22500. dispose(): void;
  22501. }
  22502. /**
  22503. * Interface used to define a physics engine
  22504. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22505. */
  22506. export interface IPhysicsEngine {
  22507. /**
  22508. * Gets the gravity vector used by the simulation
  22509. */
  22510. gravity: Vector3;
  22511. /**
  22512. * Sets the gravity vector used by the simulation
  22513. * @param gravity defines the gravity vector to use
  22514. */
  22515. setGravity(gravity: Vector3): void;
  22516. /**
  22517. * Set the time step of the physics engine.
  22518. * Default is 1/60.
  22519. * To slow it down, enter 1/600 for example.
  22520. * To speed it up, 1/30
  22521. * @param newTimeStep the new timestep to apply to this world.
  22522. */
  22523. setTimeStep(newTimeStep: number): void;
  22524. /**
  22525. * Get the time step of the physics engine.
  22526. * @returns the current time step
  22527. */
  22528. getTimeStep(): number;
  22529. /**
  22530. * Release all resources
  22531. */
  22532. dispose(): void;
  22533. /**
  22534. * Gets the name of the current physics plugin
  22535. * @returns the name of the plugin
  22536. */
  22537. getPhysicsPluginName(): string;
  22538. /**
  22539. * Adding a new impostor for the impostor tracking.
  22540. * This will be done by the impostor itself.
  22541. * @param impostor the impostor to add
  22542. */
  22543. addImpostor(impostor: PhysicsImpostor): void;
  22544. /**
  22545. * Remove an impostor from the engine.
  22546. * This impostor and its mesh will not longer be updated by the physics engine.
  22547. * @param impostor the impostor to remove
  22548. */
  22549. removeImpostor(impostor: PhysicsImpostor): void;
  22550. /**
  22551. * Add a joint to the physics engine
  22552. * @param mainImpostor defines the main impostor to which the joint is added.
  22553. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22554. * @param joint defines the joint that will connect both impostors.
  22555. */
  22556. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22557. /**
  22558. * Removes a joint from the simulation
  22559. * @param mainImpostor defines the impostor used with the joint
  22560. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22561. * @param joint defines the joint to remove
  22562. */
  22563. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22564. /**
  22565. * Gets the current plugin used to run the simulation
  22566. * @returns current plugin
  22567. */
  22568. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22569. /**
  22570. * Gets the list of physic impostors
  22571. * @returns an array of PhysicsImpostor
  22572. */
  22573. getImpostors(): Array<PhysicsImpostor>;
  22574. /**
  22575. * Gets the impostor for a physics enabled object
  22576. * @param object defines the object impersonated by the impostor
  22577. * @returns the PhysicsImpostor or null if not found
  22578. */
  22579. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22580. /**
  22581. * Gets the impostor for a physics body object
  22582. * @param body defines physics body used by the impostor
  22583. * @returns the PhysicsImpostor or null if not found
  22584. */
  22585. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22586. /**
  22587. * Does a raycast in the physics world
  22588. * @param from when should the ray start?
  22589. * @param to when should the ray end?
  22590. * @returns PhysicsRaycastResult
  22591. */
  22592. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22593. /**
  22594. * Called by the scene. No need to call it.
  22595. * @param delta defines the timespam between frames
  22596. */
  22597. _step(delta: number): void;
  22598. }
  22599. }
  22600. declare module BABYLON {
  22601. /**
  22602. * The interface for the physics imposter parameters
  22603. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22604. */
  22605. export interface PhysicsImpostorParameters {
  22606. /**
  22607. * The mass of the physics imposter
  22608. */
  22609. mass: number;
  22610. /**
  22611. * The friction of the physics imposter
  22612. */
  22613. friction?: number;
  22614. /**
  22615. * The coefficient of restitution of the physics imposter
  22616. */
  22617. restitution?: number;
  22618. /**
  22619. * The native options of the physics imposter
  22620. */
  22621. nativeOptions?: any;
  22622. /**
  22623. * Specifies if the parent should be ignored
  22624. */
  22625. ignoreParent?: boolean;
  22626. /**
  22627. * Specifies if bi-directional transformations should be disabled
  22628. */
  22629. disableBidirectionalTransformation?: boolean;
  22630. /**
  22631. * The pressure inside the physics imposter, soft object only
  22632. */
  22633. pressure?: number;
  22634. /**
  22635. * The stiffness the physics imposter, soft object only
  22636. */
  22637. stiffness?: number;
  22638. /**
  22639. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22640. */
  22641. velocityIterations?: number;
  22642. /**
  22643. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22644. */
  22645. positionIterations?: number;
  22646. /**
  22647. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22648. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22649. * Add to fix multiple points
  22650. */
  22651. fixedPoints?: number;
  22652. /**
  22653. * The collision margin around a soft object
  22654. */
  22655. margin?: number;
  22656. /**
  22657. * The collision margin around a soft object
  22658. */
  22659. damping?: number;
  22660. /**
  22661. * The path for a rope based on an extrusion
  22662. */
  22663. path?: any;
  22664. /**
  22665. * The shape of an extrusion used for a rope based on an extrusion
  22666. */
  22667. shape?: any;
  22668. }
  22669. /**
  22670. * Interface for a physics-enabled object
  22671. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22672. */
  22673. export interface IPhysicsEnabledObject {
  22674. /**
  22675. * The position of the physics-enabled object
  22676. */
  22677. position: Vector3;
  22678. /**
  22679. * The rotation of the physics-enabled object
  22680. */
  22681. rotationQuaternion: Nullable<Quaternion>;
  22682. /**
  22683. * The scale of the physics-enabled object
  22684. */
  22685. scaling: Vector3;
  22686. /**
  22687. * The rotation of the physics-enabled object
  22688. */
  22689. rotation?: Vector3;
  22690. /**
  22691. * The parent of the physics-enabled object
  22692. */
  22693. parent?: any;
  22694. /**
  22695. * The bounding info of the physics-enabled object
  22696. * @returns The bounding info of the physics-enabled object
  22697. */
  22698. getBoundingInfo(): BoundingInfo;
  22699. /**
  22700. * Computes the world matrix
  22701. * @param force Specifies if the world matrix should be computed by force
  22702. * @returns A world matrix
  22703. */
  22704. computeWorldMatrix(force: boolean): Matrix;
  22705. /**
  22706. * Gets the world matrix
  22707. * @returns A world matrix
  22708. */
  22709. getWorldMatrix?(): Matrix;
  22710. /**
  22711. * Gets the child meshes
  22712. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22713. * @returns An array of abstract meshes
  22714. */
  22715. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22716. /**
  22717. * Gets the vertex data
  22718. * @param kind The type of vertex data
  22719. * @returns A nullable array of numbers, or a float32 array
  22720. */
  22721. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22722. /**
  22723. * Gets the indices from the mesh
  22724. * @returns A nullable array of index arrays
  22725. */
  22726. getIndices?(): Nullable<IndicesArray>;
  22727. /**
  22728. * Gets the scene from the mesh
  22729. * @returns the indices array or null
  22730. */
  22731. getScene?(): Scene;
  22732. /**
  22733. * Gets the absolute position from the mesh
  22734. * @returns the absolute position
  22735. */
  22736. getAbsolutePosition(): Vector3;
  22737. /**
  22738. * Gets the absolute pivot point from the mesh
  22739. * @returns the absolute pivot point
  22740. */
  22741. getAbsolutePivotPoint(): Vector3;
  22742. /**
  22743. * Rotates the mesh
  22744. * @param axis The axis of rotation
  22745. * @param amount The amount of rotation
  22746. * @param space The space of the rotation
  22747. * @returns The rotation transform node
  22748. */
  22749. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22750. /**
  22751. * Translates the mesh
  22752. * @param axis The axis of translation
  22753. * @param distance The distance of translation
  22754. * @param space The space of the translation
  22755. * @returns The transform node
  22756. */
  22757. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22758. /**
  22759. * Sets the absolute position of the mesh
  22760. * @param absolutePosition The absolute position of the mesh
  22761. * @returns The transform node
  22762. */
  22763. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22764. /**
  22765. * Gets the class name of the mesh
  22766. * @returns The class name
  22767. */
  22768. getClassName(): string;
  22769. }
  22770. /**
  22771. * Represents a physics imposter
  22772. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22773. */
  22774. export class PhysicsImpostor {
  22775. /**
  22776. * The physics-enabled object used as the physics imposter
  22777. */
  22778. object: IPhysicsEnabledObject;
  22779. /**
  22780. * The type of the physics imposter
  22781. */
  22782. type: number;
  22783. private _options;
  22784. private _scene?;
  22785. /**
  22786. * The default object size of the imposter
  22787. */
  22788. static DEFAULT_OBJECT_SIZE: Vector3;
  22789. /**
  22790. * The identity quaternion of the imposter
  22791. */
  22792. static IDENTITY_QUATERNION: Quaternion;
  22793. /** @hidden */
  22794. _pluginData: any;
  22795. private _physicsEngine;
  22796. private _physicsBody;
  22797. private _bodyUpdateRequired;
  22798. private _onBeforePhysicsStepCallbacks;
  22799. private _onAfterPhysicsStepCallbacks;
  22800. /** @hidden */
  22801. _onPhysicsCollideCallbacks: Array<{
  22802. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  22803. otherImpostors: Array<PhysicsImpostor>;
  22804. }>;
  22805. private _deltaPosition;
  22806. private _deltaRotation;
  22807. private _deltaRotationConjugated;
  22808. /** @hidden */
  22809. _isFromLine: boolean;
  22810. private _parent;
  22811. private _isDisposed;
  22812. private static _tmpVecs;
  22813. private static _tmpQuat;
  22814. /**
  22815. * Specifies if the physics imposter is disposed
  22816. */
  22817. readonly isDisposed: boolean;
  22818. /**
  22819. * Gets the mass of the physics imposter
  22820. */
  22821. mass: number;
  22822. /**
  22823. * Gets the coefficient of friction
  22824. */
  22825. /**
  22826. * Sets the coefficient of friction
  22827. */
  22828. friction: number;
  22829. /**
  22830. * Gets the coefficient of restitution
  22831. */
  22832. /**
  22833. * Sets the coefficient of restitution
  22834. */
  22835. restitution: number;
  22836. /**
  22837. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  22838. */
  22839. /**
  22840. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  22841. */
  22842. pressure: number;
  22843. /**
  22844. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22845. */
  22846. /**
  22847. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22848. */
  22849. stiffness: number;
  22850. /**
  22851. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22852. */
  22853. /**
  22854. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22855. */
  22856. velocityIterations: number;
  22857. /**
  22858. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22859. */
  22860. /**
  22861. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22862. */
  22863. positionIterations: number;
  22864. /**
  22865. * The unique id of the physics imposter
  22866. * set by the physics engine when adding this impostor to the array
  22867. */
  22868. uniqueId: number;
  22869. /**
  22870. * @hidden
  22871. */
  22872. soft: boolean;
  22873. /**
  22874. * @hidden
  22875. */
  22876. segments: number;
  22877. private _joints;
  22878. /**
  22879. * Initializes the physics imposter
  22880. * @param object The physics-enabled object used as the physics imposter
  22881. * @param type The type of the physics imposter
  22882. * @param _options The options for the physics imposter
  22883. * @param _scene The Babylon scene
  22884. */
  22885. constructor(
  22886. /**
  22887. * The physics-enabled object used as the physics imposter
  22888. */
  22889. object: IPhysicsEnabledObject,
  22890. /**
  22891. * The type of the physics imposter
  22892. */
  22893. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  22894. /**
  22895. * This function will completly initialize this impostor.
  22896. * It will create a new body - but only if this mesh has no parent.
  22897. * If it has, this impostor will not be used other than to define the impostor
  22898. * of the child mesh.
  22899. * @hidden
  22900. */
  22901. _init(): void;
  22902. private _getPhysicsParent;
  22903. /**
  22904. * Should a new body be generated.
  22905. * @returns boolean specifying if body initialization is required
  22906. */
  22907. isBodyInitRequired(): boolean;
  22908. /**
  22909. * Sets the updated scaling
  22910. * @param updated Specifies if the scaling is updated
  22911. */
  22912. setScalingUpdated(): void;
  22913. /**
  22914. * Force a regeneration of this or the parent's impostor's body.
  22915. * Use under cautious - This will remove all joints already implemented.
  22916. */
  22917. forceUpdate(): void;
  22918. /**
  22919. * Gets the body that holds this impostor. Either its own, or its parent.
  22920. */
  22921. /**
  22922. * Set the physics body. Used mainly by the physics engine/plugin
  22923. */
  22924. physicsBody: any;
  22925. /**
  22926. * Get the parent of the physics imposter
  22927. * @returns Physics imposter or null
  22928. */
  22929. /**
  22930. * Sets the parent of the physics imposter
  22931. */
  22932. parent: Nullable<PhysicsImpostor>;
  22933. /**
  22934. * Resets the update flags
  22935. */
  22936. resetUpdateFlags(): void;
  22937. /**
  22938. * Gets the object extend size
  22939. * @returns the object extend size
  22940. */
  22941. getObjectExtendSize(): Vector3;
  22942. /**
  22943. * Gets the object center
  22944. * @returns The object center
  22945. */
  22946. getObjectCenter(): Vector3;
  22947. /**
  22948. * Get a specific parametes from the options parameter
  22949. * @param paramName The object parameter name
  22950. * @returns The object parameter
  22951. */
  22952. getParam(paramName: string): any;
  22953. /**
  22954. * Sets a specific parameter in the options given to the physics plugin
  22955. * @param paramName The parameter name
  22956. * @param value The value of the parameter
  22957. */
  22958. setParam(paramName: string, value: number): void;
  22959. /**
  22960. * Specifically change the body's mass option. Won't recreate the physics body object
  22961. * @param mass The mass of the physics imposter
  22962. */
  22963. setMass(mass: number): void;
  22964. /**
  22965. * Gets the linear velocity
  22966. * @returns linear velocity or null
  22967. */
  22968. getLinearVelocity(): Nullable<Vector3>;
  22969. /**
  22970. * Sets the linear velocity
  22971. * @param velocity linear velocity or null
  22972. */
  22973. setLinearVelocity(velocity: Nullable<Vector3>): void;
  22974. /**
  22975. * Gets the angular velocity
  22976. * @returns angular velocity or null
  22977. */
  22978. getAngularVelocity(): Nullable<Vector3>;
  22979. /**
  22980. * Sets the angular velocity
  22981. * @param velocity The velocity or null
  22982. */
  22983. setAngularVelocity(velocity: Nullable<Vector3>): void;
  22984. /**
  22985. * Execute a function with the physics plugin native code
  22986. * Provide a function the will have two variables - the world object and the physics body object
  22987. * @param func The function to execute with the physics plugin native code
  22988. */
  22989. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  22990. /**
  22991. * Register a function that will be executed before the physics world is stepping forward
  22992. * @param func The function to execute before the physics world is stepped forward
  22993. */
  22994. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22995. /**
  22996. * Unregister a function that will be executed before the physics world is stepping forward
  22997. * @param func The function to execute before the physics world is stepped forward
  22998. */
  22999. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23000. /**
  23001. * Register a function that will be executed after the physics step
  23002. * @param func The function to execute after physics step
  23003. */
  23004. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23005. /**
  23006. * Unregisters a function that will be executed after the physics step
  23007. * @param func The function to execute after physics step
  23008. */
  23009. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23010. /**
  23011. * register a function that will be executed when this impostor collides against a different body
  23012. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23013. * @param func Callback that is executed on collision
  23014. */
  23015. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23016. /**
  23017. * Unregisters the physics imposter on contact
  23018. * @param collideAgainst The physics object to collide against
  23019. * @param func Callback to execute on collision
  23020. */
  23021. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23022. private _tmpQuat;
  23023. private _tmpQuat2;
  23024. /**
  23025. * Get the parent rotation
  23026. * @returns The parent rotation
  23027. */
  23028. getParentsRotation(): Quaternion;
  23029. /**
  23030. * this function is executed by the physics engine.
  23031. */
  23032. beforeStep: () => void;
  23033. /**
  23034. * this function is executed by the physics engine
  23035. */
  23036. afterStep: () => void;
  23037. /**
  23038. * Legacy collision detection event support
  23039. */
  23040. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23041. /**
  23042. * event and body object due to cannon's event-based architecture.
  23043. */
  23044. onCollide: (e: {
  23045. body: any;
  23046. }) => void;
  23047. /**
  23048. * Apply a force
  23049. * @param force The force to apply
  23050. * @param contactPoint The contact point for the force
  23051. * @returns The physics imposter
  23052. */
  23053. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23054. /**
  23055. * Apply an impulse
  23056. * @param force The impulse force
  23057. * @param contactPoint The contact point for the impulse force
  23058. * @returns The physics imposter
  23059. */
  23060. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23061. /**
  23062. * A help function to create a joint
  23063. * @param otherImpostor A physics imposter used to create a joint
  23064. * @param jointType The type of joint
  23065. * @param jointData The data for the joint
  23066. * @returns The physics imposter
  23067. */
  23068. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23069. /**
  23070. * Add a joint to this impostor with a different impostor
  23071. * @param otherImpostor A physics imposter used to add a joint
  23072. * @param joint The joint to add
  23073. * @returns The physics imposter
  23074. */
  23075. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23076. /**
  23077. * Add an anchor to a cloth impostor
  23078. * @param otherImpostor rigid impostor to anchor to
  23079. * @param width ratio across width from 0 to 1
  23080. * @param height ratio up height from 0 to 1
  23081. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23082. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23083. * @returns impostor the soft imposter
  23084. */
  23085. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23086. /**
  23087. * Add a hook to a rope impostor
  23088. * @param otherImpostor rigid impostor to anchor to
  23089. * @param length ratio across rope from 0 to 1
  23090. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23091. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23092. * @returns impostor the rope imposter
  23093. */
  23094. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23095. /**
  23096. * Will keep this body still, in a sleep mode.
  23097. * @returns the physics imposter
  23098. */
  23099. sleep(): PhysicsImpostor;
  23100. /**
  23101. * Wake the body up.
  23102. * @returns The physics imposter
  23103. */
  23104. wakeUp(): PhysicsImpostor;
  23105. /**
  23106. * Clones the physics imposter
  23107. * @param newObject The physics imposter clones to this physics-enabled object
  23108. * @returns A nullable physics imposter
  23109. */
  23110. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23111. /**
  23112. * Disposes the physics imposter
  23113. */
  23114. dispose(): void;
  23115. /**
  23116. * Sets the delta position
  23117. * @param position The delta position amount
  23118. */
  23119. setDeltaPosition(position: Vector3): void;
  23120. /**
  23121. * Sets the delta rotation
  23122. * @param rotation The delta rotation amount
  23123. */
  23124. setDeltaRotation(rotation: Quaternion): void;
  23125. /**
  23126. * Gets the box size of the physics imposter and stores the result in the input parameter
  23127. * @param result Stores the box size
  23128. * @returns The physics imposter
  23129. */
  23130. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23131. /**
  23132. * Gets the radius of the physics imposter
  23133. * @returns Radius of the physics imposter
  23134. */
  23135. getRadius(): number;
  23136. /**
  23137. * Sync a bone with this impostor
  23138. * @param bone The bone to sync to the impostor.
  23139. * @param boneMesh The mesh that the bone is influencing.
  23140. * @param jointPivot The pivot of the joint / bone in local space.
  23141. * @param distToJoint Optional distance from the impostor to the joint.
  23142. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23143. */
  23144. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23145. /**
  23146. * Sync impostor to a bone
  23147. * @param bone The bone that the impostor will be synced to.
  23148. * @param boneMesh The mesh that the bone is influencing.
  23149. * @param jointPivot The pivot of the joint / bone in local space.
  23150. * @param distToJoint Optional distance from the impostor to the joint.
  23151. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23152. * @param boneAxis Optional vector3 axis the bone is aligned with
  23153. */
  23154. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23155. /**
  23156. * No-Imposter type
  23157. */
  23158. static NoImpostor: number;
  23159. /**
  23160. * Sphere-Imposter type
  23161. */
  23162. static SphereImpostor: number;
  23163. /**
  23164. * Box-Imposter type
  23165. */
  23166. static BoxImpostor: number;
  23167. /**
  23168. * Plane-Imposter type
  23169. */
  23170. static PlaneImpostor: number;
  23171. /**
  23172. * Mesh-imposter type
  23173. */
  23174. static MeshImpostor: number;
  23175. /**
  23176. * Capsule-Impostor type (Ammo.js plugin only)
  23177. */
  23178. static CapsuleImpostor: number;
  23179. /**
  23180. * Cylinder-Imposter type
  23181. */
  23182. static CylinderImpostor: number;
  23183. /**
  23184. * Particle-Imposter type
  23185. */
  23186. static ParticleImpostor: number;
  23187. /**
  23188. * Heightmap-Imposter type
  23189. */
  23190. static HeightmapImpostor: number;
  23191. /**
  23192. * ConvexHull-Impostor type (Ammo.js plugin only)
  23193. */
  23194. static ConvexHullImpostor: number;
  23195. /**
  23196. * Rope-Imposter type
  23197. */
  23198. static RopeImpostor: number;
  23199. /**
  23200. * Cloth-Imposter type
  23201. */
  23202. static ClothImpostor: number;
  23203. /**
  23204. * Softbody-Imposter type
  23205. */
  23206. static SoftbodyImpostor: number;
  23207. }
  23208. }
  23209. declare module BABYLON {
  23210. /**
  23211. * @hidden
  23212. **/
  23213. export class _CreationDataStorage {
  23214. closePath?: boolean;
  23215. closeArray?: boolean;
  23216. idx: number[];
  23217. dashSize: number;
  23218. gapSize: number;
  23219. path3D: Path3D;
  23220. pathArray: Vector3[][];
  23221. arc: number;
  23222. radius: number;
  23223. cap: number;
  23224. tessellation: number;
  23225. }
  23226. /**
  23227. * @hidden
  23228. **/
  23229. class _InstanceDataStorage {
  23230. visibleInstances: any;
  23231. batchCache: _InstancesBatch;
  23232. instancesBufferSize: number;
  23233. instancesBuffer: Nullable<Buffer>;
  23234. instancesData: Float32Array;
  23235. overridenInstanceCount: number;
  23236. isFrozen: boolean;
  23237. previousBatch: Nullable<_InstancesBatch>;
  23238. hardwareInstancedRendering: boolean;
  23239. sideOrientation: number;
  23240. }
  23241. /**
  23242. * @hidden
  23243. **/
  23244. export class _InstancesBatch {
  23245. mustReturn: boolean;
  23246. visibleInstances: Nullable<InstancedMesh[]>[];
  23247. renderSelf: boolean[];
  23248. hardwareInstancedRendering: boolean[];
  23249. }
  23250. /**
  23251. * Class used to represent renderable models
  23252. */
  23253. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23254. /**
  23255. * Mesh side orientation : usually the external or front surface
  23256. */
  23257. static readonly FRONTSIDE: number;
  23258. /**
  23259. * Mesh side orientation : usually the internal or back surface
  23260. */
  23261. static readonly BACKSIDE: number;
  23262. /**
  23263. * Mesh side orientation : both internal and external or front and back surfaces
  23264. */
  23265. static readonly DOUBLESIDE: number;
  23266. /**
  23267. * Mesh side orientation : by default, `FRONTSIDE`
  23268. */
  23269. static readonly DEFAULTSIDE: number;
  23270. /**
  23271. * Mesh cap setting : no cap
  23272. */
  23273. static readonly NO_CAP: number;
  23274. /**
  23275. * Mesh cap setting : one cap at the beginning of the mesh
  23276. */
  23277. static readonly CAP_START: number;
  23278. /**
  23279. * Mesh cap setting : one cap at the end of the mesh
  23280. */
  23281. static readonly CAP_END: number;
  23282. /**
  23283. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23284. */
  23285. static readonly CAP_ALL: number;
  23286. /**
  23287. * Mesh pattern setting : no flip or rotate
  23288. */
  23289. static readonly NO_FLIP: number;
  23290. /**
  23291. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23292. */
  23293. static readonly FLIP_TILE: number;
  23294. /**
  23295. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23296. */
  23297. static readonly ROTATE_TILE: number;
  23298. /**
  23299. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23300. */
  23301. static readonly FLIP_ROW: number;
  23302. /**
  23303. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23304. */
  23305. static readonly ROTATE_ROW: number;
  23306. /**
  23307. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23308. */
  23309. static readonly FLIP_N_ROTATE_TILE: number;
  23310. /**
  23311. * Mesh pattern setting : rotate pattern and rotate
  23312. */
  23313. static readonly FLIP_N_ROTATE_ROW: number;
  23314. /**
  23315. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23316. */
  23317. static readonly CENTER: number;
  23318. /**
  23319. * Mesh tile positioning : part tiles on left
  23320. */
  23321. static readonly LEFT: number;
  23322. /**
  23323. * Mesh tile positioning : part tiles on right
  23324. */
  23325. static readonly RIGHT: number;
  23326. /**
  23327. * Mesh tile positioning : part tiles on top
  23328. */
  23329. static readonly TOP: number;
  23330. /**
  23331. * Mesh tile positioning : part tiles on bottom
  23332. */
  23333. static readonly BOTTOM: number;
  23334. /**
  23335. * Gets the default side orientation.
  23336. * @param orientation the orientation to value to attempt to get
  23337. * @returns the default orientation
  23338. * @hidden
  23339. */
  23340. static _GetDefaultSideOrientation(orientation?: number): number;
  23341. private _internalMeshDataInfo;
  23342. /**
  23343. * An event triggered before rendering the mesh
  23344. */
  23345. readonly onBeforeRenderObservable: Observable<Mesh>;
  23346. /**
  23347. * An event triggered before binding the mesh
  23348. */
  23349. readonly onBeforeBindObservable: Observable<Mesh>;
  23350. /**
  23351. * An event triggered after rendering the mesh
  23352. */
  23353. readonly onAfterRenderObservable: Observable<Mesh>;
  23354. /**
  23355. * An event triggered before drawing the mesh
  23356. */
  23357. readonly onBeforeDrawObservable: Observable<Mesh>;
  23358. private _onBeforeDrawObserver;
  23359. /**
  23360. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23361. */
  23362. onBeforeDraw: () => void;
  23363. readonly hasInstances: boolean;
  23364. /**
  23365. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23366. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23367. */
  23368. delayLoadState: number;
  23369. /**
  23370. * Gets the list of instances created from this mesh
  23371. * it is not supposed to be modified manually.
  23372. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23373. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23374. */
  23375. instances: InstancedMesh[];
  23376. /**
  23377. * Gets the file containing delay loading data for this mesh
  23378. */
  23379. delayLoadingFile: string;
  23380. /** @hidden */
  23381. _binaryInfo: any;
  23382. /**
  23383. * User defined function used to change how LOD level selection is done
  23384. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23385. */
  23386. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23387. /**
  23388. * Gets or sets the morph target manager
  23389. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23390. */
  23391. morphTargetManager: Nullable<MorphTargetManager>;
  23392. /** @hidden */
  23393. _creationDataStorage: Nullable<_CreationDataStorage>;
  23394. /** @hidden */
  23395. _geometry: Nullable<Geometry>;
  23396. /** @hidden */
  23397. _delayInfo: Array<string>;
  23398. /** @hidden */
  23399. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23400. /** @hidden */
  23401. _instanceDataStorage: _InstanceDataStorage;
  23402. private _effectiveMaterial;
  23403. /** @hidden */
  23404. _shouldGenerateFlatShading: boolean;
  23405. /** @hidden */
  23406. _originalBuilderSideOrientation: number;
  23407. /**
  23408. * Use this property to change the original side orientation defined at construction time
  23409. */
  23410. overrideMaterialSideOrientation: Nullable<number>;
  23411. /**
  23412. * Gets the source mesh (the one used to clone this one from)
  23413. */
  23414. readonly source: Nullable<Mesh>;
  23415. /**
  23416. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23417. */
  23418. isUnIndexed: boolean;
  23419. /**
  23420. * @constructor
  23421. * @param name The value used by scene.getMeshByName() to do a lookup.
  23422. * @param scene The scene to add this mesh to.
  23423. * @param parent The parent of this mesh, if it has one
  23424. * @param source An optional Mesh from which geometry is shared, cloned.
  23425. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23426. * When false, achieved by calling a clone(), also passing False.
  23427. * This will make creation of children, recursive.
  23428. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23429. */
  23430. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23431. /**
  23432. * Gets the class name
  23433. * @returns the string "Mesh".
  23434. */
  23435. getClassName(): string;
  23436. /** @hidden */
  23437. readonly _isMesh: boolean;
  23438. /**
  23439. * Returns a description of this mesh
  23440. * @param fullDetails define if full details about this mesh must be used
  23441. * @returns a descriptive string representing this mesh
  23442. */
  23443. toString(fullDetails?: boolean): string;
  23444. /** @hidden */
  23445. _unBindEffect(): void;
  23446. /**
  23447. * Gets a boolean indicating if this mesh has LOD
  23448. */
  23449. readonly hasLODLevels: boolean;
  23450. /**
  23451. * Gets the list of MeshLODLevel associated with the current mesh
  23452. * @returns an array of MeshLODLevel
  23453. */
  23454. getLODLevels(): MeshLODLevel[];
  23455. private _sortLODLevels;
  23456. /**
  23457. * Add a mesh as LOD level triggered at the given distance.
  23458. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23459. * @param distance The distance from the center of the object to show this level
  23460. * @param mesh The mesh to be added as LOD level (can be null)
  23461. * @return This mesh (for chaining)
  23462. */
  23463. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23464. /**
  23465. * Returns the LOD level mesh at the passed distance or null if not found.
  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. * @returns a Mesh or `null`
  23469. */
  23470. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23471. /**
  23472. * Remove a mesh from the LOD array
  23473. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23474. * @param mesh defines the mesh to be removed
  23475. * @return This mesh (for chaining)
  23476. */
  23477. removeLODLevel(mesh: Mesh): Mesh;
  23478. /**
  23479. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23480. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23481. * @param camera defines the camera to use to compute distance
  23482. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23483. * @return This mesh (for chaining)
  23484. */
  23485. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23486. /**
  23487. * Gets the mesh internal Geometry object
  23488. */
  23489. readonly geometry: Nullable<Geometry>;
  23490. /**
  23491. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23492. * @returns the total number of vertices
  23493. */
  23494. getTotalVertices(): number;
  23495. /**
  23496. * Returns the content of an associated vertex buffer
  23497. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23498. * - VertexBuffer.PositionKind
  23499. * - VertexBuffer.UVKind
  23500. * - VertexBuffer.UV2Kind
  23501. * - VertexBuffer.UV3Kind
  23502. * - VertexBuffer.UV4Kind
  23503. * - VertexBuffer.UV5Kind
  23504. * - VertexBuffer.UV6Kind
  23505. * - VertexBuffer.ColorKind
  23506. * - VertexBuffer.MatricesIndicesKind
  23507. * - VertexBuffer.MatricesIndicesExtraKind
  23508. * - VertexBuffer.MatricesWeightsKind
  23509. * - VertexBuffer.MatricesWeightsExtraKind
  23510. * @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
  23511. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23512. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23513. */
  23514. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23515. /**
  23516. * Returns the mesh VertexBuffer object from the requested `kind`
  23517. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23518. * - VertexBuffer.PositionKind
  23519. * - VertexBuffer.NormalKind
  23520. * - VertexBuffer.UVKind
  23521. * - VertexBuffer.UV2Kind
  23522. * - VertexBuffer.UV3Kind
  23523. * - VertexBuffer.UV4Kind
  23524. * - VertexBuffer.UV5Kind
  23525. * - VertexBuffer.UV6Kind
  23526. * - VertexBuffer.ColorKind
  23527. * - VertexBuffer.MatricesIndicesKind
  23528. * - VertexBuffer.MatricesIndicesExtraKind
  23529. * - VertexBuffer.MatricesWeightsKind
  23530. * - VertexBuffer.MatricesWeightsExtraKind
  23531. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23532. */
  23533. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23534. /**
  23535. * Tests if a specific vertex buffer is associated with this mesh
  23536. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23537. * - VertexBuffer.PositionKind
  23538. * - VertexBuffer.NormalKind
  23539. * - VertexBuffer.UVKind
  23540. * - VertexBuffer.UV2Kind
  23541. * - VertexBuffer.UV3Kind
  23542. * - VertexBuffer.UV4Kind
  23543. * - VertexBuffer.UV5Kind
  23544. * - VertexBuffer.UV6Kind
  23545. * - VertexBuffer.ColorKind
  23546. * - VertexBuffer.MatricesIndicesKind
  23547. * - VertexBuffer.MatricesIndicesExtraKind
  23548. * - VertexBuffer.MatricesWeightsKind
  23549. * - VertexBuffer.MatricesWeightsExtraKind
  23550. * @returns a boolean
  23551. */
  23552. isVerticesDataPresent(kind: string): boolean;
  23553. /**
  23554. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23555. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23556. * - VertexBuffer.PositionKind
  23557. * - VertexBuffer.UVKind
  23558. * - VertexBuffer.UV2Kind
  23559. * - VertexBuffer.UV3Kind
  23560. * - VertexBuffer.UV4Kind
  23561. * - VertexBuffer.UV5Kind
  23562. * - VertexBuffer.UV6Kind
  23563. * - VertexBuffer.ColorKind
  23564. * - VertexBuffer.MatricesIndicesKind
  23565. * - VertexBuffer.MatricesIndicesExtraKind
  23566. * - VertexBuffer.MatricesWeightsKind
  23567. * - VertexBuffer.MatricesWeightsExtraKind
  23568. * @returns a boolean
  23569. */
  23570. isVertexBufferUpdatable(kind: string): boolean;
  23571. /**
  23572. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23573. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23574. * - VertexBuffer.PositionKind
  23575. * - VertexBuffer.NormalKind
  23576. * - VertexBuffer.UVKind
  23577. * - VertexBuffer.UV2Kind
  23578. * - VertexBuffer.UV3Kind
  23579. * - VertexBuffer.UV4Kind
  23580. * - VertexBuffer.UV5Kind
  23581. * - VertexBuffer.UV6Kind
  23582. * - VertexBuffer.ColorKind
  23583. * - VertexBuffer.MatricesIndicesKind
  23584. * - VertexBuffer.MatricesIndicesExtraKind
  23585. * - VertexBuffer.MatricesWeightsKind
  23586. * - VertexBuffer.MatricesWeightsExtraKind
  23587. * @returns an array of strings
  23588. */
  23589. getVerticesDataKinds(): string[];
  23590. /**
  23591. * Returns a positive integer : the total number of indices in this mesh geometry.
  23592. * @returns the numner of indices or zero if the mesh has no geometry.
  23593. */
  23594. getTotalIndices(): number;
  23595. /**
  23596. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23597. * @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.
  23598. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23599. * @returns the indices array or an empty array if the mesh has no geometry
  23600. */
  23601. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23602. readonly isBlocked: boolean;
  23603. /**
  23604. * Determine if the current mesh is ready to be rendered
  23605. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23606. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23607. * @returns true if all associated assets are ready (material, textures, shaders)
  23608. */
  23609. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23610. /**
  23611. * 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.
  23612. */
  23613. readonly areNormalsFrozen: boolean;
  23614. /**
  23615. * 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.
  23616. * @returns the current mesh
  23617. */
  23618. freezeNormals(): Mesh;
  23619. /**
  23620. * 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
  23621. * @returns the current mesh
  23622. */
  23623. unfreezeNormals(): Mesh;
  23624. /**
  23625. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23626. */
  23627. overridenInstanceCount: number;
  23628. /** @hidden */
  23629. _preActivate(): Mesh;
  23630. /** @hidden */
  23631. _preActivateForIntermediateRendering(renderId: number): Mesh;
  23632. /** @hidden */
  23633. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23634. /**
  23635. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23636. * This means the mesh underlying bounding box and sphere are recomputed.
  23637. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23638. * @returns the current mesh
  23639. */
  23640. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23641. /** @hidden */
  23642. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23643. /**
  23644. * This function will subdivide the mesh into multiple submeshes
  23645. * @param count defines the expected number of submeshes
  23646. */
  23647. subdivide(count: number): void;
  23648. /**
  23649. * Copy a FloatArray into a specific associated vertex buffer
  23650. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23651. * - VertexBuffer.PositionKind
  23652. * - VertexBuffer.UVKind
  23653. * - VertexBuffer.UV2Kind
  23654. * - VertexBuffer.UV3Kind
  23655. * - VertexBuffer.UV4Kind
  23656. * - VertexBuffer.UV5Kind
  23657. * - VertexBuffer.UV6Kind
  23658. * - VertexBuffer.ColorKind
  23659. * - VertexBuffer.MatricesIndicesKind
  23660. * - VertexBuffer.MatricesIndicesExtraKind
  23661. * - VertexBuffer.MatricesWeightsKind
  23662. * - VertexBuffer.MatricesWeightsExtraKind
  23663. * @param data defines the data source
  23664. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23665. * @param stride defines the data stride size (can be null)
  23666. * @returns the current mesh
  23667. */
  23668. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  23669. /**
  23670. * Flags an associated vertex buffer as updatable
  23671. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23672. * - VertexBuffer.PositionKind
  23673. * - VertexBuffer.UVKind
  23674. * - VertexBuffer.UV2Kind
  23675. * - VertexBuffer.UV3Kind
  23676. * - VertexBuffer.UV4Kind
  23677. * - VertexBuffer.UV5Kind
  23678. * - VertexBuffer.UV6Kind
  23679. * - VertexBuffer.ColorKind
  23680. * - VertexBuffer.MatricesIndicesKind
  23681. * - VertexBuffer.MatricesIndicesExtraKind
  23682. * - VertexBuffer.MatricesWeightsKind
  23683. * - VertexBuffer.MatricesWeightsExtraKind
  23684. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23685. */
  23686. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23687. /**
  23688. * Sets the mesh global Vertex Buffer
  23689. * @param buffer defines the buffer to use
  23690. * @returns the current mesh
  23691. */
  23692. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23693. /**
  23694. * Update a specific associated vertex buffer
  23695. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23696. * - VertexBuffer.PositionKind
  23697. * - VertexBuffer.UVKind
  23698. * - VertexBuffer.UV2Kind
  23699. * - VertexBuffer.UV3Kind
  23700. * - VertexBuffer.UV4Kind
  23701. * - VertexBuffer.UV5Kind
  23702. * - VertexBuffer.UV6Kind
  23703. * - VertexBuffer.ColorKind
  23704. * - VertexBuffer.MatricesIndicesKind
  23705. * - VertexBuffer.MatricesIndicesExtraKind
  23706. * - VertexBuffer.MatricesWeightsKind
  23707. * - VertexBuffer.MatricesWeightsExtraKind
  23708. * @param data defines the data source
  23709. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23710. * @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)
  23711. * @returns the current mesh
  23712. */
  23713. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  23714. /**
  23715. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23716. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23717. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23718. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23719. * @returns the current mesh
  23720. */
  23721. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23722. /**
  23723. * Creates a un-shared specific occurence of the geometry for the mesh.
  23724. * @returns the current mesh
  23725. */
  23726. makeGeometryUnique(): Mesh;
  23727. /**
  23728. * Set the index buffer of this mesh
  23729. * @param indices defines the source data
  23730. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23731. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23732. * @returns the current mesh
  23733. */
  23734. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  23735. /**
  23736. * Update the current index buffer
  23737. * @param indices defines the source data
  23738. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23739. * @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)
  23740. * @returns the current mesh
  23741. */
  23742. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  23743. /**
  23744. * Invert the geometry to move from a right handed system to a left handed one.
  23745. * @returns the current mesh
  23746. */
  23747. toLeftHanded(): Mesh;
  23748. /** @hidden */
  23749. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23750. /** @hidden */
  23751. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23752. /**
  23753. * Registers for this mesh a javascript function called just before the rendering process
  23754. * @param func defines the function to call before rendering this mesh
  23755. * @returns the current mesh
  23756. */
  23757. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23758. /**
  23759. * Disposes a previously registered javascript function called before the rendering
  23760. * @param func defines the function to remove
  23761. * @returns the current mesh
  23762. */
  23763. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23764. /**
  23765. * Registers for this mesh a javascript function called just after the rendering is complete
  23766. * @param func defines the function to call after rendering this mesh
  23767. * @returns the current mesh
  23768. */
  23769. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23770. /**
  23771. * Disposes a previously registered javascript function called after the rendering.
  23772. * @param func defines the function to remove
  23773. * @returns the current mesh
  23774. */
  23775. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23776. /** @hidden */
  23777. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23778. /** @hidden */
  23779. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23780. /** @hidden */
  23781. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23782. /** @hidden */
  23783. _rebuild(): void;
  23784. /** @hidden */
  23785. _freeze(): void;
  23786. /** @hidden */
  23787. _unFreeze(): void;
  23788. /**
  23789. * 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
  23790. * @param subMesh defines the subMesh to render
  23791. * @param enableAlphaMode defines if alpha mode can be changed
  23792. * @returns the current mesh
  23793. */
  23794. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  23795. private _onBeforeDraw;
  23796. /**
  23797. * Renormalize the mesh and patch it up if there are no weights
  23798. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  23799. * However in the case of zero weights then we set just a single influence to 1.
  23800. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  23801. */
  23802. cleanMatrixWeights(): void;
  23803. private normalizeSkinFourWeights;
  23804. private normalizeSkinWeightsAndExtra;
  23805. /**
  23806. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  23807. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  23808. * the user know there was an issue with importing the mesh
  23809. * @returns a validation object with skinned, valid and report string
  23810. */
  23811. validateSkinning(): {
  23812. skinned: boolean;
  23813. valid: boolean;
  23814. report: string;
  23815. };
  23816. /** @hidden */
  23817. _checkDelayState(): Mesh;
  23818. private _queueLoad;
  23819. /**
  23820. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23821. * A mesh is in the frustum if its bounding box intersects the frustum
  23822. * @param frustumPlanes defines the frustum to test
  23823. * @returns true if the mesh is in the frustum planes
  23824. */
  23825. isInFrustum(frustumPlanes: Plane[]): boolean;
  23826. /**
  23827. * Sets the mesh material by the material or multiMaterial `id` property
  23828. * @param id is a string identifying the material or the multiMaterial
  23829. * @returns the current mesh
  23830. */
  23831. setMaterialByID(id: string): Mesh;
  23832. /**
  23833. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  23834. * @returns an array of IAnimatable
  23835. */
  23836. getAnimatables(): IAnimatable[];
  23837. /**
  23838. * Modifies the mesh geometry according to the passed transformation matrix.
  23839. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  23840. * The mesh normals are modified using the same transformation.
  23841. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23842. * @param transform defines the transform matrix to use
  23843. * @see http://doc.babylonjs.com/resources/baking_transformations
  23844. * @returns the current mesh
  23845. */
  23846. bakeTransformIntoVertices(transform: Matrix): Mesh;
  23847. /**
  23848. * Modifies the mesh geometry according to its own current World Matrix.
  23849. * The mesh World Matrix is then reset.
  23850. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  23851. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23852. * @see http://doc.babylonjs.com/resources/baking_transformations
  23853. * @returns the current mesh
  23854. */
  23855. bakeCurrentTransformIntoVertices(): Mesh;
  23856. /** @hidden */
  23857. readonly _positions: Nullable<Vector3[]>;
  23858. /** @hidden */
  23859. _resetPointsArrayCache(): Mesh;
  23860. /** @hidden */
  23861. _generatePointsArray(): boolean;
  23862. /**
  23863. * Returns a new Mesh object generated from the current mesh properties.
  23864. * This method must not get confused with createInstance()
  23865. * @param name is a string, the name given to the new mesh
  23866. * @param newParent can be any Node object (default `null`)
  23867. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  23868. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  23869. * @returns a new mesh
  23870. */
  23871. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  23872. /**
  23873. * Releases resources associated with this mesh.
  23874. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23875. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23876. */
  23877. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23878. /**
  23879. * Modifies the mesh geometry according to a displacement map.
  23880. * 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.
  23881. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23882. * @param url is a string, the URL from the image file is to be downloaded.
  23883. * @param minHeight is the lower limit of the displacement.
  23884. * @param maxHeight is the upper limit of the displacement.
  23885. * @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.
  23886. * @param uvOffset is an optional vector2 used to offset UV.
  23887. * @param uvScale is an optional vector2 used to scale UV.
  23888. * @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.
  23889. * @returns the Mesh.
  23890. */
  23891. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23892. /**
  23893. * Modifies the mesh geometry according to a displacementMap buffer.
  23894. * 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.
  23895. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23896. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  23897. * @param heightMapWidth is the width of the buffer image.
  23898. * @param heightMapHeight is the height of the buffer image.
  23899. * @param minHeight is the lower limit of the displacement.
  23900. * @param maxHeight is the upper limit of the displacement.
  23901. * @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.
  23902. * @param uvOffset is an optional vector2 used to offset UV.
  23903. * @param uvScale is an optional vector2 used to scale UV.
  23904. * @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.
  23905. * @returns the Mesh.
  23906. */
  23907. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23908. /**
  23909. * Modify the mesh to get a flat shading rendering.
  23910. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  23911. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  23912. * @returns current mesh
  23913. */
  23914. convertToFlatShadedMesh(): Mesh;
  23915. /**
  23916. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  23917. * In other words, more vertices, no more indices and a single bigger VBO.
  23918. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  23919. * @returns current mesh
  23920. */
  23921. convertToUnIndexedMesh(): Mesh;
  23922. /**
  23923. * Inverses facet orientations.
  23924. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23925. * @param flipNormals will also inverts the normals
  23926. * @returns current mesh
  23927. */
  23928. flipFaces(flipNormals?: boolean): Mesh;
  23929. /**
  23930. * Increase the number of facets and hence vertices in a mesh
  23931. * Vertex normals are interpolated from existing vertex normals
  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 numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  23934. */
  23935. increaseVertices(numberPerEdge: number): void;
  23936. /**
  23937. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  23938. * This will undo any application of covertToFlatShadedMesh
  23939. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23940. */
  23941. forceSharedVertices(): void;
  23942. /** @hidden */
  23943. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  23944. /** @hidden */
  23945. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  23946. /**
  23947. * Creates a new InstancedMesh object from the mesh model.
  23948. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23949. * @param name defines the name of the new instance
  23950. * @returns a new InstancedMesh
  23951. */
  23952. createInstance(name: string): InstancedMesh;
  23953. /**
  23954. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  23955. * After this call, all the mesh instances have the same submeshes than the current mesh.
  23956. * @returns the current mesh
  23957. */
  23958. synchronizeInstances(): Mesh;
  23959. /**
  23960. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  23961. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  23962. * This should be used together with the simplification to avoid disappearing triangles.
  23963. * @param successCallback an optional success callback to be called after the optimization finished.
  23964. * @returns the current mesh
  23965. */
  23966. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  23967. /**
  23968. * Serialize current mesh
  23969. * @param serializationObject defines the object which will receive the serialization data
  23970. */
  23971. serialize(serializationObject: any): void;
  23972. /** @hidden */
  23973. _syncGeometryWithMorphTargetManager(): void;
  23974. /** @hidden */
  23975. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  23976. /**
  23977. * Returns a new Mesh object parsed from the source provided.
  23978. * @param parsedMesh is the source
  23979. * @param scene defines the hosting scene
  23980. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  23981. * @returns a new Mesh
  23982. */
  23983. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  23984. /**
  23985. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  23986. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23987. * @param name defines the name of the mesh to create
  23988. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  23989. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  23990. * @param closePath creates a seam between the first and the last points of each path of the path array
  23991. * @param offset is taken in account only if the `pathArray` is containing a single path
  23992. * @param scene defines the hosting scene
  23993. * @param updatable defines if the mesh must be flagged as updatable
  23994. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23995. * @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)
  23996. * @returns a new Mesh
  23997. */
  23998. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23999. /**
  24000. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24001. * @param name defines the name of the mesh to create
  24002. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24003. * @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
  24004. * @param scene defines the hosting scene
  24005. * @param updatable defines if the mesh must be flagged as updatable
  24006. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24007. * @returns a new Mesh
  24008. */
  24009. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24010. /**
  24011. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24012. * @param name defines the name of the mesh to create
  24013. * @param size sets the size (float) of each box side (default 1)
  24014. * @param scene defines the hosting scene
  24015. * @param updatable defines if the mesh must be flagged as updatable
  24016. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24017. * @returns a new Mesh
  24018. */
  24019. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24020. /**
  24021. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24022. * @param name defines the name of the mesh to create
  24023. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24024. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24025. * @param scene defines the hosting scene
  24026. * @param updatable defines if the mesh must be flagged as updatable
  24027. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24028. * @returns a new Mesh
  24029. */
  24030. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24031. /**
  24032. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24033. * @param name defines the name of the mesh to create
  24034. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24035. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24036. * @param scene defines the hosting scene
  24037. * @returns a new Mesh
  24038. */
  24039. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24040. /**
  24041. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24042. * @param name defines the name of the mesh to create
  24043. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24044. * @param diameterTop set the top cap diameter (floats, default 1)
  24045. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24046. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24047. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24048. * @param scene defines the hosting scene
  24049. * @param updatable defines if the mesh must be flagged as updatable
  24050. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24051. * @returns a new Mesh
  24052. */
  24053. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24054. /**
  24055. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24056. * @param name defines the name of the mesh to create
  24057. * @param diameter sets the diameter size (float) of the torus (default 1)
  24058. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24059. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24060. * @param scene defines the hosting scene
  24061. * @param updatable defines if the mesh must be flagged as updatable
  24062. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24063. * @returns a new Mesh
  24064. */
  24065. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24066. /**
  24067. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24068. * @param name defines the name of the mesh to create
  24069. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24070. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24071. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24072. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24073. * @param p the number of windings on X axis (positive integers, default 2)
  24074. * @param q the number of windings on Y axis (positive integers, default 3)
  24075. * @param scene defines the hosting scene
  24076. * @param updatable defines if the mesh must be flagged as updatable
  24077. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24078. * @returns a new Mesh
  24079. */
  24080. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24081. /**
  24082. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24083. * @param name defines the name of the mesh to create
  24084. * @param points is an array successive Vector3
  24085. * @param scene defines the hosting scene
  24086. * @param updatable defines if the mesh must be flagged as updatable
  24087. * @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).
  24088. * @returns a new Mesh
  24089. */
  24090. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24091. /**
  24092. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24093. * @param name defines the name of the mesh to create
  24094. * @param points is an array successive Vector3
  24095. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24096. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24097. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24098. * @param scene defines the hosting scene
  24099. * @param updatable defines if the mesh must be flagged as updatable
  24100. * @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)
  24101. * @returns a new Mesh
  24102. */
  24103. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24104. /**
  24105. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24106. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24107. * 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.
  24108. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24109. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24110. * Remember you can only change the shape positions, not their number when updating a polygon.
  24111. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24112. * @param name defines the name of the mesh to create
  24113. * @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
  24114. * @param scene defines the hosting scene
  24115. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24116. * @param updatable defines if the mesh must be flagged as updatable
  24117. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24118. * @param earcutInjection can be used to inject your own earcut reference
  24119. * @returns a new Mesh
  24120. */
  24121. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24122. /**
  24123. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24124. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24125. * @param name defines the name of the mesh to create
  24126. * @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
  24127. * @param depth defines the height of extrusion
  24128. * @param scene defines the hosting scene
  24129. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24130. * @param updatable defines if the mesh must be flagged as updatable
  24131. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24132. * @param earcutInjection can be used to inject your own earcut reference
  24133. * @returns a new Mesh
  24134. */
  24135. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24136. /**
  24137. * Creates an extruded shape mesh.
  24138. * 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
  24139. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24140. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24141. * @param name defines the name of the mesh to create
  24142. * @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
  24143. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24144. * @param scale is the value to scale the shape
  24145. * @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
  24146. * @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
  24147. * @param scene defines the hosting scene
  24148. * @param updatable defines if the mesh must be flagged as updatable
  24149. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24150. * @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)
  24151. * @returns a new Mesh
  24152. */
  24153. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24154. /**
  24155. * Creates an custom extruded shape mesh.
  24156. * The custom extrusion is a parametric shape.
  24157. * It has no predefined shape. Its final shape will depend on the input parameters.
  24158. * Please consider using the same method from the MeshBuilder class instead
  24159. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24160. * @param name defines the name of the mesh to create
  24161. * @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
  24162. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24163. * @param scaleFunction is a custom Javascript function called on each path point
  24164. * @param rotationFunction is a custom Javascript function called on each path point
  24165. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24166. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24167. * @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
  24168. * @param scene defines the hosting scene
  24169. * @param updatable defines if the mesh must be flagged as updatable
  24170. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24171. * @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)
  24172. * @returns a new Mesh
  24173. */
  24174. 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;
  24175. /**
  24176. * Creates lathe mesh.
  24177. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24178. * Please consider using the same method from the MeshBuilder class instead
  24179. * @param name defines the name of the mesh to create
  24180. * @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
  24181. * @param radius is the radius value of the lathe
  24182. * @param tessellation is the side number of the lathe.
  24183. * @param scene defines the hosting scene
  24184. * @param updatable defines if the mesh must be flagged as updatable
  24185. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24186. * @returns a new Mesh
  24187. */
  24188. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24189. /**
  24190. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24191. * @param name defines the name of the mesh to create
  24192. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24193. * @param scene defines the hosting scene
  24194. * @param updatable defines if the mesh must be flagged as updatable
  24195. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24196. * @returns a new Mesh
  24197. */
  24198. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24199. /**
  24200. * Creates a ground mesh.
  24201. * Please consider using the same method from the MeshBuilder class instead
  24202. * @param name defines the name of the mesh to create
  24203. * @param width set the width of the ground
  24204. * @param height set the height of the ground
  24205. * @param subdivisions sets the number of subdivisions per side
  24206. * @param scene defines the hosting scene
  24207. * @param updatable defines if the mesh must be flagged as updatable
  24208. * @returns a new Mesh
  24209. */
  24210. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24211. /**
  24212. * Creates a tiled ground mesh.
  24213. * Please consider using the same method from the MeshBuilder class instead
  24214. * @param name defines the name of the mesh to create
  24215. * @param xmin set the ground minimum X coordinate
  24216. * @param zmin set the ground minimum Y coordinate
  24217. * @param xmax set the ground maximum X coordinate
  24218. * @param zmax set the ground maximum Z coordinate
  24219. * @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
  24220. * @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
  24221. * @param scene defines the hosting scene
  24222. * @param updatable defines if the mesh must be flagged as updatable
  24223. * @returns a new Mesh
  24224. */
  24225. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24226. w: number;
  24227. h: number;
  24228. }, precision: {
  24229. w: number;
  24230. h: number;
  24231. }, scene: Scene, updatable?: boolean): Mesh;
  24232. /**
  24233. * Creates a ground mesh from a height map.
  24234. * Please consider using the same method from the MeshBuilder class instead
  24235. * @see http://doc.babylonjs.com/babylon101/height_map
  24236. * @param name defines the name of the mesh to create
  24237. * @param url sets the URL of the height map image resource
  24238. * @param width set the ground width size
  24239. * @param height set the ground height size
  24240. * @param subdivisions sets the number of subdivision per side
  24241. * @param minHeight is the minimum altitude on the ground
  24242. * @param maxHeight is the maximum altitude on the ground
  24243. * @param scene defines the hosting scene
  24244. * @param updatable defines if the mesh must be flagged as updatable
  24245. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24246. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24247. * @returns a new Mesh
  24248. */
  24249. 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;
  24250. /**
  24251. * Creates a tube mesh.
  24252. * The tube is a parametric shape.
  24253. * It has no predefined shape. Its final shape will depend on the input parameters.
  24254. * Please consider using the same method from the MeshBuilder class instead
  24255. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24256. * @param name defines the name of the mesh to create
  24257. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24258. * @param radius sets the tube radius size
  24259. * @param tessellation is the number of sides on the tubular surface
  24260. * @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
  24261. * @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
  24262. * @param scene defines the hosting scene
  24263. * @param updatable defines if the mesh must be flagged as updatable
  24264. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24265. * @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)
  24266. * @returns a new Mesh
  24267. */
  24268. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24269. (i: number, distance: number): number;
  24270. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24271. /**
  24272. * Creates a polyhedron mesh.
  24273. * Please consider using the same method from the MeshBuilder class instead.
  24274. * * 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
  24275. * * The parameter `size` (positive float, default 1) sets the polygon size
  24276. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24277. * * 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`
  24278. * * 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
  24279. * * 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)`)
  24280. * * 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
  24281. * * 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
  24282. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24283. * * 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
  24284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24285. * @param name defines the name of the mesh to create
  24286. * @param options defines the options used to create the mesh
  24287. * @param scene defines the hosting scene
  24288. * @returns a new Mesh
  24289. */
  24290. static CreatePolyhedron(name: string, options: {
  24291. type?: number;
  24292. size?: number;
  24293. sizeX?: number;
  24294. sizeY?: number;
  24295. sizeZ?: number;
  24296. custom?: any;
  24297. faceUV?: Vector4[];
  24298. faceColors?: Color4[];
  24299. updatable?: boolean;
  24300. sideOrientation?: number;
  24301. }, scene: Scene): Mesh;
  24302. /**
  24303. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24304. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24305. * * 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`)
  24306. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24307. * * 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
  24308. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24309. * * 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
  24310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24311. * @param name defines the name of the mesh
  24312. * @param options defines the options used to create the mesh
  24313. * @param scene defines the hosting scene
  24314. * @returns a new Mesh
  24315. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24316. */
  24317. static CreateIcoSphere(name: string, options: {
  24318. radius?: number;
  24319. flat?: boolean;
  24320. subdivisions?: number;
  24321. sideOrientation?: number;
  24322. updatable?: boolean;
  24323. }, scene: Scene): Mesh;
  24324. /**
  24325. * Creates a decal mesh.
  24326. * Please consider using the same method from the MeshBuilder class instead.
  24327. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24328. * @param name defines the name of the mesh
  24329. * @param sourceMesh defines the mesh receiving the decal
  24330. * @param position sets the position of the decal in world coordinates
  24331. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24332. * @param size sets the decal scaling
  24333. * @param angle sets the angle to rotate the decal
  24334. * @returns a new Mesh
  24335. */
  24336. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24337. /**
  24338. * Prepare internal position array for software CPU skinning
  24339. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24340. */
  24341. setPositionsForCPUSkinning(): Float32Array;
  24342. /**
  24343. * Prepare internal normal array for software CPU skinning
  24344. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24345. */
  24346. setNormalsForCPUSkinning(): Float32Array;
  24347. /**
  24348. * Updates the vertex buffer by applying transformation from the bones
  24349. * @param skeleton defines the skeleton to apply to current mesh
  24350. * @returns the current mesh
  24351. */
  24352. applySkeleton(skeleton: Skeleton): Mesh;
  24353. /**
  24354. * 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
  24355. * @param meshes defines the list of meshes to scan
  24356. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24357. */
  24358. static MinMax(meshes: AbstractMesh[]): {
  24359. min: Vector3;
  24360. max: Vector3;
  24361. };
  24362. /**
  24363. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24364. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24365. * @returns a vector3
  24366. */
  24367. static Center(meshesOrMinMaxVector: {
  24368. min: Vector3;
  24369. max: Vector3;
  24370. } | AbstractMesh[]): Vector3;
  24371. /**
  24372. * Merge the array of meshes into a single mesh for performance reasons.
  24373. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24374. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24375. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24376. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24377. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24378. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24379. * @returns a new mesh
  24380. */
  24381. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24382. /** @hidden */
  24383. addInstance(instance: InstancedMesh): void;
  24384. /** @hidden */
  24385. removeInstance(instance: InstancedMesh): void;
  24386. }
  24387. }
  24388. declare module BABYLON {
  24389. /**
  24390. * This is the base class of all the camera used in the application.
  24391. * @see http://doc.babylonjs.com/features/cameras
  24392. */
  24393. export class Camera extends Node {
  24394. /** @hidden */
  24395. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24396. /**
  24397. * This is the default projection mode used by the cameras.
  24398. * It helps recreating a feeling of perspective and better appreciate depth.
  24399. * This is the best way to simulate real life cameras.
  24400. */
  24401. static readonly PERSPECTIVE_CAMERA: number;
  24402. /**
  24403. * This helps creating camera with an orthographic mode.
  24404. * 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.
  24405. */
  24406. static readonly ORTHOGRAPHIC_CAMERA: number;
  24407. /**
  24408. * This is the default FOV mode for perspective cameras.
  24409. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24410. */
  24411. static readonly FOVMODE_VERTICAL_FIXED: number;
  24412. /**
  24413. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24414. */
  24415. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24416. /**
  24417. * This specifies ther is no need for a camera rig.
  24418. * Basically only one eye is rendered corresponding to the camera.
  24419. */
  24420. static readonly RIG_MODE_NONE: number;
  24421. /**
  24422. * Simulates a camera Rig with one blue eye and one red eye.
  24423. * This can be use with 3d blue and red glasses.
  24424. */
  24425. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24426. /**
  24427. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24428. */
  24429. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24430. /**
  24431. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24432. */
  24433. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24434. /**
  24435. * Defines that both eyes of the camera will be rendered over under each other.
  24436. */
  24437. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24438. /**
  24439. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24440. */
  24441. static readonly RIG_MODE_VR: number;
  24442. /**
  24443. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24444. */
  24445. static readonly RIG_MODE_WEBVR: number;
  24446. /**
  24447. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24448. */
  24449. static readonly RIG_MODE_CUSTOM: number;
  24450. /**
  24451. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24452. */
  24453. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24454. /**
  24455. * Define the input manager associated with the camera.
  24456. */
  24457. inputs: CameraInputsManager<Camera>;
  24458. /** @hidden */
  24459. _position: Vector3;
  24460. /**
  24461. * Define the current local position of the camera in the scene
  24462. */
  24463. position: Vector3;
  24464. /**
  24465. * The vector the camera should consider as up.
  24466. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24467. */
  24468. upVector: Vector3;
  24469. /**
  24470. * Define the current limit on the left side for an orthographic camera
  24471. * In scene unit
  24472. */
  24473. orthoLeft: Nullable<number>;
  24474. /**
  24475. * Define the current limit on the right side for an orthographic camera
  24476. * In scene unit
  24477. */
  24478. orthoRight: Nullable<number>;
  24479. /**
  24480. * Define the current limit on the bottom side for an orthographic camera
  24481. * In scene unit
  24482. */
  24483. orthoBottom: Nullable<number>;
  24484. /**
  24485. * Define the current limit on the top side for an orthographic camera
  24486. * In scene unit
  24487. */
  24488. orthoTop: Nullable<number>;
  24489. /**
  24490. * Field Of View is set in Radians. (default is 0.8)
  24491. */
  24492. fov: number;
  24493. /**
  24494. * Define the minimum distance the camera can see from.
  24495. * This is important to note that the depth buffer are not infinite and the closer it starts
  24496. * the more your scene might encounter depth fighting issue.
  24497. */
  24498. minZ: number;
  24499. /**
  24500. * Define the maximum distance the camera can see to.
  24501. * This is important to note that the depth buffer are not infinite and the further it end
  24502. * the more your scene might encounter depth fighting issue.
  24503. */
  24504. maxZ: number;
  24505. /**
  24506. * Define the default inertia of the camera.
  24507. * This helps giving a smooth feeling to the camera movement.
  24508. */
  24509. inertia: number;
  24510. /**
  24511. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24512. */
  24513. mode: number;
  24514. /**
  24515. * Define wether the camera is intermediate.
  24516. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24517. */
  24518. isIntermediate: boolean;
  24519. /**
  24520. * Define the viewport of the camera.
  24521. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24522. */
  24523. viewport: Viewport;
  24524. /**
  24525. * Restricts the camera to viewing objects with the same layerMask.
  24526. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24527. */
  24528. layerMask: number;
  24529. /**
  24530. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24531. */
  24532. fovMode: number;
  24533. /**
  24534. * Rig mode of the camera.
  24535. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24536. * This is normally controlled byt the camera themselves as internal use.
  24537. */
  24538. cameraRigMode: number;
  24539. /**
  24540. * Defines the distance between both "eyes" in case of a RIG
  24541. */
  24542. interaxialDistance: number;
  24543. /**
  24544. * Defines if stereoscopic rendering is done side by side or over under.
  24545. */
  24546. isStereoscopicSideBySide: boolean;
  24547. /**
  24548. * 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
  24549. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24550. * else in the scene. (Eg. security camera)
  24551. *
  24552. * 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)
  24553. */
  24554. customRenderTargets: RenderTargetTexture[];
  24555. /**
  24556. * When set, the camera will render to this render target instead of the default canvas
  24557. *
  24558. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24559. */
  24560. outputRenderTarget: Nullable<RenderTargetTexture>;
  24561. /**
  24562. * Observable triggered when the camera view matrix has changed.
  24563. */
  24564. onViewMatrixChangedObservable: Observable<Camera>;
  24565. /**
  24566. * Observable triggered when the camera Projection matrix has changed.
  24567. */
  24568. onProjectionMatrixChangedObservable: Observable<Camera>;
  24569. /**
  24570. * Observable triggered when the inputs have been processed.
  24571. */
  24572. onAfterCheckInputsObservable: Observable<Camera>;
  24573. /**
  24574. * Observable triggered when reset has been called and applied to the camera.
  24575. */
  24576. onRestoreStateObservable: Observable<Camera>;
  24577. /** @hidden */
  24578. _cameraRigParams: any;
  24579. /** @hidden */
  24580. _rigCameras: Camera[];
  24581. /** @hidden */
  24582. _rigPostProcess: Nullable<PostProcess>;
  24583. protected _webvrViewMatrix: Matrix;
  24584. /** @hidden */
  24585. _skipRendering: boolean;
  24586. /** @hidden */
  24587. _projectionMatrix: Matrix;
  24588. /** @hidden */
  24589. _postProcesses: Nullable<PostProcess>[];
  24590. /** @hidden */
  24591. _activeMeshes: SmartArray<AbstractMesh>;
  24592. protected _globalPosition: Vector3;
  24593. /** @hidden */
  24594. _computedViewMatrix: Matrix;
  24595. private _doNotComputeProjectionMatrix;
  24596. private _transformMatrix;
  24597. private _frustumPlanes;
  24598. private _refreshFrustumPlanes;
  24599. private _storedFov;
  24600. private _stateStored;
  24601. /**
  24602. * Instantiates a new camera object.
  24603. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24604. * @see http://doc.babylonjs.com/features/cameras
  24605. * @param name Defines the name of the camera in the scene
  24606. * @param position Defines the position of the camera
  24607. * @param scene Defines the scene the camera belongs too
  24608. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24609. */
  24610. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24611. /**
  24612. * Store current camera state (fov, position, etc..)
  24613. * @returns the camera
  24614. */
  24615. storeState(): Camera;
  24616. /**
  24617. * Restores the camera state values if it has been stored. You must call storeState() first
  24618. */
  24619. protected _restoreStateValues(): boolean;
  24620. /**
  24621. * Restored camera state. You must call storeState() first.
  24622. * @returns true if restored and false otherwise
  24623. */
  24624. restoreState(): boolean;
  24625. /**
  24626. * Gets the class name of the camera.
  24627. * @returns the class name
  24628. */
  24629. getClassName(): string;
  24630. /** @hidden */
  24631. readonly _isCamera: boolean;
  24632. /**
  24633. * Gets a string representation of the camera useful for debug purpose.
  24634. * @param fullDetails Defines that a more verboe level of logging is required
  24635. * @returns the string representation
  24636. */
  24637. toString(fullDetails?: boolean): string;
  24638. /**
  24639. * Gets the current world space position of the camera.
  24640. */
  24641. readonly globalPosition: Vector3;
  24642. /**
  24643. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24644. * @returns the active meshe list
  24645. */
  24646. getActiveMeshes(): SmartArray<AbstractMesh>;
  24647. /**
  24648. * Check wether a mesh is part of the current active mesh list of the camera
  24649. * @param mesh Defines the mesh to check
  24650. * @returns true if active, false otherwise
  24651. */
  24652. isActiveMesh(mesh: Mesh): boolean;
  24653. /**
  24654. * Is this camera ready to be used/rendered
  24655. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24656. * @return true if the camera is ready
  24657. */
  24658. isReady(completeCheck?: boolean): boolean;
  24659. /** @hidden */
  24660. _initCache(): void;
  24661. /** @hidden */
  24662. _updateCache(ignoreParentClass?: boolean): void;
  24663. /** @hidden */
  24664. _isSynchronized(): boolean;
  24665. /** @hidden */
  24666. _isSynchronizedViewMatrix(): boolean;
  24667. /** @hidden */
  24668. _isSynchronizedProjectionMatrix(): boolean;
  24669. /**
  24670. * Attach the input controls to a specific dom element to get the input from.
  24671. * @param element Defines the element the controls should be listened from
  24672. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24673. */
  24674. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24675. /**
  24676. * Detach the current controls from the specified dom element.
  24677. * @param element Defines the element to stop listening the inputs from
  24678. */
  24679. detachControl(element: HTMLElement): void;
  24680. /**
  24681. * Update the camera state according to the different inputs gathered during the frame.
  24682. */
  24683. update(): void;
  24684. /** @hidden */
  24685. _checkInputs(): void;
  24686. /** @hidden */
  24687. readonly rigCameras: Camera[];
  24688. /**
  24689. * Gets the post process used by the rig cameras
  24690. */
  24691. readonly rigPostProcess: Nullable<PostProcess>;
  24692. /**
  24693. * Internal, gets the first post proces.
  24694. * @returns the first post process to be run on this camera.
  24695. */
  24696. _getFirstPostProcess(): Nullable<PostProcess>;
  24697. private _cascadePostProcessesToRigCams;
  24698. /**
  24699. * Attach a post process to the camera.
  24700. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24701. * @param postProcess The post process to attach to the camera
  24702. * @param insertAt The position of the post process in case several of them are in use in the scene
  24703. * @returns the position the post process has been inserted at
  24704. */
  24705. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24706. /**
  24707. * Detach 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 detach from the camera
  24710. */
  24711. detachPostProcess(postProcess: PostProcess): void;
  24712. /**
  24713. * Gets the current world matrix of the camera
  24714. */
  24715. getWorldMatrix(): Matrix;
  24716. /** @hidden */
  24717. _getViewMatrix(): Matrix;
  24718. /**
  24719. * Gets the current view matrix of the camera.
  24720. * @param force forces the camera to recompute the matrix without looking at the cached state
  24721. * @returns the view matrix
  24722. */
  24723. getViewMatrix(force?: boolean): Matrix;
  24724. /**
  24725. * Freeze the projection matrix.
  24726. * It will prevent the cache check of the camera projection compute and can speed up perf
  24727. * if no parameter of the camera are meant to change
  24728. * @param projection Defines manually a projection if necessary
  24729. */
  24730. freezeProjectionMatrix(projection?: Matrix): void;
  24731. /**
  24732. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24733. */
  24734. unfreezeProjectionMatrix(): void;
  24735. /**
  24736. * Gets the current projection matrix of the camera.
  24737. * @param force forces the camera to recompute the matrix without looking at the cached state
  24738. * @returns the projection matrix
  24739. */
  24740. getProjectionMatrix(force?: boolean): Matrix;
  24741. /**
  24742. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24743. * @returns a Matrix
  24744. */
  24745. getTransformationMatrix(): Matrix;
  24746. private _updateFrustumPlanes;
  24747. /**
  24748. * Checks if a cullable object (mesh...) is in the camera frustum
  24749. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24750. * @param target The object to check
  24751. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24752. * @returns true if the object is in frustum otherwise false
  24753. */
  24754. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24755. /**
  24756. * Checks if a cullable object (mesh...) is in the camera frustum
  24757. * Unlike isInFrustum this cheks the full bounding box
  24758. * @param target The object to check
  24759. * @returns true if the object is in frustum otherwise false
  24760. */
  24761. isCompletelyInFrustum(target: ICullable): boolean;
  24762. /**
  24763. * Gets a ray in the forward direction from the camera.
  24764. * @param length Defines the length of the ray to create
  24765. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24766. * @param origin Defines the start point of the ray which defaults to the camera position
  24767. * @returns the forward ray
  24768. */
  24769. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24770. /**
  24771. * Releases resources associated with this node.
  24772. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24773. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24774. */
  24775. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24776. /** @hidden */
  24777. _isLeftCamera: boolean;
  24778. /**
  24779. * Gets the left camera of a rig setup in case of Rigged Camera
  24780. */
  24781. readonly isLeftCamera: boolean;
  24782. /** @hidden */
  24783. _isRightCamera: boolean;
  24784. /**
  24785. * Gets the right camera of a rig setup in case of Rigged Camera
  24786. */
  24787. readonly isRightCamera: boolean;
  24788. /**
  24789. * Gets the left camera of a rig setup in case of Rigged Camera
  24790. */
  24791. readonly leftCamera: Nullable<FreeCamera>;
  24792. /**
  24793. * Gets the right camera of a rig setup in case of Rigged Camera
  24794. */
  24795. readonly rightCamera: Nullable<FreeCamera>;
  24796. /**
  24797. * Gets the left camera target of a rig setup in case of Rigged Camera
  24798. * @returns the target position
  24799. */
  24800. getLeftTarget(): Nullable<Vector3>;
  24801. /**
  24802. * Gets the right camera target of a rig setup in case of Rigged Camera
  24803. * @returns the target position
  24804. */
  24805. getRightTarget(): Nullable<Vector3>;
  24806. /**
  24807. * @hidden
  24808. */
  24809. setCameraRigMode(mode: number, rigParams: any): void;
  24810. /** @hidden */
  24811. static _setStereoscopicRigMode(camera: Camera): void;
  24812. /** @hidden */
  24813. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  24814. /** @hidden */
  24815. static _setVRRigMode(camera: Camera, rigParams: any): void;
  24816. /** @hidden */
  24817. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  24818. /** @hidden */
  24819. _getVRProjectionMatrix(): Matrix;
  24820. protected _updateCameraRotationMatrix(): void;
  24821. protected _updateWebVRCameraRotationMatrix(): void;
  24822. /**
  24823. * This function MUST be overwritten by the different WebVR cameras available.
  24824. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24825. * @hidden
  24826. */
  24827. _getWebVRProjectionMatrix(): Matrix;
  24828. /**
  24829. * This function MUST be overwritten by the different WebVR cameras available.
  24830. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24831. * @hidden
  24832. */
  24833. _getWebVRViewMatrix(): Matrix;
  24834. /** @hidden */
  24835. setCameraRigParameter(name: string, value: any): void;
  24836. /**
  24837. * needs to be overridden by children so sub has required properties to be copied
  24838. * @hidden
  24839. */
  24840. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  24841. /**
  24842. * May need to be overridden by children
  24843. * @hidden
  24844. */
  24845. _updateRigCameras(): void;
  24846. /** @hidden */
  24847. _setupInputs(): void;
  24848. /**
  24849. * Serialiaze the camera setup to a json represention
  24850. * @returns the JSON representation
  24851. */
  24852. serialize(): any;
  24853. /**
  24854. * Clones the current camera.
  24855. * @param name The cloned camera name
  24856. * @returns the cloned camera
  24857. */
  24858. clone(name: string): Camera;
  24859. /**
  24860. * Gets the direction of the camera relative to a given local axis.
  24861. * @param localAxis Defines the reference axis to provide a relative direction.
  24862. * @return the direction
  24863. */
  24864. getDirection(localAxis: Vector3): Vector3;
  24865. /**
  24866. * Gets the direction of the camera relative to a given local axis into a passed vector.
  24867. * @param localAxis Defines the reference axis to provide a relative direction.
  24868. * @param result Defines the vector to store the result in
  24869. */
  24870. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  24871. /**
  24872. * Gets a camera constructor for a given camera type
  24873. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  24874. * @param name The name of the camera the result will be able to instantiate
  24875. * @param scene The scene the result will construct the camera in
  24876. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  24877. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  24878. * @returns a factory method to construc the camera
  24879. */
  24880. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  24881. /**
  24882. * Compute the world matrix of the camera.
  24883. * @returns the camera workd matrix
  24884. */
  24885. computeWorldMatrix(): Matrix;
  24886. /**
  24887. * Parse a JSON and creates the camera from the parsed information
  24888. * @param parsedCamera The JSON to parse
  24889. * @param scene The scene to instantiate the camera in
  24890. * @returns the newly constructed camera
  24891. */
  24892. static Parse(parsedCamera: any, scene: Scene): Camera;
  24893. }
  24894. }
  24895. declare module BABYLON {
  24896. /**
  24897. * Class containing static functions to help procedurally build meshes
  24898. */
  24899. export class DiscBuilder {
  24900. /**
  24901. * Creates a plane polygonal mesh. By default, this is a disc
  24902. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24903. * * 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
  24904. * * 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
  24905. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24906. * * 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
  24907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24908. * @param name defines the name of the mesh
  24909. * @param options defines the options used to create the mesh
  24910. * @param scene defines the hosting scene
  24911. * @returns the plane polygonal mesh
  24912. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24913. */
  24914. static CreateDisc(name: string, options: {
  24915. radius?: number;
  24916. tessellation?: number;
  24917. arc?: number;
  24918. updatable?: boolean;
  24919. sideOrientation?: number;
  24920. frontUVs?: Vector4;
  24921. backUVs?: Vector4;
  24922. }, scene?: Nullable<Scene>): Mesh;
  24923. }
  24924. }
  24925. declare module BABYLON {
  24926. /**
  24927. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24928. *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.
  24929. * The SPS is also a particle system. It provides some methods to manage the particles.
  24930. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24931. *
  24932. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  24933. */
  24934. export class SolidParticleSystem implements IDisposable {
  24935. /**
  24936. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24937. * Example : var p = SPS.particles[i];
  24938. */
  24939. particles: SolidParticle[];
  24940. /**
  24941. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24942. */
  24943. nbParticles: number;
  24944. /**
  24945. * If the particles must ever face the camera (default false). Useful for planar particles.
  24946. */
  24947. billboard: boolean;
  24948. /**
  24949. * Recompute normals when adding a shape
  24950. */
  24951. recomputeNormals: boolean;
  24952. /**
  24953. * This a counter ofr your own usage. It's not set by any SPS functions.
  24954. */
  24955. counter: number;
  24956. /**
  24957. * The SPS name. This name is also given to the underlying mesh.
  24958. */
  24959. name: string;
  24960. /**
  24961. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24962. */
  24963. mesh: Mesh;
  24964. /**
  24965. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24966. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  24967. */
  24968. vars: any;
  24969. /**
  24970. * This array is populated when the SPS is set as 'pickable'.
  24971. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24972. * Each element of this array is an object `{idx: int, faceId: int}`.
  24973. * `idx` is the picked particle index in the `SPS.particles` array
  24974. * `faceId` is the picked face index counted within this particle.
  24975. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  24976. */
  24977. pickedParticles: {
  24978. idx: number;
  24979. faceId: number;
  24980. }[];
  24981. /**
  24982. * This array is populated when `enableDepthSort` is set to true.
  24983. * Each element of this array is an instance of the class DepthSortedParticle.
  24984. */
  24985. depthSortedParticles: DepthSortedParticle[];
  24986. /**
  24987. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24988. * @hidden
  24989. */
  24990. _bSphereOnly: boolean;
  24991. /**
  24992. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24993. * @hidden
  24994. */
  24995. _bSphereRadiusFactor: number;
  24996. private _scene;
  24997. private _positions;
  24998. private _indices;
  24999. private _normals;
  25000. private _colors;
  25001. private _uvs;
  25002. private _indices32;
  25003. private _positions32;
  25004. private _normals32;
  25005. private _fixedNormal32;
  25006. private _colors32;
  25007. private _uvs32;
  25008. private _index;
  25009. private _updatable;
  25010. private _pickable;
  25011. private _isVisibilityBoxLocked;
  25012. private _alwaysVisible;
  25013. private _depthSort;
  25014. private _shapeCounter;
  25015. private _copy;
  25016. private _color;
  25017. private _computeParticleColor;
  25018. private _computeParticleTexture;
  25019. private _computeParticleRotation;
  25020. private _computeParticleVertex;
  25021. private _computeBoundingBox;
  25022. private _depthSortParticles;
  25023. private _camera;
  25024. private _mustUnrotateFixedNormals;
  25025. private _particlesIntersect;
  25026. private _needs32Bits;
  25027. /**
  25028. * Creates a SPS (Solid Particle System) object.
  25029. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25030. * @param scene (Scene) is the scene in which the SPS is added.
  25031. * @param options defines the options of the sps e.g.
  25032. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25033. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25034. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25035. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25036. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25037. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25038. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25039. */
  25040. constructor(name: string, scene: Scene, options?: {
  25041. updatable?: boolean;
  25042. isPickable?: boolean;
  25043. enableDepthSort?: boolean;
  25044. particleIntersection?: boolean;
  25045. boundingSphereOnly?: boolean;
  25046. bSphereRadiusFactor?: number;
  25047. });
  25048. /**
  25049. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25050. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25051. * @returns the created mesh
  25052. */
  25053. buildMesh(): Mesh;
  25054. /**
  25055. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25056. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25057. * Thus the particles generated from `digest()` have their property `position` set yet.
  25058. * @param mesh ( Mesh ) is the mesh to be digested
  25059. * @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
  25060. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25061. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25062. * @returns the current SPS
  25063. */
  25064. digest(mesh: Mesh, options?: {
  25065. facetNb?: number;
  25066. number?: number;
  25067. delta?: number;
  25068. }): SolidParticleSystem;
  25069. private _unrotateFixedNormals;
  25070. private _resetCopy;
  25071. private _meshBuilder;
  25072. private _posToShape;
  25073. private _uvsToShapeUV;
  25074. private _addParticle;
  25075. /**
  25076. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25077. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25078. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25079. * @param nb (positive integer) the number of particles to be created from this model
  25080. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25081. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25082. * @returns the number of shapes in the system
  25083. */
  25084. addShape(mesh: Mesh, nb: number, options?: {
  25085. positionFunction?: any;
  25086. vertexFunction?: any;
  25087. }): number;
  25088. private _rebuildParticle;
  25089. /**
  25090. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25091. * @returns the SPS.
  25092. */
  25093. rebuildMesh(): SolidParticleSystem;
  25094. /**
  25095. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25096. * This method calls `updateParticle()` for each particle of the SPS.
  25097. * For an animated SPS, it is usually called within the render loop.
  25098. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25099. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25100. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25101. * @returns the SPS.
  25102. */
  25103. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25104. /**
  25105. * Disposes the SPS.
  25106. */
  25107. dispose(): void;
  25108. /**
  25109. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25110. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25111. * @returns the SPS.
  25112. */
  25113. refreshVisibleSize(): SolidParticleSystem;
  25114. /**
  25115. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25116. * @param size the size (float) of the visibility box
  25117. * note : this doesn't lock the SPS mesh bounding box.
  25118. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25119. */
  25120. setVisibilityBox(size: number): void;
  25121. /**
  25122. * Gets whether the SPS as always visible or not
  25123. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25124. */
  25125. /**
  25126. * Sets the SPS as always visible or not
  25127. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25128. */
  25129. isAlwaysVisible: boolean;
  25130. /**
  25131. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25132. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25133. */
  25134. /**
  25135. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25136. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25137. */
  25138. isVisibilityBoxLocked: boolean;
  25139. /**
  25140. * Tells to `setParticles()` to compute the particle rotations or not.
  25141. * Default value : true. The SPS is faster when it's set to false.
  25142. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25143. */
  25144. /**
  25145. * Gets if `setParticles()` computes the particle rotations or not.
  25146. * Default value : true. The SPS is faster when it's set to false.
  25147. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25148. */
  25149. computeParticleRotation: boolean;
  25150. /**
  25151. * Tells to `setParticles()` to compute the particle colors or not.
  25152. * Default value : true. The SPS is faster when it's set to false.
  25153. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25154. */
  25155. /**
  25156. * Gets if `setParticles()` computes the particle colors or not.
  25157. * Default value : true. The SPS is faster when it's set to false.
  25158. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25159. */
  25160. computeParticleColor: boolean;
  25161. /**
  25162. * Gets if `setParticles()` computes the particle textures or not.
  25163. * Default value : true. The SPS is faster when it's set to false.
  25164. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25165. */
  25166. computeParticleTexture: boolean;
  25167. /**
  25168. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25169. * Default value : false. The SPS is faster when it's set to false.
  25170. * Note : the particle custom vertex positions aren't stored values.
  25171. */
  25172. /**
  25173. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25174. * Default value : false. The SPS is faster when it's set to false.
  25175. * Note : the particle custom vertex positions aren't stored values.
  25176. */
  25177. computeParticleVertex: boolean;
  25178. /**
  25179. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25180. */
  25181. /**
  25182. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25183. */
  25184. computeBoundingBox: boolean;
  25185. /**
  25186. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25187. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25188. * Default : `true`
  25189. */
  25190. /**
  25191. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25192. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25193. * Default : `true`
  25194. */
  25195. depthSortParticles: boolean;
  25196. /**
  25197. * This function does nothing. It may be overwritten to set all the particle first values.
  25198. * The SPS doesn't call this function, you may have to call it by your own.
  25199. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25200. */
  25201. initParticles(): void;
  25202. /**
  25203. * This function does nothing. It may be overwritten to recycle a particle.
  25204. * The SPS doesn't call this function, you may have to call it by your own.
  25205. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25206. * @param particle The particle to recycle
  25207. * @returns the recycled particle
  25208. */
  25209. recycleParticle(particle: SolidParticle): SolidParticle;
  25210. /**
  25211. * Updates a particle : this function should be overwritten by the user.
  25212. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25213. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25214. * @example : just set a particle position or velocity and recycle conditions
  25215. * @param particle The particle to update
  25216. * @returns the updated particle
  25217. */
  25218. updateParticle(particle: SolidParticle): SolidParticle;
  25219. /**
  25220. * Updates a vertex of a particle : it can be overwritten by the user.
  25221. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25222. * @param particle the current particle
  25223. * @param vertex the current index of the current particle
  25224. * @param pt the index of the current vertex in the particle shape
  25225. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25226. * @example : just set a vertex particle position
  25227. * @returns the updated vertex
  25228. */
  25229. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25230. /**
  25231. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25232. * This does nothing and may be overwritten by the user.
  25233. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25234. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25235. * @param update the boolean update value actually passed to setParticles()
  25236. */
  25237. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25238. /**
  25239. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25240. * This will be passed three parameters.
  25241. * This does nothing and may be overwritten by the user.
  25242. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25243. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25244. * @param update the boolean update value actually passed to setParticles()
  25245. */
  25246. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25247. }
  25248. }
  25249. declare module BABYLON {
  25250. /**
  25251. * Represents one particle of a solid particle system.
  25252. */
  25253. export class SolidParticle {
  25254. /**
  25255. * particle global index
  25256. */
  25257. idx: number;
  25258. /**
  25259. * The color of the particle
  25260. */
  25261. color: Nullable<Color4>;
  25262. /**
  25263. * The world space position of the particle.
  25264. */
  25265. position: Vector3;
  25266. /**
  25267. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25268. */
  25269. rotation: Vector3;
  25270. /**
  25271. * The world space rotation quaternion of the particle.
  25272. */
  25273. rotationQuaternion: Nullable<Quaternion>;
  25274. /**
  25275. * The scaling of the particle.
  25276. */
  25277. scaling: Vector3;
  25278. /**
  25279. * The uvs of the particle.
  25280. */
  25281. uvs: Vector4;
  25282. /**
  25283. * The current speed of the particle.
  25284. */
  25285. velocity: Vector3;
  25286. /**
  25287. * The pivot point in the particle local space.
  25288. */
  25289. pivot: Vector3;
  25290. /**
  25291. * Must the particle be translated from its pivot point in its local space ?
  25292. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25293. * Default : false
  25294. */
  25295. translateFromPivot: boolean;
  25296. /**
  25297. * Is the particle active or not ?
  25298. */
  25299. alive: boolean;
  25300. /**
  25301. * Is the particle visible or not ?
  25302. */
  25303. isVisible: boolean;
  25304. /**
  25305. * Index of this particle in the global "positions" array (Internal use)
  25306. * @hidden
  25307. */
  25308. _pos: number;
  25309. /**
  25310. * @hidden Index of this particle in the global "indices" array (Internal use)
  25311. */
  25312. _ind: number;
  25313. /**
  25314. * @hidden ModelShape of this particle (Internal use)
  25315. */
  25316. _model: ModelShape;
  25317. /**
  25318. * ModelShape id of this particle
  25319. */
  25320. shapeId: number;
  25321. /**
  25322. * Index of the particle in its shape id (Internal use)
  25323. */
  25324. idxInShape: number;
  25325. /**
  25326. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25327. */
  25328. _modelBoundingInfo: BoundingInfo;
  25329. /**
  25330. * @hidden Particle BoundingInfo object (Internal use)
  25331. */
  25332. _boundingInfo: BoundingInfo;
  25333. /**
  25334. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25335. */
  25336. _sps: SolidParticleSystem;
  25337. /**
  25338. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25339. */
  25340. _stillInvisible: boolean;
  25341. /**
  25342. * @hidden Last computed particle rotation matrix
  25343. */
  25344. _rotationMatrix: number[];
  25345. /**
  25346. * Parent particle Id, if any.
  25347. * Default null.
  25348. */
  25349. parentId: Nullable<number>;
  25350. /**
  25351. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25352. * The possible values are :
  25353. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25354. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25355. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25356. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25357. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25358. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25359. * */
  25360. cullingStrategy: number;
  25361. /**
  25362. * @hidden Internal global position in the SPS.
  25363. */
  25364. _globalPosition: Vector3;
  25365. /**
  25366. * Creates a Solid Particle object.
  25367. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25368. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25369. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25370. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25371. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25372. * @param shapeId (integer) is the model shape identifier in the SPS.
  25373. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25374. * @param sps defines the sps it is associated to
  25375. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25376. */
  25377. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25378. /**
  25379. * Legacy support, changed scale to scaling
  25380. */
  25381. /**
  25382. * Legacy support, changed scale to scaling
  25383. */
  25384. scale: Vector3;
  25385. /**
  25386. * Legacy support, changed quaternion to rotationQuaternion
  25387. */
  25388. /**
  25389. * Legacy support, changed quaternion to rotationQuaternion
  25390. */
  25391. quaternion: Nullable<Quaternion>;
  25392. /**
  25393. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25394. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25395. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25396. * @returns true if it intersects
  25397. */
  25398. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25399. /**
  25400. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25401. * A particle is in the frustum if its bounding box intersects the frustum
  25402. * @param frustumPlanes defines the frustum to test
  25403. * @returns true if the particle is in the frustum planes
  25404. */
  25405. isInFrustum(frustumPlanes: Plane[]): boolean;
  25406. /**
  25407. * get the rotation matrix of the particle
  25408. * @hidden
  25409. */
  25410. getRotationMatrix(m: Matrix): void;
  25411. }
  25412. /**
  25413. * Represents the shape of the model used by one particle of a solid particle system.
  25414. * SPS internal tool, don't use it manually.
  25415. */
  25416. export class ModelShape {
  25417. /**
  25418. * The shape id
  25419. * @hidden
  25420. */
  25421. shapeID: number;
  25422. /**
  25423. * flat array of model positions (internal use)
  25424. * @hidden
  25425. */
  25426. _shape: Vector3[];
  25427. /**
  25428. * flat array of model UVs (internal use)
  25429. * @hidden
  25430. */
  25431. _shapeUV: number[];
  25432. /**
  25433. * length of the shape in the model indices array (internal use)
  25434. * @hidden
  25435. */
  25436. _indicesLength: number;
  25437. /**
  25438. * Custom position function (internal use)
  25439. * @hidden
  25440. */
  25441. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25442. /**
  25443. * Custom vertex function (internal use)
  25444. * @hidden
  25445. */
  25446. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25447. /**
  25448. * 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.
  25449. * SPS internal tool, don't use it manually.
  25450. * @hidden
  25451. */
  25452. 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>);
  25453. }
  25454. /**
  25455. * Represents a Depth Sorted Particle in the solid particle system.
  25456. */
  25457. export class DepthSortedParticle {
  25458. /**
  25459. * Index of the particle in the "indices" array
  25460. */
  25461. ind: number;
  25462. /**
  25463. * Length of the particle shape in the "indices" array
  25464. */
  25465. indicesLength: number;
  25466. /**
  25467. * Squared distance from the particle to the camera
  25468. */
  25469. sqDistance: number;
  25470. }
  25471. }
  25472. declare module BABYLON {
  25473. /**
  25474. * @hidden
  25475. */
  25476. export class _MeshCollisionData {
  25477. _checkCollisions: boolean;
  25478. _collisionMask: number;
  25479. _collisionGroup: number;
  25480. _collider: Nullable<Collider>;
  25481. _oldPositionForCollisions: Vector3;
  25482. _diffPositionForCollisions: Vector3;
  25483. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25484. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25485. }
  25486. }
  25487. declare module BABYLON {
  25488. /** @hidden */
  25489. class _FacetDataStorage {
  25490. facetPositions: Vector3[];
  25491. facetNormals: Vector3[];
  25492. facetPartitioning: number[][];
  25493. facetNb: number;
  25494. partitioningSubdivisions: number;
  25495. partitioningBBoxRatio: number;
  25496. facetDataEnabled: boolean;
  25497. facetParameters: any;
  25498. bbSize: Vector3;
  25499. subDiv: {
  25500. max: number;
  25501. X: number;
  25502. Y: number;
  25503. Z: number;
  25504. };
  25505. facetDepthSort: boolean;
  25506. facetDepthSortEnabled: boolean;
  25507. depthSortedIndices: IndicesArray;
  25508. depthSortedFacets: {
  25509. ind: number;
  25510. sqDistance: number;
  25511. }[];
  25512. facetDepthSortFunction: (f1: {
  25513. ind: number;
  25514. sqDistance: number;
  25515. }, f2: {
  25516. ind: number;
  25517. sqDistance: number;
  25518. }) => number;
  25519. facetDepthSortFrom: Vector3;
  25520. facetDepthSortOrigin: Vector3;
  25521. invertedMatrix: Matrix;
  25522. }
  25523. /**
  25524. * @hidden
  25525. **/
  25526. class _InternalAbstractMeshDataInfo {
  25527. _hasVertexAlpha: boolean;
  25528. _useVertexColors: boolean;
  25529. _numBoneInfluencers: number;
  25530. _applyFog: boolean;
  25531. _receiveShadows: boolean;
  25532. _facetData: _FacetDataStorage;
  25533. _visibility: number;
  25534. _skeleton: Nullable<Skeleton>;
  25535. _layerMask: number;
  25536. _computeBonesUsingShaders: boolean;
  25537. _isActive: boolean;
  25538. _onlyForInstances: boolean;
  25539. _isActiveIntermediate: boolean;
  25540. _onlyForInstancesIntermediate: boolean;
  25541. }
  25542. /**
  25543. * Class used to store all common mesh properties
  25544. */
  25545. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25546. /** No occlusion */
  25547. static OCCLUSION_TYPE_NONE: number;
  25548. /** Occlusion set to optimisitic */
  25549. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25550. /** Occlusion set to strict */
  25551. static OCCLUSION_TYPE_STRICT: number;
  25552. /** Use an accurante occlusion algorithm */
  25553. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25554. /** Use a conservative occlusion algorithm */
  25555. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25556. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25557. * Test order :
  25558. * Is the bounding sphere outside the frustum ?
  25559. * If not, are the bounding box vertices outside the frustum ?
  25560. * It not, then the cullable object is in the frustum.
  25561. */
  25562. static readonly CULLINGSTRATEGY_STANDARD: number;
  25563. /** Culling strategy : Bounding Sphere Only.
  25564. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25565. * It's also less accurate than the standard because some not visible objects can still be selected.
  25566. * Test : is the bounding sphere outside the frustum ?
  25567. * If not, then the cullable object is in the frustum.
  25568. */
  25569. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25570. /** Culling strategy : Optimistic Inclusion.
  25571. * This in an inclusion test first, then the standard exclusion test.
  25572. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25573. * 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.
  25574. * Anyway, it's as accurate as the standard strategy.
  25575. * Test :
  25576. * Is the cullable object bounding sphere center in the frustum ?
  25577. * If not, apply the default culling strategy.
  25578. */
  25579. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25580. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25581. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25582. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25583. * 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.
  25584. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25585. * Test :
  25586. * Is the cullable object bounding sphere center in the frustum ?
  25587. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25588. */
  25589. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25590. /**
  25591. * No billboard
  25592. */
  25593. static readonly BILLBOARDMODE_NONE: number;
  25594. /** Billboard on X axis */
  25595. static readonly BILLBOARDMODE_X: number;
  25596. /** Billboard on Y axis */
  25597. static readonly BILLBOARDMODE_Y: number;
  25598. /** Billboard on Z axis */
  25599. static readonly BILLBOARDMODE_Z: number;
  25600. /** Billboard on all axes */
  25601. static readonly BILLBOARDMODE_ALL: number;
  25602. /** Billboard on using position instead of orientation */
  25603. static readonly BILLBOARDMODE_USE_POSITION: number;
  25604. /** @hidden */
  25605. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25606. /**
  25607. * The culling strategy to use to check whether the mesh must be rendered or not.
  25608. * This value can be changed at any time and will be used on the next render mesh selection.
  25609. * The possible values are :
  25610. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25611. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25612. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25613. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25614. * Please read each static variable documentation to get details about the culling process.
  25615. * */
  25616. cullingStrategy: number;
  25617. /**
  25618. * Gets the number of facets in the mesh
  25619. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25620. */
  25621. readonly facetNb: number;
  25622. /**
  25623. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25624. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25625. */
  25626. partitioningSubdivisions: number;
  25627. /**
  25628. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25629. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25630. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25631. */
  25632. partitioningBBoxRatio: number;
  25633. /**
  25634. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25635. * Works only for updatable meshes.
  25636. * Doesn't work with multi-materials
  25637. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25638. */
  25639. mustDepthSortFacets: boolean;
  25640. /**
  25641. * The location (Vector3) where the facet depth sort must be computed from.
  25642. * By default, the active camera position.
  25643. * Used only when facet depth sort is enabled
  25644. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25645. */
  25646. facetDepthSortFrom: Vector3;
  25647. /**
  25648. * gets a boolean indicating if facetData is enabled
  25649. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25650. */
  25651. readonly isFacetDataEnabled: boolean;
  25652. /** @hidden */
  25653. _updateNonUniformScalingState(value: boolean): boolean;
  25654. /**
  25655. * An event triggered when this mesh collides with another one
  25656. */
  25657. onCollideObservable: Observable<AbstractMesh>;
  25658. /** Set a function to call when this mesh collides with another one */
  25659. onCollide: () => void;
  25660. /**
  25661. * An event triggered when the collision's position changes
  25662. */
  25663. onCollisionPositionChangeObservable: Observable<Vector3>;
  25664. /** Set a function to call when the collision's position changes */
  25665. onCollisionPositionChange: () => void;
  25666. /**
  25667. * An event triggered when material is changed
  25668. */
  25669. onMaterialChangedObservable: Observable<AbstractMesh>;
  25670. /**
  25671. * Gets or sets the orientation for POV movement & rotation
  25672. */
  25673. definedFacingForward: boolean;
  25674. /** @hidden */
  25675. _occlusionQuery: Nullable<WebGLQuery>;
  25676. /** @hidden */
  25677. _renderingGroup: Nullable<RenderingGroup>;
  25678. /**
  25679. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25680. */
  25681. /**
  25682. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25683. */
  25684. visibility: number;
  25685. /** Gets or sets the alpha index used to sort transparent meshes
  25686. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25687. */
  25688. alphaIndex: number;
  25689. /**
  25690. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25691. */
  25692. isVisible: boolean;
  25693. /**
  25694. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25695. */
  25696. isPickable: boolean;
  25697. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25698. showSubMeshesBoundingBox: boolean;
  25699. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25700. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25701. */
  25702. isBlocker: boolean;
  25703. /**
  25704. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25705. */
  25706. enablePointerMoveEvents: boolean;
  25707. /**
  25708. * Specifies the rendering group id for this mesh (0 by default)
  25709. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25710. */
  25711. renderingGroupId: number;
  25712. private _material;
  25713. /** Gets or sets current material */
  25714. material: Nullable<Material>;
  25715. /**
  25716. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25717. * @see http://doc.babylonjs.com/babylon101/shadows
  25718. */
  25719. receiveShadows: boolean;
  25720. /** Defines color to use when rendering outline */
  25721. outlineColor: Color3;
  25722. /** Define width to use when rendering outline */
  25723. outlineWidth: number;
  25724. /** Defines color to use when rendering overlay */
  25725. overlayColor: Color3;
  25726. /** Defines alpha to use when rendering overlay */
  25727. overlayAlpha: number;
  25728. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25729. hasVertexAlpha: boolean;
  25730. /** 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) */
  25731. useVertexColors: boolean;
  25732. /**
  25733. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25734. */
  25735. computeBonesUsingShaders: boolean;
  25736. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25737. numBoneInfluencers: number;
  25738. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25739. applyFog: boolean;
  25740. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25741. useOctreeForRenderingSelection: boolean;
  25742. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25743. useOctreeForPicking: boolean;
  25744. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25745. useOctreeForCollisions: boolean;
  25746. /**
  25747. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25748. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25749. */
  25750. layerMask: number;
  25751. /**
  25752. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25753. */
  25754. alwaysSelectAsActiveMesh: boolean;
  25755. /**
  25756. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25757. */
  25758. doNotSyncBoundingInfo: boolean;
  25759. /**
  25760. * Gets or sets the current action manager
  25761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25762. */
  25763. actionManager: Nullable<AbstractActionManager>;
  25764. private _meshCollisionData;
  25765. /**
  25766. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25767. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25768. */
  25769. ellipsoid: Vector3;
  25770. /**
  25771. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25772. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25773. */
  25774. ellipsoidOffset: Vector3;
  25775. /**
  25776. * Gets or sets a collision mask used to mask collisions (default is -1).
  25777. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25778. */
  25779. collisionMask: number;
  25780. /**
  25781. * Gets or sets the current collision group mask (-1 by default).
  25782. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25783. */
  25784. collisionGroup: number;
  25785. /**
  25786. * Defines edge width used when edgesRenderer is enabled
  25787. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25788. */
  25789. edgesWidth: number;
  25790. /**
  25791. * Defines edge color used when edgesRenderer is enabled
  25792. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25793. */
  25794. edgesColor: Color4;
  25795. /** @hidden */
  25796. _edgesRenderer: Nullable<IEdgesRenderer>;
  25797. /** @hidden */
  25798. _masterMesh: Nullable<AbstractMesh>;
  25799. /** @hidden */
  25800. _boundingInfo: Nullable<BoundingInfo>;
  25801. /** @hidden */
  25802. _renderId: number;
  25803. /**
  25804. * Gets or sets the list of subMeshes
  25805. * @see http://doc.babylonjs.com/how_to/multi_materials
  25806. */
  25807. subMeshes: SubMesh[];
  25808. /** @hidden */
  25809. _intersectionsInProgress: AbstractMesh[];
  25810. /** @hidden */
  25811. _unIndexed: boolean;
  25812. /** @hidden */
  25813. _lightSources: Light[];
  25814. /** Gets the list of lights affecting that mesh */
  25815. readonly lightSources: Light[];
  25816. /** @hidden */
  25817. readonly _positions: Nullable<Vector3[]>;
  25818. /** @hidden */
  25819. _waitingData: {
  25820. lods: Nullable<any>;
  25821. actions: Nullable<any>;
  25822. freezeWorldMatrix: Nullable<boolean>;
  25823. };
  25824. /** @hidden */
  25825. _bonesTransformMatrices: Nullable<Float32Array>;
  25826. /** @hidden */
  25827. _transformMatrixTexture: Nullable<RawTexture>;
  25828. /**
  25829. * Gets or sets a skeleton to apply skining transformations
  25830. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25831. */
  25832. skeleton: Nullable<Skeleton>;
  25833. /**
  25834. * An event triggered when the mesh is rebuilt.
  25835. */
  25836. onRebuildObservable: Observable<AbstractMesh>;
  25837. /**
  25838. * Creates a new AbstractMesh
  25839. * @param name defines the name of the mesh
  25840. * @param scene defines the hosting scene
  25841. */
  25842. constructor(name: string, scene?: Nullable<Scene>);
  25843. /**
  25844. * Returns the string "AbstractMesh"
  25845. * @returns "AbstractMesh"
  25846. */
  25847. getClassName(): string;
  25848. /**
  25849. * Gets a string representation of the current mesh
  25850. * @param fullDetails defines a boolean indicating if full details must be included
  25851. * @returns a string representation of the current mesh
  25852. */
  25853. toString(fullDetails?: boolean): string;
  25854. /**
  25855. * @hidden
  25856. */
  25857. protected _getEffectiveParent(): Nullable<Node>;
  25858. /** @hidden */
  25859. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25860. /** @hidden */
  25861. _rebuild(): void;
  25862. /** @hidden */
  25863. _resyncLightSources(): void;
  25864. /** @hidden */
  25865. _resyncLighSource(light: Light): void;
  25866. /** @hidden */
  25867. _unBindEffect(): void;
  25868. /** @hidden */
  25869. _removeLightSource(light: Light): void;
  25870. private _markSubMeshesAsDirty;
  25871. /** @hidden */
  25872. _markSubMeshesAsLightDirty(): void;
  25873. /** @hidden */
  25874. _markSubMeshesAsAttributesDirty(): void;
  25875. /** @hidden */
  25876. _markSubMeshesAsMiscDirty(): void;
  25877. /**
  25878. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25879. */
  25880. scaling: Vector3;
  25881. /**
  25882. * Returns true if the mesh is blocked. Implemented by child classes
  25883. */
  25884. readonly isBlocked: boolean;
  25885. /**
  25886. * Returns the mesh itself by default. Implemented by child classes
  25887. * @param camera defines the camera to use to pick the right LOD level
  25888. * @returns the currentAbstractMesh
  25889. */
  25890. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25891. /**
  25892. * Returns 0 by default. Implemented by child classes
  25893. * @returns an integer
  25894. */
  25895. getTotalVertices(): number;
  25896. /**
  25897. * Returns a positive integer : the total number of indices in this mesh geometry.
  25898. * @returns the numner of indices or zero if the mesh has no geometry.
  25899. */
  25900. getTotalIndices(): number;
  25901. /**
  25902. * Returns null by default. Implemented by child classes
  25903. * @returns null
  25904. */
  25905. getIndices(): Nullable<IndicesArray>;
  25906. /**
  25907. * Returns the array of the requested vertex data kind. Implemented by child classes
  25908. * @param kind defines the vertex data kind to use
  25909. * @returns null
  25910. */
  25911. getVerticesData(kind: string): Nullable<FloatArray>;
  25912. /**
  25913. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25914. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25915. * Note that a new underlying VertexBuffer object is created each call.
  25916. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25917. * @param kind defines vertex data kind:
  25918. * * VertexBuffer.PositionKind
  25919. * * VertexBuffer.UVKind
  25920. * * VertexBuffer.UV2Kind
  25921. * * VertexBuffer.UV3Kind
  25922. * * VertexBuffer.UV4Kind
  25923. * * VertexBuffer.UV5Kind
  25924. * * VertexBuffer.UV6Kind
  25925. * * VertexBuffer.ColorKind
  25926. * * VertexBuffer.MatricesIndicesKind
  25927. * * VertexBuffer.MatricesIndicesExtraKind
  25928. * * VertexBuffer.MatricesWeightsKind
  25929. * * VertexBuffer.MatricesWeightsExtraKind
  25930. * @param data defines the data source
  25931. * @param updatable defines if the data must be flagged as updatable (or static)
  25932. * @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
  25933. * @returns the current mesh
  25934. */
  25935. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25936. /**
  25937. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25938. * If the mesh has no geometry, it is simply returned as it is.
  25939. * @param kind defines vertex data kind:
  25940. * * VertexBuffer.PositionKind
  25941. * * VertexBuffer.UVKind
  25942. * * VertexBuffer.UV2Kind
  25943. * * VertexBuffer.UV3Kind
  25944. * * VertexBuffer.UV4Kind
  25945. * * VertexBuffer.UV5Kind
  25946. * * VertexBuffer.UV6Kind
  25947. * * VertexBuffer.ColorKind
  25948. * * VertexBuffer.MatricesIndicesKind
  25949. * * VertexBuffer.MatricesIndicesExtraKind
  25950. * * VertexBuffer.MatricesWeightsKind
  25951. * * VertexBuffer.MatricesWeightsExtraKind
  25952. * @param data defines the data source
  25953. * @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
  25954. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25955. * @returns the current mesh
  25956. */
  25957. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25958. /**
  25959. * Sets the mesh indices,
  25960. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25961. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25962. * @param totalVertices Defines the total number of vertices
  25963. * @returns the current mesh
  25964. */
  25965. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25966. /**
  25967. * Gets a boolean indicating if specific vertex data is present
  25968. * @param kind defines the vertex data kind to use
  25969. * @returns true is data kind is present
  25970. */
  25971. isVerticesDataPresent(kind: string): boolean;
  25972. /**
  25973. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  25974. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  25975. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  25976. * @returns a BoundingInfo
  25977. */
  25978. getBoundingInfo(): BoundingInfo;
  25979. /**
  25980. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25981. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25982. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25983. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25984. * @returns the current mesh
  25985. */
  25986. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25987. /**
  25988. * Overwrite the current bounding info
  25989. * @param boundingInfo defines the new bounding info
  25990. * @returns the current mesh
  25991. */
  25992. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25993. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25994. readonly useBones: boolean;
  25995. /** @hidden */
  25996. _preActivate(): void;
  25997. /** @hidden */
  25998. _preActivateForIntermediateRendering(renderId: number): void;
  25999. /** @hidden */
  26000. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26001. /** @hidden */
  26002. _postActivate(): void;
  26003. /** @hidden */
  26004. _freeze(): void;
  26005. /** @hidden */
  26006. _unFreeze(): void;
  26007. /**
  26008. * Gets the current world matrix
  26009. * @returns a Matrix
  26010. */
  26011. getWorldMatrix(): Matrix;
  26012. /** @hidden */
  26013. _getWorldMatrixDeterminant(): number;
  26014. /**
  26015. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26016. */
  26017. readonly isAnInstance: boolean;
  26018. /**
  26019. * Gets a boolean indicating if this mesh has instances
  26020. */
  26021. readonly hasInstances: boolean;
  26022. /**
  26023. * Perform relative position change from the point of view of behind the front of the mesh.
  26024. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26025. * Supports definition of mesh facing forward or backward
  26026. * @param amountRight defines the distance on the right axis
  26027. * @param amountUp defines the distance on the up axis
  26028. * @param amountForward defines the distance on the forward axis
  26029. * @returns the current mesh
  26030. */
  26031. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26032. /**
  26033. * Calculate relative position change from the point of view of behind the front of the mesh.
  26034. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26035. * Supports definition of mesh facing forward or backward
  26036. * @param amountRight defines the distance on the right axis
  26037. * @param amountUp defines the distance on the up axis
  26038. * @param amountForward defines the distance on the forward axis
  26039. * @returns the new displacement vector
  26040. */
  26041. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26042. /**
  26043. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26044. * Supports definition of mesh facing forward or backward
  26045. * @param flipBack defines the flip
  26046. * @param twirlClockwise defines the twirl
  26047. * @param tiltRight defines the tilt
  26048. * @returns the current mesh
  26049. */
  26050. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26051. /**
  26052. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26053. * Supports definition of mesh facing forward or backward.
  26054. * @param flipBack defines the flip
  26055. * @param twirlClockwise defines the twirl
  26056. * @param tiltRight defines the tilt
  26057. * @returns the new rotation vector
  26058. */
  26059. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26060. /**
  26061. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26062. * This means the mesh underlying bounding box and sphere are recomputed.
  26063. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26064. * @returns the current mesh
  26065. */
  26066. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26067. /** @hidden */
  26068. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26069. /** @hidden */
  26070. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26071. /** @hidden */
  26072. _updateBoundingInfo(): AbstractMesh;
  26073. /** @hidden */
  26074. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26075. /** @hidden */
  26076. protected _afterComputeWorldMatrix(): void;
  26077. /** @hidden */
  26078. readonly _effectiveMesh: AbstractMesh;
  26079. /**
  26080. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26081. * A mesh is in the frustum if its bounding box intersects the frustum
  26082. * @param frustumPlanes defines the frustum to test
  26083. * @returns true if the mesh is in the frustum planes
  26084. */
  26085. isInFrustum(frustumPlanes: Plane[]): boolean;
  26086. /**
  26087. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26088. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26089. * @param frustumPlanes defines the frustum to test
  26090. * @returns true if the mesh is completely in the frustum planes
  26091. */
  26092. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26093. /**
  26094. * True if the mesh intersects another mesh or a SolidParticle object
  26095. * @param mesh defines a target mesh or SolidParticle to test
  26096. * @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)
  26097. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26098. * @returns true if there is an intersection
  26099. */
  26100. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26101. /**
  26102. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26103. * @param point defines the point to test
  26104. * @returns true if there is an intersection
  26105. */
  26106. intersectsPoint(point: Vector3): boolean;
  26107. /**
  26108. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26109. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26110. */
  26111. checkCollisions: boolean;
  26112. /**
  26113. * Gets Collider object used to compute collisions (not physics)
  26114. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26115. */
  26116. readonly collider: Nullable<Collider>;
  26117. /**
  26118. * Move the mesh using collision engine
  26119. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26120. * @param displacement defines the requested displacement vector
  26121. * @returns the current mesh
  26122. */
  26123. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26124. private _onCollisionPositionChange;
  26125. /** @hidden */
  26126. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26127. /** @hidden */
  26128. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26129. /** @hidden */
  26130. _checkCollision(collider: Collider): AbstractMesh;
  26131. /** @hidden */
  26132. _generatePointsArray(): boolean;
  26133. /**
  26134. * Checks if the passed Ray intersects with the mesh
  26135. * @param ray defines the ray to use
  26136. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26137. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26138. * @returns the picking info
  26139. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26140. */
  26141. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26142. /**
  26143. * Clones the current mesh
  26144. * @param name defines the mesh name
  26145. * @param newParent defines the new mesh parent
  26146. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26147. * @returns the new mesh
  26148. */
  26149. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26150. /**
  26151. * Disposes all the submeshes of the current meshnp
  26152. * @returns the current mesh
  26153. */
  26154. releaseSubMeshes(): AbstractMesh;
  26155. /**
  26156. * Releases resources associated with this abstract mesh.
  26157. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26158. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26159. */
  26160. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26161. /**
  26162. * Adds the passed mesh as a child to the current mesh
  26163. * @param mesh defines the child mesh
  26164. * @returns the current mesh
  26165. */
  26166. addChild(mesh: AbstractMesh): AbstractMesh;
  26167. /**
  26168. * Removes the passed mesh from the current mesh children list
  26169. * @param mesh defines the child mesh
  26170. * @returns the current mesh
  26171. */
  26172. removeChild(mesh: AbstractMesh): AbstractMesh;
  26173. /** @hidden */
  26174. private _initFacetData;
  26175. /**
  26176. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26177. * This method can be called within the render loop.
  26178. * 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
  26179. * @returns the current mesh
  26180. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26181. */
  26182. updateFacetData(): AbstractMesh;
  26183. /**
  26184. * Returns the facetLocalNormals array.
  26185. * The normals are expressed in the mesh local spac
  26186. * @returns an array of Vector3
  26187. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26188. */
  26189. getFacetLocalNormals(): Vector3[];
  26190. /**
  26191. * Returns the facetLocalPositions array.
  26192. * The facet positions are expressed in the mesh local space
  26193. * @returns an array of Vector3
  26194. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26195. */
  26196. getFacetLocalPositions(): Vector3[];
  26197. /**
  26198. * Returns the facetLocalPartioning array
  26199. * @returns an array of array of numbers
  26200. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26201. */
  26202. getFacetLocalPartitioning(): number[][];
  26203. /**
  26204. * Returns the i-th facet position in the world system.
  26205. * This method allocates a new Vector3 per call
  26206. * @param i defines the facet index
  26207. * @returns a new Vector3
  26208. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26209. */
  26210. getFacetPosition(i: number): Vector3;
  26211. /**
  26212. * Sets the reference Vector3 with the i-th facet position in the world system
  26213. * @param i defines the facet index
  26214. * @param ref defines the target vector
  26215. * @returns the current mesh
  26216. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26217. */
  26218. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26219. /**
  26220. * Returns the i-th facet normal in the world system.
  26221. * This method allocates a new Vector3 per call
  26222. * @param i defines the facet index
  26223. * @returns a new Vector3
  26224. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26225. */
  26226. getFacetNormal(i: number): Vector3;
  26227. /**
  26228. * Sets the reference Vector3 with the i-th facet normal in the world system
  26229. * @param i defines the facet index
  26230. * @param ref defines the target vector
  26231. * @returns the current mesh
  26232. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26233. */
  26234. getFacetNormalToRef(i: number, ref: Vector3): this;
  26235. /**
  26236. * 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)
  26237. * @param x defines x coordinate
  26238. * @param y defines y coordinate
  26239. * @param z defines z coordinate
  26240. * @returns the array of facet indexes
  26241. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26242. */
  26243. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26244. /**
  26245. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26246. * @param projected sets as the (x,y,z) world projection on the facet
  26247. * @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
  26248. * @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
  26249. * @param x defines x coordinate
  26250. * @param y defines y coordinate
  26251. * @param z defines z coordinate
  26252. * @returns the face index if found (or null instead)
  26253. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26254. */
  26255. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26256. /**
  26257. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26258. * @param projected sets as the (x,y,z) local projection on the facet
  26259. * @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
  26260. * @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
  26261. * @param x defines x coordinate
  26262. * @param y defines y coordinate
  26263. * @param z defines z coordinate
  26264. * @returns the face index if found (or null instead)
  26265. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26266. */
  26267. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26268. /**
  26269. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26270. * @returns the parameters
  26271. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26272. */
  26273. getFacetDataParameters(): any;
  26274. /**
  26275. * Disables the feature FacetData and frees the related memory
  26276. * @returns the current mesh
  26277. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26278. */
  26279. disableFacetData(): AbstractMesh;
  26280. /**
  26281. * Updates the AbstractMesh indices array
  26282. * @param indices defines the data source
  26283. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26284. * @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)
  26285. * @returns the current mesh
  26286. */
  26287. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26288. /**
  26289. * Creates new normals data for the mesh
  26290. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26291. * @returns the current mesh
  26292. */
  26293. createNormals(updatable: boolean): AbstractMesh;
  26294. /**
  26295. * Align the mesh with a normal
  26296. * @param normal defines the normal to use
  26297. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26298. * @returns the current mesh
  26299. */
  26300. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26301. /** @hidden */
  26302. _checkOcclusionQuery(): boolean;
  26303. /**
  26304. * Disables the mesh edge rendering mode
  26305. * @returns the currentAbstractMesh
  26306. */
  26307. disableEdgesRendering(): AbstractMesh;
  26308. /**
  26309. * Enables the edge rendering mode on the mesh.
  26310. * This mode makes the mesh edges visible
  26311. * @param epsilon defines the maximal distance between two angles to detect a face
  26312. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26313. * @returns the currentAbstractMesh
  26314. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26315. */
  26316. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26317. }
  26318. }
  26319. declare module BABYLON {
  26320. /**
  26321. * Interface used to define ActionEvent
  26322. */
  26323. export interface IActionEvent {
  26324. /** The mesh or sprite that triggered the action */
  26325. source: any;
  26326. /** The X mouse cursor position at the time of the event */
  26327. pointerX: number;
  26328. /** The Y mouse cursor position at the time of the event */
  26329. pointerY: number;
  26330. /** The mesh that is currently pointed at (can be null) */
  26331. meshUnderPointer: Nullable<AbstractMesh>;
  26332. /** the original (browser) event that triggered the ActionEvent */
  26333. sourceEvent?: any;
  26334. /** additional data for the event */
  26335. additionalData?: any;
  26336. }
  26337. /**
  26338. * ActionEvent is the event being sent when an action is triggered.
  26339. */
  26340. export class ActionEvent implements IActionEvent {
  26341. /** The mesh or sprite that triggered the action */
  26342. source: any;
  26343. /** The X mouse cursor position at the time of the event */
  26344. pointerX: number;
  26345. /** The Y mouse cursor position at the time of the event */
  26346. pointerY: number;
  26347. /** The mesh that is currently pointed at (can be null) */
  26348. meshUnderPointer: Nullable<AbstractMesh>;
  26349. /** the original (browser) event that triggered the ActionEvent */
  26350. sourceEvent?: any;
  26351. /** additional data for the event */
  26352. additionalData?: any;
  26353. /**
  26354. * Creates a new ActionEvent
  26355. * @param source The mesh or sprite that triggered the action
  26356. * @param pointerX The X mouse cursor position at the time of the event
  26357. * @param pointerY The Y mouse cursor position at the time of the event
  26358. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26359. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26360. * @param additionalData additional data for the event
  26361. */
  26362. constructor(
  26363. /** The mesh or sprite that triggered the action */
  26364. source: any,
  26365. /** The X mouse cursor position at the time of the event */
  26366. pointerX: number,
  26367. /** The Y mouse cursor position at the time of the event */
  26368. pointerY: number,
  26369. /** The mesh that is currently pointed at (can be null) */
  26370. meshUnderPointer: Nullable<AbstractMesh>,
  26371. /** the original (browser) event that triggered the ActionEvent */
  26372. sourceEvent?: any,
  26373. /** additional data for the event */
  26374. additionalData?: any);
  26375. /**
  26376. * Helper function to auto-create an ActionEvent from a source mesh.
  26377. * @param source The source mesh that triggered the event
  26378. * @param evt The original (browser) event
  26379. * @param additionalData additional data for the event
  26380. * @returns the new ActionEvent
  26381. */
  26382. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26383. /**
  26384. * Helper function to auto-create an ActionEvent from a source sprite
  26385. * @param source The source sprite that triggered the event
  26386. * @param scene Scene associated with the sprite
  26387. * @param evt The original (browser) event
  26388. * @param additionalData additional data for the event
  26389. * @returns the new ActionEvent
  26390. */
  26391. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26392. /**
  26393. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26394. * @param scene the scene where the event occurred
  26395. * @param evt The original (browser) event
  26396. * @returns the new ActionEvent
  26397. */
  26398. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26399. /**
  26400. * Helper function to auto-create an ActionEvent from a primitive
  26401. * @param prim defines the target primitive
  26402. * @param pointerPos defines the pointer position
  26403. * @param evt The original (browser) event
  26404. * @param additionalData additional data for the event
  26405. * @returns the new ActionEvent
  26406. */
  26407. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26408. }
  26409. }
  26410. declare module BABYLON {
  26411. /**
  26412. * Abstract class used to decouple action Manager from scene and meshes.
  26413. * Do not instantiate.
  26414. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26415. */
  26416. export abstract class AbstractActionManager implements IDisposable {
  26417. /** Gets the list of active triggers */
  26418. static Triggers: {
  26419. [key: string]: number;
  26420. };
  26421. /** Gets the cursor to use when hovering items */
  26422. hoverCursor: string;
  26423. /** Gets the list of actions */
  26424. actions: IAction[];
  26425. /**
  26426. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26427. */
  26428. isRecursive: boolean;
  26429. /**
  26430. * Releases all associated resources
  26431. */
  26432. abstract dispose(): void;
  26433. /**
  26434. * Does this action manager has pointer triggers
  26435. */
  26436. abstract readonly hasPointerTriggers: boolean;
  26437. /**
  26438. * Does this action manager has pick triggers
  26439. */
  26440. abstract readonly hasPickTriggers: boolean;
  26441. /**
  26442. * Process a specific trigger
  26443. * @param trigger defines the trigger to process
  26444. * @param evt defines the event details to be processed
  26445. */
  26446. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26447. /**
  26448. * Does this action manager handles actions of any of the given triggers
  26449. * @param triggers defines the triggers to be tested
  26450. * @return a boolean indicating whether one (or more) of the triggers is handled
  26451. */
  26452. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26453. /**
  26454. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26455. * speed.
  26456. * @param triggerA defines the trigger to be tested
  26457. * @param triggerB defines the trigger to be tested
  26458. * @return a boolean indicating whether one (or more) of the triggers is handled
  26459. */
  26460. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26461. /**
  26462. * Does this action manager handles actions of a given trigger
  26463. * @param trigger defines the trigger to be tested
  26464. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26465. * @return whether the trigger is handled
  26466. */
  26467. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26468. /**
  26469. * Serialize this manager to a JSON object
  26470. * @param name defines the property name to store this manager
  26471. * @returns a JSON representation of this manager
  26472. */
  26473. abstract serialize(name: string): any;
  26474. /**
  26475. * Registers an action to this action manager
  26476. * @param action defines the action to be registered
  26477. * @return the action amended (prepared) after registration
  26478. */
  26479. abstract registerAction(action: IAction): Nullable<IAction>;
  26480. /**
  26481. * Unregisters an action to this action manager
  26482. * @param action defines the action to be unregistered
  26483. * @return a boolean indicating whether the action has been unregistered
  26484. */
  26485. abstract unregisterAction(action: IAction): Boolean;
  26486. /**
  26487. * Does exist one action manager with at least one trigger
  26488. **/
  26489. static readonly HasTriggers: boolean;
  26490. /**
  26491. * Does exist one action manager with at least one pick trigger
  26492. **/
  26493. static readonly HasPickTriggers: boolean;
  26494. /**
  26495. * Does exist one action manager that handles actions of a given trigger
  26496. * @param trigger defines the trigger to be tested
  26497. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26498. **/
  26499. static HasSpecificTrigger(trigger: number): boolean;
  26500. }
  26501. }
  26502. declare module BABYLON {
  26503. /**
  26504. * Defines how a node can be built from a string name.
  26505. */
  26506. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26507. /**
  26508. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26509. */
  26510. export class Node implements IBehaviorAware<Node> {
  26511. /** @hidden */
  26512. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26513. private static _NodeConstructors;
  26514. /**
  26515. * Add a new node constructor
  26516. * @param type defines the type name of the node to construct
  26517. * @param constructorFunc defines the constructor function
  26518. */
  26519. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26520. /**
  26521. * Returns a node constructor based on type name
  26522. * @param type defines the type name
  26523. * @param name defines the new node name
  26524. * @param scene defines the hosting scene
  26525. * @param options defines optional options to transmit to constructors
  26526. * @returns the new constructor or null
  26527. */
  26528. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26529. /**
  26530. * Gets or sets the name of the node
  26531. */
  26532. name: string;
  26533. /**
  26534. * Gets or sets the id of the node
  26535. */
  26536. id: string;
  26537. /**
  26538. * Gets or sets the unique id of the node
  26539. */
  26540. uniqueId: number;
  26541. /**
  26542. * Gets or sets a string used to store user defined state for the node
  26543. */
  26544. state: string;
  26545. /**
  26546. * Gets or sets an object used to store user defined information for the node
  26547. */
  26548. metadata: any;
  26549. /**
  26550. * For internal use only. Please do not use.
  26551. */
  26552. reservedDataStore: any;
  26553. /**
  26554. * List of inspectable custom properties (used by the Inspector)
  26555. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26556. */
  26557. inspectableCustomProperties: IInspectable[];
  26558. /**
  26559. * Gets or sets a boolean used to define if the node must be serialized
  26560. */
  26561. doNotSerialize: boolean;
  26562. /** @hidden */
  26563. _isDisposed: boolean;
  26564. /**
  26565. * Gets a list of Animations associated with the node
  26566. */
  26567. animations: Animation[];
  26568. protected _ranges: {
  26569. [name: string]: Nullable<AnimationRange>;
  26570. };
  26571. /**
  26572. * Callback raised when the node is ready to be used
  26573. */
  26574. onReady: Nullable<(node: Node) => void>;
  26575. private _isEnabled;
  26576. private _isParentEnabled;
  26577. private _isReady;
  26578. /** @hidden */
  26579. _currentRenderId: number;
  26580. private _parentUpdateId;
  26581. /** @hidden */
  26582. _childUpdateId: number;
  26583. /** @hidden */
  26584. _waitingParentId: Nullable<string>;
  26585. /** @hidden */
  26586. _scene: Scene;
  26587. /** @hidden */
  26588. _cache: any;
  26589. private _parentNode;
  26590. private _children;
  26591. /** @hidden */
  26592. _worldMatrix: Matrix;
  26593. /** @hidden */
  26594. _worldMatrixDeterminant: number;
  26595. /** @hidden */
  26596. _worldMatrixDeterminantIsDirty: boolean;
  26597. /** @hidden */
  26598. private _sceneRootNodesIndex;
  26599. /**
  26600. * Gets a boolean indicating if the node has been disposed
  26601. * @returns true if the node was disposed
  26602. */
  26603. isDisposed(): boolean;
  26604. /**
  26605. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26606. * @see https://doc.babylonjs.com/how_to/parenting
  26607. */
  26608. parent: Nullable<Node>;
  26609. private addToSceneRootNodes;
  26610. private removeFromSceneRootNodes;
  26611. private _animationPropertiesOverride;
  26612. /**
  26613. * Gets or sets the animation properties override
  26614. */
  26615. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26616. /**
  26617. * Gets a string idenfifying the name of the class
  26618. * @returns "Node" string
  26619. */
  26620. getClassName(): string;
  26621. /** @hidden */
  26622. readonly _isNode: boolean;
  26623. /**
  26624. * An event triggered when the mesh is disposed
  26625. */
  26626. onDisposeObservable: Observable<Node>;
  26627. private _onDisposeObserver;
  26628. /**
  26629. * Sets a callback that will be raised when the node will be disposed
  26630. */
  26631. onDispose: () => void;
  26632. /**
  26633. * Creates a new Node
  26634. * @param name the name and id to be given to this node
  26635. * @param scene the scene this node will be added to
  26636. * @param addToRootNodes the node will be added to scene.rootNodes
  26637. */
  26638. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26639. /**
  26640. * Gets the scene of the node
  26641. * @returns a scene
  26642. */
  26643. getScene(): Scene;
  26644. /**
  26645. * Gets the engine of the node
  26646. * @returns a Engine
  26647. */
  26648. getEngine(): Engine;
  26649. private _behaviors;
  26650. /**
  26651. * Attach a behavior to the node
  26652. * @see http://doc.babylonjs.com/features/behaviour
  26653. * @param behavior defines the behavior to attach
  26654. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26655. * @returns the current Node
  26656. */
  26657. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26658. /**
  26659. * Remove an attached behavior
  26660. * @see http://doc.babylonjs.com/features/behaviour
  26661. * @param behavior defines the behavior to attach
  26662. * @returns the current Node
  26663. */
  26664. removeBehavior(behavior: Behavior<Node>): Node;
  26665. /**
  26666. * Gets the list of attached behaviors
  26667. * @see http://doc.babylonjs.com/features/behaviour
  26668. */
  26669. readonly behaviors: Behavior<Node>[];
  26670. /**
  26671. * Gets an attached behavior by name
  26672. * @param name defines the name of the behavior to look for
  26673. * @see http://doc.babylonjs.com/features/behaviour
  26674. * @returns null if behavior was not found else the requested behavior
  26675. */
  26676. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26677. /**
  26678. * Returns the latest update of the World matrix
  26679. * @returns a Matrix
  26680. */
  26681. getWorldMatrix(): Matrix;
  26682. /** @hidden */
  26683. _getWorldMatrixDeterminant(): number;
  26684. /**
  26685. * Returns directly the latest state of the mesh World matrix.
  26686. * A Matrix is returned.
  26687. */
  26688. readonly worldMatrixFromCache: Matrix;
  26689. /** @hidden */
  26690. _initCache(): void;
  26691. /** @hidden */
  26692. updateCache(force?: boolean): void;
  26693. /** @hidden */
  26694. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26695. /** @hidden */
  26696. _updateCache(ignoreParentClass?: boolean): void;
  26697. /** @hidden */
  26698. _isSynchronized(): boolean;
  26699. /** @hidden */
  26700. _markSyncedWithParent(): void;
  26701. /** @hidden */
  26702. isSynchronizedWithParent(): boolean;
  26703. /** @hidden */
  26704. isSynchronized(): boolean;
  26705. /**
  26706. * Is this node ready to be used/rendered
  26707. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26708. * @return true if the node is ready
  26709. */
  26710. isReady(completeCheck?: boolean): boolean;
  26711. /**
  26712. * Is this node enabled?
  26713. * 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
  26714. * @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
  26715. * @return whether this node (and its parent) is enabled
  26716. */
  26717. isEnabled(checkAncestors?: boolean): boolean;
  26718. /** @hidden */
  26719. protected _syncParentEnabledState(): void;
  26720. /**
  26721. * Set the enabled state of this node
  26722. * @param value defines the new enabled state
  26723. */
  26724. setEnabled(value: boolean): void;
  26725. /**
  26726. * Is this node a descendant of the given node?
  26727. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26728. * @param ancestor defines the parent node to inspect
  26729. * @returns a boolean indicating if this node is a descendant of the given node
  26730. */
  26731. isDescendantOf(ancestor: Node): boolean;
  26732. /** @hidden */
  26733. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26734. /**
  26735. * Will return all nodes that have this node as ascendant
  26736. * @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
  26737. * @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
  26738. * @return all children nodes of all types
  26739. */
  26740. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26741. /**
  26742. * Get all child-meshes of this node
  26743. * @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)
  26744. * @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
  26745. * @returns an array of AbstractMesh
  26746. */
  26747. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26748. /**
  26749. * Get all direct children of this node
  26750. * @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
  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: true)
  26752. * @returns an array of Node
  26753. */
  26754. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26755. /** @hidden */
  26756. _setReady(state: boolean): void;
  26757. /**
  26758. * Get an animation by name
  26759. * @param name defines the name of the animation to look for
  26760. * @returns null if not found else the requested animation
  26761. */
  26762. getAnimationByName(name: string): Nullable<Animation>;
  26763. /**
  26764. * Creates an animation range for this node
  26765. * @param name defines the name of the range
  26766. * @param from defines the starting key
  26767. * @param to defines the end key
  26768. */
  26769. createAnimationRange(name: string, from: number, to: number): void;
  26770. /**
  26771. * Delete a specific animation range
  26772. * @param name defines the name of the range to delete
  26773. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26774. */
  26775. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26776. /**
  26777. * Get an animation range by name
  26778. * @param name defines the name of the animation range to look for
  26779. * @returns null if not found else the requested animation range
  26780. */
  26781. getAnimationRange(name: string): Nullable<AnimationRange>;
  26782. /**
  26783. * Gets the list of all animation ranges defined on this node
  26784. * @returns an array
  26785. */
  26786. getAnimationRanges(): Nullable<AnimationRange>[];
  26787. /**
  26788. * Will start the animation sequence
  26789. * @param name defines the range frames for animation sequence
  26790. * @param loop defines if the animation should loop (false by default)
  26791. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26792. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26793. * @returns the object created for this animation. If range does not exist, it will return null
  26794. */
  26795. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26796. /**
  26797. * Serialize animation ranges into a JSON compatible object
  26798. * @returns serialization object
  26799. */
  26800. serializeAnimationRanges(): any;
  26801. /**
  26802. * Computes the world matrix of the node
  26803. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26804. * @returns the world matrix
  26805. */
  26806. computeWorldMatrix(force?: boolean): Matrix;
  26807. /**
  26808. * Releases resources associated with this node.
  26809. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26810. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26811. */
  26812. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26813. /**
  26814. * Parse animation range data from a serialization object and store them into a given node
  26815. * @param node defines where to store the animation ranges
  26816. * @param parsedNode defines the serialization object to read data from
  26817. * @param scene defines the hosting scene
  26818. */
  26819. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26820. /**
  26821. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26822. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26823. * @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
  26824. * @returns the new bounding vectors
  26825. */
  26826. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26827. min: Vector3;
  26828. max: Vector3;
  26829. };
  26830. }
  26831. }
  26832. declare module BABYLON {
  26833. /**
  26834. * @hidden
  26835. */
  26836. export class _IAnimationState {
  26837. key: number;
  26838. repeatCount: number;
  26839. workValue?: any;
  26840. loopMode?: number;
  26841. offsetValue?: any;
  26842. highLimitValue?: any;
  26843. }
  26844. /**
  26845. * Class used to store any kind of animation
  26846. */
  26847. export class Animation {
  26848. /**Name of the animation */
  26849. name: string;
  26850. /**Property to animate */
  26851. targetProperty: string;
  26852. /**The frames per second of the animation */
  26853. framePerSecond: number;
  26854. /**The data type of the animation */
  26855. dataType: number;
  26856. /**The loop mode of the animation */
  26857. loopMode?: number | undefined;
  26858. /**Specifies if blending should be enabled */
  26859. enableBlending?: boolean | undefined;
  26860. /**
  26861. * Use matrix interpolation instead of using direct key value when animating matrices
  26862. */
  26863. static AllowMatricesInterpolation: boolean;
  26864. /**
  26865. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26866. */
  26867. static AllowMatrixDecomposeForInterpolation: boolean;
  26868. /**
  26869. * Stores the key frames of the animation
  26870. */
  26871. private _keys;
  26872. /**
  26873. * Stores the easing function of the animation
  26874. */
  26875. private _easingFunction;
  26876. /**
  26877. * @hidden Internal use only
  26878. */
  26879. _runtimeAnimations: RuntimeAnimation[];
  26880. /**
  26881. * The set of event that will be linked to this animation
  26882. */
  26883. private _events;
  26884. /**
  26885. * Stores an array of target property paths
  26886. */
  26887. targetPropertyPath: string[];
  26888. /**
  26889. * Stores the blending speed of the animation
  26890. */
  26891. blendingSpeed: number;
  26892. /**
  26893. * Stores the animation ranges for the animation
  26894. */
  26895. private _ranges;
  26896. /**
  26897. * @hidden Internal use
  26898. */
  26899. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26900. /**
  26901. * Sets up an animation
  26902. * @param property The property to animate
  26903. * @param animationType The animation type to apply
  26904. * @param framePerSecond The frames per second of the animation
  26905. * @param easingFunction The easing function used in the animation
  26906. * @returns The created animation
  26907. */
  26908. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26909. /**
  26910. * Create and start an animation on a node
  26911. * @param name defines the name of the global animation that will be run on all nodes
  26912. * @param node defines the root node where the animation will take place
  26913. * @param targetProperty defines property to animate
  26914. * @param framePerSecond defines the number of frame per second yo use
  26915. * @param totalFrame defines the number of frames in total
  26916. * @param from defines the initial value
  26917. * @param to defines the final value
  26918. * @param loopMode defines which loop mode you want to use (off by default)
  26919. * @param easingFunction defines the easing function to use (linear by default)
  26920. * @param onAnimationEnd defines the callback to call when animation end
  26921. * @returns the animatable created for this animation
  26922. */
  26923. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26924. /**
  26925. * Create and start an animation on a node and its descendants
  26926. * @param name defines the name of the global animation that will be run on all nodes
  26927. * @param node defines the root node where the animation will take place
  26928. * @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
  26929. * @param targetProperty defines property to animate
  26930. * @param framePerSecond defines the number of frame per second to use
  26931. * @param totalFrame defines the number of frames in total
  26932. * @param from defines the initial value
  26933. * @param to defines the final value
  26934. * @param loopMode defines which loop mode you want to use (off by default)
  26935. * @param easingFunction defines the easing function to use (linear by default)
  26936. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26937. * @returns the list of animatables created for all nodes
  26938. * @example https://www.babylonjs-playground.com/#MH0VLI
  26939. */
  26940. 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[]>;
  26941. /**
  26942. * Creates a new animation, merges it with the existing animations and starts it
  26943. * @param name Name of the animation
  26944. * @param node Node which contains the scene that begins the animations
  26945. * @param targetProperty Specifies which property to animate
  26946. * @param framePerSecond The frames per second of the animation
  26947. * @param totalFrame The total number of frames
  26948. * @param from The frame at the beginning of the animation
  26949. * @param to The frame at the end of the animation
  26950. * @param loopMode Specifies the loop mode of the animation
  26951. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26952. * @param onAnimationEnd Callback to run once the animation is complete
  26953. * @returns Nullable animation
  26954. */
  26955. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26956. /**
  26957. * Transition property of an host to the target Value
  26958. * @param property The property to transition
  26959. * @param targetValue The target Value of the property
  26960. * @param host The object where the property to animate belongs
  26961. * @param scene Scene used to run the animation
  26962. * @param frameRate Framerate (in frame/s) to use
  26963. * @param transition The transition type we want to use
  26964. * @param duration The duration of the animation, in milliseconds
  26965. * @param onAnimationEnd Callback trigger at the end of the animation
  26966. * @returns Nullable animation
  26967. */
  26968. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26969. /**
  26970. * Return the array of runtime animations currently using this animation
  26971. */
  26972. readonly runtimeAnimations: RuntimeAnimation[];
  26973. /**
  26974. * Specifies if any of the runtime animations are currently running
  26975. */
  26976. readonly hasRunningRuntimeAnimations: boolean;
  26977. /**
  26978. * Initializes the animation
  26979. * @param name Name of the animation
  26980. * @param targetProperty Property to animate
  26981. * @param framePerSecond The frames per second of the animation
  26982. * @param dataType The data type of the animation
  26983. * @param loopMode The loop mode of the animation
  26984. * @param enableBlending Specifies if blending should be enabled
  26985. */
  26986. constructor(
  26987. /**Name of the animation */
  26988. name: string,
  26989. /**Property to animate */
  26990. targetProperty: string,
  26991. /**The frames per second of the animation */
  26992. framePerSecond: number,
  26993. /**The data type of the animation */
  26994. dataType: number,
  26995. /**The loop mode of the animation */
  26996. loopMode?: number | undefined,
  26997. /**Specifies if blending should be enabled */
  26998. enableBlending?: boolean | undefined);
  26999. /**
  27000. * Converts the animation to a string
  27001. * @param fullDetails support for multiple levels of logging within scene loading
  27002. * @returns String form of the animation
  27003. */
  27004. toString(fullDetails?: boolean): string;
  27005. /**
  27006. * Add an event to this animation
  27007. * @param event Event to add
  27008. */
  27009. addEvent(event: AnimationEvent): void;
  27010. /**
  27011. * Remove all events found at the given frame
  27012. * @param frame The frame to remove events from
  27013. */
  27014. removeEvents(frame: number): void;
  27015. /**
  27016. * Retrieves all the events from the animation
  27017. * @returns Events from the animation
  27018. */
  27019. getEvents(): AnimationEvent[];
  27020. /**
  27021. * Creates an animation range
  27022. * @param name Name of the animation range
  27023. * @param from Starting frame of the animation range
  27024. * @param to Ending frame of the animation
  27025. */
  27026. createRange(name: string, from: number, to: number): void;
  27027. /**
  27028. * Deletes an animation range by name
  27029. * @param name Name of the animation range to delete
  27030. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27031. */
  27032. deleteRange(name: string, deleteFrames?: boolean): void;
  27033. /**
  27034. * Gets the animation range by name, or null if not defined
  27035. * @param name Name of the animation range
  27036. * @returns Nullable animation range
  27037. */
  27038. getRange(name: string): Nullable<AnimationRange>;
  27039. /**
  27040. * Gets the key frames from the animation
  27041. * @returns The key frames of the animation
  27042. */
  27043. getKeys(): Array<IAnimationKey>;
  27044. /**
  27045. * Gets the highest frame rate of the animation
  27046. * @returns Highest frame rate of the animation
  27047. */
  27048. getHighestFrame(): number;
  27049. /**
  27050. * Gets the easing function of the animation
  27051. * @returns Easing function of the animation
  27052. */
  27053. getEasingFunction(): IEasingFunction;
  27054. /**
  27055. * Sets the easing function of the animation
  27056. * @param easingFunction A custom mathematical formula for animation
  27057. */
  27058. setEasingFunction(easingFunction: EasingFunction): void;
  27059. /**
  27060. * Interpolates a scalar linearly
  27061. * @param startValue Start value of the animation curve
  27062. * @param endValue End value of the animation curve
  27063. * @param gradient Scalar amount to interpolate
  27064. * @returns Interpolated scalar value
  27065. */
  27066. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27067. /**
  27068. * Interpolates a scalar cubically
  27069. * @param startValue Start value of the animation curve
  27070. * @param outTangent End tangent of the animation
  27071. * @param endValue End value of the animation curve
  27072. * @param inTangent Start tangent of the animation curve
  27073. * @param gradient Scalar amount to interpolate
  27074. * @returns Interpolated scalar value
  27075. */
  27076. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27077. /**
  27078. * Interpolates a quaternion using a spherical linear interpolation
  27079. * @param startValue Start value of the animation curve
  27080. * @param endValue End value of the animation curve
  27081. * @param gradient Scalar amount to interpolate
  27082. * @returns Interpolated quaternion value
  27083. */
  27084. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27085. /**
  27086. * Interpolates a quaternion cubically
  27087. * @param startValue Start value of the animation curve
  27088. * @param outTangent End tangent of the animation curve
  27089. * @param endValue End value of the animation curve
  27090. * @param inTangent Start tangent of the animation curve
  27091. * @param gradient Scalar amount to interpolate
  27092. * @returns Interpolated quaternion value
  27093. */
  27094. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27095. /**
  27096. * Interpolates a Vector3 linearl
  27097. * @param startValue Start value of the animation curve
  27098. * @param endValue End value of the animation curve
  27099. * @param gradient Scalar amount to interpolate
  27100. * @returns Interpolated scalar value
  27101. */
  27102. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27103. /**
  27104. * Interpolates a Vector3 cubically
  27105. * @param startValue Start value of the animation curve
  27106. * @param outTangent End tangent of the animation
  27107. * @param endValue End value of the animation curve
  27108. * @param inTangent Start tangent of the animation curve
  27109. * @param gradient Scalar amount to interpolate
  27110. * @returns InterpolatedVector3 value
  27111. */
  27112. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27113. /**
  27114. * Interpolates a Vector2 linearly
  27115. * @param startValue Start value of the animation curve
  27116. * @param endValue End value of the animation curve
  27117. * @param gradient Scalar amount to interpolate
  27118. * @returns Interpolated Vector2 value
  27119. */
  27120. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27121. /**
  27122. * Interpolates a Vector2 cubically
  27123. * @param startValue Start value of the animation curve
  27124. * @param outTangent End tangent of the animation
  27125. * @param endValue End value of the animation curve
  27126. * @param inTangent Start tangent of the animation curve
  27127. * @param gradient Scalar amount to interpolate
  27128. * @returns Interpolated Vector2 value
  27129. */
  27130. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27131. /**
  27132. * Interpolates a size linearly
  27133. * @param startValue Start value of the animation curve
  27134. * @param endValue End value of the animation curve
  27135. * @param gradient Scalar amount to interpolate
  27136. * @returns Interpolated Size value
  27137. */
  27138. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27139. /**
  27140. * Interpolates a Color3 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 Color3 value
  27145. */
  27146. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27147. /**
  27148. * @hidden Internal use only
  27149. */
  27150. _getKeyValue(value: any): any;
  27151. /**
  27152. * @hidden Internal use only
  27153. */
  27154. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27155. /**
  27156. * Defines the function to use to interpolate matrices
  27157. * @param startValue defines the start matrix
  27158. * @param endValue defines the end matrix
  27159. * @param gradient defines the gradient between both matrices
  27160. * @param result defines an optional target matrix where to store the interpolation
  27161. * @returns the interpolated matrix
  27162. */
  27163. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27164. /**
  27165. * Makes a copy of the animation
  27166. * @returns Cloned animation
  27167. */
  27168. clone(): Animation;
  27169. /**
  27170. * Sets the key frames of the animation
  27171. * @param values The animation key frames to set
  27172. */
  27173. setKeys(values: Array<IAnimationKey>): void;
  27174. /**
  27175. * Serializes the animation to an object
  27176. * @returns Serialized object
  27177. */
  27178. serialize(): any;
  27179. /**
  27180. * Float animation type
  27181. */
  27182. private static _ANIMATIONTYPE_FLOAT;
  27183. /**
  27184. * Vector3 animation type
  27185. */
  27186. private static _ANIMATIONTYPE_VECTOR3;
  27187. /**
  27188. * Quaternion animation type
  27189. */
  27190. private static _ANIMATIONTYPE_QUATERNION;
  27191. /**
  27192. * Matrix animation type
  27193. */
  27194. private static _ANIMATIONTYPE_MATRIX;
  27195. /**
  27196. * Color3 animation type
  27197. */
  27198. private static _ANIMATIONTYPE_COLOR3;
  27199. /**
  27200. * Vector2 animation type
  27201. */
  27202. private static _ANIMATIONTYPE_VECTOR2;
  27203. /**
  27204. * Size animation type
  27205. */
  27206. private static _ANIMATIONTYPE_SIZE;
  27207. /**
  27208. * Relative Loop Mode
  27209. */
  27210. private static _ANIMATIONLOOPMODE_RELATIVE;
  27211. /**
  27212. * Cycle Loop Mode
  27213. */
  27214. private static _ANIMATIONLOOPMODE_CYCLE;
  27215. /**
  27216. * Constant Loop Mode
  27217. */
  27218. private static _ANIMATIONLOOPMODE_CONSTANT;
  27219. /**
  27220. * Get the float animation type
  27221. */
  27222. static readonly ANIMATIONTYPE_FLOAT: number;
  27223. /**
  27224. * Get the Vector3 animation type
  27225. */
  27226. static readonly ANIMATIONTYPE_VECTOR3: number;
  27227. /**
  27228. * Get the Vector2 animation type
  27229. */
  27230. static readonly ANIMATIONTYPE_VECTOR2: number;
  27231. /**
  27232. * Get the Size animation type
  27233. */
  27234. static readonly ANIMATIONTYPE_SIZE: number;
  27235. /**
  27236. * Get the Quaternion animation type
  27237. */
  27238. static readonly ANIMATIONTYPE_QUATERNION: number;
  27239. /**
  27240. * Get the Matrix animation type
  27241. */
  27242. static readonly ANIMATIONTYPE_MATRIX: number;
  27243. /**
  27244. * Get the Color3 animation type
  27245. */
  27246. static readonly ANIMATIONTYPE_COLOR3: number;
  27247. /**
  27248. * Get the Relative Loop Mode
  27249. */
  27250. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27251. /**
  27252. * Get the Cycle Loop Mode
  27253. */
  27254. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27255. /**
  27256. * Get the Constant Loop Mode
  27257. */
  27258. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27259. /** @hidden */
  27260. static _UniversalLerp(left: any, right: any, amount: number): any;
  27261. /**
  27262. * Parses an animation object and creates an animation
  27263. * @param parsedAnimation Parsed animation object
  27264. * @returns Animation object
  27265. */
  27266. static Parse(parsedAnimation: any): Animation;
  27267. /**
  27268. * Appends the serialized animations from the source animations
  27269. * @param source Source containing the animations
  27270. * @param destination Target to store the animations
  27271. */
  27272. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27273. }
  27274. }
  27275. declare module BABYLON {
  27276. /**
  27277. * Interface containing an array of animations
  27278. */
  27279. export interface IAnimatable {
  27280. /**
  27281. * Array of animations
  27282. */
  27283. animations: Nullable<Array<Animation>>;
  27284. }
  27285. }
  27286. declare module BABYLON {
  27287. /**
  27288. * This represents all the required information to add a fresnel effect on a material:
  27289. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27290. */
  27291. export class FresnelParameters {
  27292. private _isEnabled;
  27293. /**
  27294. * Define if the fresnel effect is enable or not.
  27295. */
  27296. isEnabled: boolean;
  27297. /**
  27298. * Define the color used on edges (grazing angle)
  27299. */
  27300. leftColor: Color3;
  27301. /**
  27302. * Define the color used on center
  27303. */
  27304. rightColor: Color3;
  27305. /**
  27306. * Define bias applied to computed fresnel term
  27307. */
  27308. bias: number;
  27309. /**
  27310. * Defined the power exponent applied to fresnel term
  27311. */
  27312. power: number;
  27313. /**
  27314. * Clones the current fresnel and its valuues
  27315. * @returns a clone fresnel configuration
  27316. */
  27317. clone(): FresnelParameters;
  27318. /**
  27319. * Serializes the current fresnel parameters to a JSON representation.
  27320. * @return the JSON serialization
  27321. */
  27322. serialize(): any;
  27323. /**
  27324. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27325. * @param parsedFresnelParameters Define the JSON representation
  27326. * @returns the parsed parameters
  27327. */
  27328. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27329. }
  27330. }
  27331. declare module BABYLON {
  27332. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27333. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27334. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27335. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27336. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27337. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27338. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27339. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27340. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27341. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27342. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27343. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27344. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27345. /**
  27346. * Decorator used to define property that can be serialized as reference to a camera
  27347. * @param sourceName defines the name of the property to decorate
  27348. */
  27349. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27350. /**
  27351. * Class used to help serialization objects
  27352. */
  27353. export class SerializationHelper {
  27354. /** @hidden */
  27355. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27356. /** @hidden */
  27357. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27358. /** @hidden */
  27359. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27360. /** @hidden */
  27361. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27362. /**
  27363. * Appends the serialized animations from the source animations
  27364. * @param source Source containing the animations
  27365. * @param destination Target to store the animations
  27366. */
  27367. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27368. /**
  27369. * Static function used to serialized a specific entity
  27370. * @param entity defines the entity to serialize
  27371. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27372. * @returns a JSON compatible object representing the serialization of the entity
  27373. */
  27374. static Serialize<T>(entity: T, serializationObject?: any): any;
  27375. /**
  27376. * Creates a new entity from a serialization data object
  27377. * @param creationFunction defines a function used to instanciated the new entity
  27378. * @param source defines the source serialization data
  27379. * @param scene defines the hosting scene
  27380. * @param rootUrl defines the root url for resources
  27381. * @returns a new entity
  27382. */
  27383. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27384. /**
  27385. * Clones an object
  27386. * @param creationFunction defines the function used to instanciate the new object
  27387. * @param source defines the source object
  27388. * @returns the cloned object
  27389. */
  27390. static Clone<T>(creationFunction: () => T, source: T): T;
  27391. /**
  27392. * Instanciates a new object based on a source one (some data will be shared between both object)
  27393. * @param creationFunction defines the function used to instanciate the new object
  27394. * @param source defines the source object
  27395. * @returns the new object
  27396. */
  27397. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27398. }
  27399. }
  27400. declare module BABYLON {
  27401. /**
  27402. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  27403. */
  27404. export interface CubeMapInfo {
  27405. /**
  27406. * The pixel array for the front face.
  27407. * This is stored in format, left to right, up to down format.
  27408. */
  27409. front: Nullable<ArrayBufferView>;
  27410. /**
  27411. * The pixel array for the back face.
  27412. * This is stored in format, left to right, up to down format.
  27413. */
  27414. back: Nullable<ArrayBufferView>;
  27415. /**
  27416. * The pixel array for the left face.
  27417. * This is stored in format, left to right, up to down format.
  27418. */
  27419. left: Nullable<ArrayBufferView>;
  27420. /**
  27421. * The pixel array for the right face.
  27422. * This is stored in format, left to right, up to down format.
  27423. */
  27424. right: Nullable<ArrayBufferView>;
  27425. /**
  27426. * The pixel array for the up face.
  27427. * This is stored in format, left to right, up to down format.
  27428. */
  27429. up: Nullable<ArrayBufferView>;
  27430. /**
  27431. * The pixel array for the down face.
  27432. * This is stored in format, left to right, up to down format.
  27433. */
  27434. down: Nullable<ArrayBufferView>;
  27435. /**
  27436. * The size of the cubemap stored.
  27437. *
  27438. * Each faces will be size * size pixels.
  27439. */
  27440. size: number;
  27441. /**
  27442. * The format of the texture.
  27443. *
  27444. * RGBA, RGB.
  27445. */
  27446. format: number;
  27447. /**
  27448. * The type of the texture data.
  27449. *
  27450. * UNSIGNED_INT, FLOAT.
  27451. */
  27452. type: number;
  27453. /**
  27454. * Specifies whether the texture is in gamma space.
  27455. */
  27456. gammaSpace: boolean;
  27457. }
  27458. /**
  27459. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  27460. */
  27461. export class PanoramaToCubeMapTools {
  27462. private static FACE_FRONT;
  27463. private static FACE_BACK;
  27464. private static FACE_RIGHT;
  27465. private static FACE_LEFT;
  27466. private static FACE_DOWN;
  27467. private static FACE_UP;
  27468. /**
  27469. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27470. *
  27471. * @param float32Array The source data.
  27472. * @param inputWidth The width of the input panorama.
  27473. * @param inputHeight The height of the input panorama.
  27474. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27475. * @return The cubemap data
  27476. */
  27477. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27478. private static CreateCubemapTexture;
  27479. private static CalcProjectionSpherical;
  27480. }
  27481. }
  27482. declare module BABYLON {
  27483. /**
  27484. * Helper class dealing with the extraction of spherical polynomial dataArray
  27485. * from a cube map.
  27486. */
  27487. export class CubeMapToSphericalPolynomialTools {
  27488. private static FileFaces;
  27489. /**
  27490. * Converts a texture to the according Spherical Polynomial data.
  27491. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27492. *
  27493. * @param texture The texture to extract the information from.
  27494. * @return The Spherical Polynomial data.
  27495. */
  27496. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27497. /**
  27498. * Converts a cubemap 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 cubeInfo The Cube map to extract the information from.
  27502. * @return The Spherical Polynomial data.
  27503. */
  27504. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27505. }
  27506. }
  27507. declare module BABYLON {
  27508. /**
  27509. * Class used to manipulate GUIDs
  27510. */
  27511. export class GUID {
  27512. /**
  27513. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27514. * Be aware Math.random() could cause collisions, but:
  27515. * "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"
  27516. * @returns a pseudo random id
  27517. */
  27518. static RandomId(): string;
  27519. }
  27520. }
  27521. declare module BABYLON {
  27522. /**
  27523. * Base class of all the textures in babylon.
  27524. * It groups all the common properties the materials, post process, lights... might need
  27525. * in order to make a correct use of the texture.
  27526. */
  27527. export class BaseTexture implements IAnimatable {
  27528. /**
  27529. * Default anisotropic filtering level for the application.
  27530. * It is set to 4 as a good tradeoff between perf and quality.
  27531. */
  27532. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27533. /**
  27534. * Gets or sets the unique id of the texture
  27535. */
  27536. uniqueId: number;
  27537. /**
  27538. * Define the name of the texture.
  27539. */
  27540. name: string;
  27541. /**
  27542. * Gets or sets an object used to store user defined information.
  27543. */
  27544. metadata: any;
  27545. /**
  27546. * For internal use only. Please do not use.
  27547. */
  27548. reservedDataStore: any;
  27549. private _hasAlpha;
  27550. /**
  27551. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27552. */
  27553. hasAlpha: boolean;
  27554. /**
  27555. * Defines if the alpha value should be determined via the rgb values.
  27556. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27557. */
  27558. getAlphaFromRGB: boolean;
  27559. /**
  27560. * Intensity or strength of the texture.
  27561. * It is commonly used by materials to fine tune the intensity of the texture
  27562. */
  27563. level: number;
  27564. /**
  27565. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27566. * This is part of the texture as textures usually maps to one uv set.
  27567. */
  27568. coordinatesIndex: number;
  27569. private _coordinatesMode;
  27570. /**
  27571. * How a texture is mapped.
  27572. *
  27573. * | Value | Type | Description |
  27574. * | ----- | ----------------------------------- | ----------- |
  27575. * | 0 | EXPLICIT_MODE | |
  27576. * | 1 | SPHERICAL_MODE | |
  27577. * | 2 | PLANAR_MODE | |
  27578. * | 3 | CUBIC_MODE | |
  27579. * | 4 | PROJECTION_MODE | |
  27580. * | 5 | SKYBOX_MODE | |
  27581. * | 6 | INVCUBIC_MODE | |
  27582. * | 7 | EQUIRECTANGULAR_MODE | |
  27583. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27584. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27585. */
  27586. coordinatesMode: number;
  27587. /**
  27588. * | Value | Type | Description |
  27589. * | ----- | ------------------ | ----------- |
  27590. * | 0 | CLAMP_ADDRESSMODE | |
  27591. * | 1 | WRAP_ADDRESSMODE | |
  27592. * | 2 | MIRROR_ADDRESSMODE | |
  27593. */
  27594. wrapU: number;
  27595. /**
  27596. * | Value | Type | Description |
  27597. * | ----- | ------------------ | ----------- |
  27598. * | 0 | CLAMP_ADDRESSMODE | |
  27599. * | 1 | WRAP_ADDRESSMODE | |
  27600. * | 2 | MIRROR_ADDRESSMODE | |
  27601. */
  27602. wrapV: number;
  27603. /**
  27604. * | Value | Type | Description |
  27605. * | ----- | ------------------ | ----------- |
  27606. * | 0 | CLAMP_ADDRESSMODE | |
  27607. * | 1 | WRAP_ADDRESSMODE | |
  27608. * | 2 | MIRROR_ADDRESSMODE | |
  27609. */
  27610. wrapR: number;
  27611. /**
  27612. * With compliant hardware and browser (supporting anisotropic filtering)
  27613. * this defines the level of anisotropic filtering in the texture.
  27614. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27615. */
  27616. anisotropicFilteringLevel: number;
  27617. /**
  27618. * Define if the texture is a cube texture or if false a 2d texture.
  27619. */
  27620. isCube: boolean;
  27621. /**
  27622. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27623. */
  27624. is3D: boolean;
  27625. /**
  27626. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27627. * HDR texture are usually stored in linear space.
  27628. * This only impacts the PBR and Background materials
  27629. */
  27630. gammaSpace: boolean;
  27631. /**
  27632. * Gets whether or not the texture contains RGBD data.
  27633. */
  27634. readonly isRGBD: boolean;
  27635. /**
  27636. * Is Z inverted in the texture (useful in a cube texture).
  27637. */
  27638. invertZ: boolean;
  27639. /**
  27640. * Are mip maps generated for this texture or not.
  27641. */
  27642. readonly noMipmap: boolean;
  27643. /**
  27644. * @hidden
  27645. */
  27646. lodLevelInAlpha: boolean;
  27647. /**
  27648. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27649. */
  27650. lodGenerationOffset: number;
  27651. /**
  27652. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27653. */
  27654. lodGenerationScale: number;
  27655. /**
  27656. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27657. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27658. * average roughness values.
  27659. */
  27660. linearSpecularLOD: boolean;
  27661. /**
  27662. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27663. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27664. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27665. */
  27666. irradianceTexture: Nullable<BaseTexture>;
  27667. /**
  27668. * Define if the texture is a render target.
  27669. */
  27670. isRenderTarget: boolean;
  27671. /**
  27672. * Define the unique id of the texture in the scene.
  27673. */
  27674. readonly uid: string;
  27675. /**
  27676. * Return a string representation of the texture.
  27677. * @returns the texture as a string
  27678. */
  27679. toString(): string;
  27680. /**
  27681. * Get the class name of the texture.
  27682. * @returns "BaseTexture"
  27683. */
  27684. getClassName(): string;
  27685. /**
  27686. * Define the list of animation attached to the texture.
  27687. */
  27688. animations: Animation[];
  27689. /**
  27690. * An event triggered when the texture is disposed.
  27691. */
  27692. onDisposeObservable: Observable<BaseTexture>;
  27693. private _onDisposeObserver;
  27694. /**
  27695. * Callback triggered when the texture has been disposed.
  27696. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27697. */
  27698. onDispose: () => void;
  27699. /**
  27700. * Define the current state of the loading sequence when in delayed load mode.
  27701. */
  27702. delayLoadState: number;
  27703. private _scene;
  27704. /** @hidden */
  27705. _texture: Nullable<InternalTexture>;
  27706. private _uid;
  27707. /**
  27708. * Define if the texture is preventinga material to render or not.
  27709. * If not and the texture is not ready, the engine will use a default black texture instead.
  27710. */
  27711. readonly isBlocking: boolean;
  27712. /**
  27713. * Instantiates a new BaseTexture.
  27714. * Base class of all the textures in babylon.
  27715. * It groups all the common properties the materials, post process, lights... might need
  27716. * in order to make a correct use of the texture.
  27717. * @param scene Define the scene the texture blongs to
  27718. */
  27719. constructor(scene: Nullable<Scene>);
  27720. /**
  27721. * Get the scene the texture belongs to.
  27722. * @returns the scene or null if undefined
  27723. */
  27724. getScene(): Nullable<Scene>;
  27725. /**
  27726. * Get the texture transform matrix used to offset tile the texture for istance.
  27727. * @returns the transformation matrix
  27728. */
  27729. getTextureMatrix(): Matrix;
  27730. /**
  27731. * Get the texture reflection matrix used to rotate/transform the reflection.
  27732. * @returns the reflection matrix
  27733. */
  27734. getReflectionTextureMatrix(): Matrix;
  27735. /**
  27736. * Get the underlying lower level texture from Babylon.
  27737. * @returns the insternal texture
  27738. */
  27739. getInternalTexture(): Nullable<InternalTexture>;
  27740. /**
  27741. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27742. * @returns true if ready or not blocking
  27743. */
  27744. isReadyOrNotBlocking(): boolean;
  27745. /**
  27746. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27747. * @returns true if fully ready
  27748. */
  27749. isReady(): boolean;
  27750. private _cachedSize;
  27751. /**
  27752. * Get the size of the texture.
  27753. * @returns the texture size.
  27754. */
  27755. getSize(): ISize;
  27756. /**
  27757. * Get the base size of the texture.
  27758. * It can be different from the size if the texture has been resized for POT for instance
  27759. * @returns the base size
  27760. */
  27761. getBaseSize(): ISize;
  27762. /**
  27763. * Update the sampling mode of the texture.
  27764. * Default is Trilinear mode.
  27765. *
  27766. * | Value | Type | Description |
  27767. * | ----- | ------------------ | ----------- |
  27768. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27769. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27770. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27771. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27772. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27773. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27774. * | 7 | NEAREST_LINEAR | |
  27775. * | 8 | NEAREST_NEAREST | |
  27776. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27777. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27778. * | 11 | LINEAR_LINEAR | |
  27779. * | 12 | LINEAR_NEAREST | |
  27780. *
  27781. * > _mag_: magnification filter (close to the viewer)
  27782. * > _min_: minification filter (far from the viewer)
  27783. * > _mip_: filter used between mip map levels
  27784. *@param samplingMode Define the new sampling mode of the texture
  27785. */
  27786. updateSamplingMode(samplingMode: number): void;
  27787. /**
  27788. * Scales the texture if is `canRescale()`
  27789. * @param ratio the resize factor we want to use to rescale
  27790. */
  27791. scale(ratio: number): void;
  27792. /**
  27793. * Get if the texture can rescale.
  27794. */
  27795. readonly canRescale: boolean;
  27796. /** @hidden */
  27797. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27798. /** @hidden */
  27799. _rebuild(): void;
  27800. /**
  27801. * Triggers the load sequence in delayed load mode.
  27802. */
  27803. delayLoad(): void;
  27804. /**
  27805. * Clones the texture.
  27806. * @returns the cloned texture
  27807. */
  27808. clone(): Nullable<BaseTexture>;
  27809. /**
  27810. * Get the texture underlying type (INT, FLOAT...)
  27811. */
  27812. readonly textureType: number;
  27813. /**
  27814. * Get the texture underlying format (RGB, RGBA...)
  27815. */
  27816. readonly textureFormat: number;
  27817. /**
  27818. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27819. * This will returns an RGBA array buffer containing either in values (0-255) or
  27820. * float values (0-1) depending of the underlying buffer type.
  27821. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27822. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27823. * @param buffer defines a user defined buffer to fill with data (can be null)
  27824. * @returns The Array buffer containing the pixels data.
  27825. */
  27826. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27827. /**
  27828. * Release and destroy the underlying lower level texture aka internalTexture.
  27829. */
  27830. releaseInternalTexture(): void;
  27831. /**
  27832. * Get the polynomial representation of the texture data.
  27833. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27834. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27835. */
  27836. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27837. /** @hidden */
  27838. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27839. /** @hidden */
  27840. readonly _lodTextureMid: Nullable<BaseTexture>;
  27841. /** @hidden */
  27842. readonly _lodTextureLow: Nullable<BaseTexture>;
  27843. /**
  27844. * Dispose the texture and release its associated resources.
  27845. */
  27846. dispose(): void;
  27847. /**
  27848. * Serialize the texture into a JSON representation that can be parsed later on.
  27849. * @returns the JSON representation of the texture
  27850. */
  27851. serialize(): any;
  27852. /**
  27853. * Helper function to be called back once a list of texture contains only ready textures.
  27854. * @param textures Define the list of textures to wait for
  27855. * @param callback Define the callback triggered once the entire list will be ready
  27856. */
  27857. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27858. }
  27859. }
  27860. declare module BABYLON {
  27861. /**
  27862. * Class used to store data associated with WebGL texture data for the engine
  27863. * This class should not be used directly
  27864. */
  27865. export class InternalTexture {
  27866. /** @hidden */
  27867. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  27868. /**
  27869. * The source of the texture data is unknown
  27870. */
  27871. static DATASOURCE_UNKNOWN: number;
  27872. /**
  27873. * Texture data comes from an URL
  27874. */
  27875. static DATASOURCE_URL: number;
  27876. /**
  27877. * Texture data is only used for temporary storage
  27878. */
  27879. static DATASOURCE_TEMP: number;
  27880. /**
  27881. * Texture data comes from raw data (ArrayBuffer)
  27882. */
  27883. static DATASOURCE_RAW: number;
  27884. /**
  27885. * Texture content is dynamic (video or dynamic texture)
  27886. */
  27887. static DATASOURCE_DYNAMIC: number;
  27888. /**
  27889. * Texture content is generated by rendering to it
  27890. */
  27891. static DATASOURCE_RENDERTARGET: number;
  27892. /**
  27893. * Texture content is part of a multi render target process
  27894. */
  27895. static DATASOURCE_MULTIRENDERTARGET: number;
  27896. /**
  27897. * Texture data comes from a cube data file
  27898. */
  27899. static DATASOURCE_CUBE: number;
  27900. /**
  27901. * Texture data comes from a raw cube data
  27902. */
  27903. static DATASOURCE_CUBERAW: number;
  27904. /**
  27905. * Texture data come from a prefiltered cube data file
  27906. */
  27907. static DATASOURCE_CUBEPREFILTERED: number;
  27908. /**
  27909. * Texture content is raw 3D data
  27910. */
  27911. static DATASOURCE_RAW3D: number;
  27912. /**
  27913. * Texture content is a depth texture
  27914. */
  27915. static DATASOURCE_DEPTHTEXTURE: number;
  27916. /**
  27917. * Texture data comes from a raw cube data encoded with RGBD
  27918. */
  27919. static DATASOURCE_CUBERAW_RGBD: number;
  27920. /**
  27921. * Defines if the texture is ready
  27922. */
  27923. isReady: boolean;
  27924. /**
  27925. * Defines if the texture is a cube texture
  27926. */
  27927. isCube: boolean;
  27928. /**
  27929. * Defines if the texture contains 3D data
  27930. */
  27931. is3D: boolean;
  27932. /**
  27933. * Defines if the texture contains multiview data
  27934. */
  27935. isMultiview: boolean;
  27936. /**
  27937. * Gets the URL used to load this texture
  27938. */
  27939. url: string;
  27940. /**
  27941. * Gets the sampling mode of the texture
  27942. */
  27943. samplingMode: number;
  27944. /**
  27945. * Gets a boolean indicating if the texture needs mipmaps generation
  27946. */
  27947. generateMipMaps: boolean;
  27948. /**
  27949. * Gets the number of samples used by the texture (WebGL2+ only)
  27950. */
  27951. samples: number;
  27952. /**
  27953. * Gets the type of the texture (int, float...)
  27954. */
  27955. type: number;
  27956. /**
  27957. * Gets the format of the texture (RGB, RGBA...)
  27958. */
  27959. format: number;
  27960. /**
  27961. * Observable called when the texture is loaded
  27962. */
  27963. onLoadedObservable: Observable<InternalTexture>;
  27964. /**
  27965. * Gets the width of the texture
  27966. */
  27967. width: number;
  27968. /**
  27969. * Gets the height of the texture
  27970. */
  27971. height: number;
  27972. /**
  27973. * Gets the depth of the texture
  27974. */
  27975. depth: number;
  27976. /**
  27977. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  27978. */
  27979. baseWidth: number;
  27980. /**
  27981. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  27982. */
  27983. baseHeight: number;
  27984. /**
  27985. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  27986. */
  27987. baseDepth: number;
  27988. /**
  27989. * Gets a boolean indicating if the texture is inverted on Y axis
  27990. */
  27991. invertY: boolean;
  27992. /** @hidden */
  27993. _invertVScale: boolean;
  27994. /** @hidden */
  27995. _associatedChannel: number;
  27996. /** @hidden */
  27997. _dataSource: number;
  27998. /** @hidden */
  27999. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  28000. /** @hidden */
  28001. _bufferView: Nullable<ArrayBufferView>;
  28002. /** @hidden */
  28003. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28004. /** @hidden */
  28005. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28006. /** @hidden */
  28007. _size: number;
  28008. /** @hidden */
  28009. _extension: string;
  28010. /** @hidden */
  28011. _files: Nullable<string[]>;
  28012. /** @hidden */
  28013. _workingCanvas: Nullable<HTMLCanvasElement>;
  28014. /** @hidden */
  28015. _workingContext: Nullable<CanvasRenderingContext2D>;
  28016. /** @hidden */
  28017. _framebuffer: Nullable<WebGLFramebuffer>;
  28018. /** @hidden */
  28019. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28020. /** @hidden */
  28021. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28022. /** @hidden */
  28023. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28024. /** @hidden */
  28025. _attachments: Nullable<number[]>;
  28026. /** @hidden */
  28027. _cachedCoordinatesMode: Nullable<number>;
  28028. /** @hidden */
  28029. _cachedWrapU: Nullable<number>;
  28030. /** @hidden */
  28031. _cachedWrapV: Nullable<number>;
  28032. /** @hidden */
  28033. _cachedWrapR: Nullable<number>;
  28034. /** @hidden */
  28035. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28036. /** @hidden */
  28037. _isDisabled: boolean;
  28038. /** @hidden */
  28039. _compression: Nullable<string>;
  28040. /** @hidden */
  28041. _generateStencilBuffer: boolean;
  28042. /** @hidden */
  28043. _generateDepthBuffer: boolean;
  28044. /** @hidden */
  28045. _comparisonFunction: number;
  28046. /** @hidden */
  28047. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28048. /** @hidden */
  28049. _lodGenerationScale: number;
  28050. /** @hidden */
  28051. _lodGenerationOffset: number;
  28052. /** @hidden */
  28053. _colorTextureArray: Nullable<WebGLTexture>;
  28054. /** @hidden */
  28055. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28056. /** @hidden */
  28057. _lodTextureHigh: Nullable<BaseTexture>;
  28058. /** @hidden */
  28059. _lodTextureMid: Nullable<BaseTexture>;
  28060. /** @hidden */
  28061. _lodTextureLow: Nullable<BaseTexture>;
  28062. /** @hidden */
  28063. _isRGBD: boolean;
  28064. /** @hidden */
  28065. _linearSpecularLOD: boolean;
  28066. /** @hidden */
  28067. _irradianceTexture: Nullable<BaseTexture>;
  28068. /** @hidden */
  28069. _webGLTexture: Nullable<WebGLTexture>;
  28070. /** @hidden */
  28071. _references: number;
  28072. private _engine;
  28073. /**
  28074. * Gets the Engine the texture belongs to.
  28075. * @returns The babylon engine
  28076. */
  28077. getEngine(): Engine;
  28078. /**
  28079. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28080. */
  28081. readonly dataSource: number;
  28082. /**
  28083. * Creates a new InternalTexture
  28084. * @param engine defines the engine to use
  28085. * @param dataSource defines the type of data that will be used
  28086. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28087. */
  28088. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28089. /**
  28090. * Increments the number of references (ie. the number of Texture that point to it)
  28091. */
  28092. incrementReferences(): void;
  28093. /**
  28094. * Change the size of the texture (not the size of the content)
  28095. * @param width defines the new width
  28096. * @param height defines the new height
  28097. * @param depth defines the new depth (1 by default)
  28098. */
  28099. updateSize(width: int, height: int, depth?: int): void;
  28100. /** @hidden */
  28101. _rebuild(): void;
  28102. /** @hidden */
  28103. _swapAndDie(target: InternalTexture): void;
  28104. /**
  28105. * Dispose the current allocated resources
  28106. */
  28107. dispose(): void;
  28108. }
  28109. }
  28110. declare module BABYLON {
  28111. /**
  28112. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28113. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28114. */
  28115. export class EffectFallbacks {
  28116. private _defines;
  28117. private _currentRank;
  28118. private _maxRank;
  28119. private _mesh;
  28120. /**
  28121. * Removes the fallback from the bound mesh.
  28122. */
  28123. unBindMesh(): void;
  28124. /**
  28125. * Adds a fallback on the specified property.
  28126. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28127. * @param define The name of the define in the shader
  28128. */
  28129. addFallback(rank: number, define: string): void;
  28130. /**
  28131. * Sets the mesh to use CPU skinning when needing to fallback.
  28132. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28133. * @param mesh The mesh to use the fallbacks.
  28134. */
  28135. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28136. /**
  28137. * Checks to see if more fallbacks are still availible.
  28138. */
  28139. readonly isMoreFallbacks: boolean;
  28140. /**
  28141. * Removes the defines that should be removed when falling back.
  28142. * @param currentDefines defines the current define statements for the shader.
  28143. * @param effect defines the current effect we try to compile
  28144. * @returns The resulting defines with defines of the current rank removed.
  28145. */
  28146. reduce(currentDefines: string, effect: Effect): string;
  28147. }
  28148. /**
  28149. * Options to be used when creating an effect.
  28150. */
  28151. export class EffectCreationOptions {
  28152. /**
  28153. * Atrributes that will be used in the shader.
  28154. */
  28155. attributes: string[];
  28156. /**
  28157. * Uniform varible names that will be set in the shader.
  28158. */
  28159. uniformsNames: string[];
  28160. /**
  28161. * Uniform buffer varible names that will be set in the shader.
  28162. */
  28163. uniformBuffersNames: string[];
  28164. /**
  28165. * Sampler texture variable names that will be set in the shader.
  28166. */
  28167. samplers: string[];
  28168. /**
  28169. * Define statements that will be set in the shader.
  28170. */
  28171. defines: any;
  28172. /**
  28173. * Possible fallbacks for this effect to improve performance when needed.
  28174. */
  28175. fallbacks: Nullable<EffectFallbacks>;
  28176. /**
  28177. * Callback that will be called when the shader is compiled.
  28178. */
  28179. onCompiled: Nullable<(effect: Effect) => void>;
  28180. /**
  28181. * Callback that will be called if an error occurs during shader compilation.
  28182. */
  28183. onError: Nullable<(effect: Effect, errors: string) => void>;
  28184. /**
  28185. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28186. */
  28187. indexParameters: any;
  28188. /**
  28189. * Max number of lights that can be used in the shader.
  28190. */
  28191. maxSimultaneousLights: number;
  28192. /**
  28193. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28194. */
  28195. transformFeedbackVaryings: Nullable<string[]>;
  28196. }
  28197. /**
  28198. * Effect containing vertex and fragment shader that can be executed on an object.
  28199. */
  28200. export class Effect implements IDisposable {
  28201. /**
  28202. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28203. */
  28204. static ShadersRepository: string;
  28205. /**
  28206. * Name of the effect.
  28207. */
  28208. name: any;
  28209. /**
  28210. * String container all the define statements that should be set on the shader.
  28211. */
  28212. defines: string;
  28213. /**
  28214. * Callback that will be called when the shader is compiled.
  28215. */
  28216. onCompiled: Nullable<(effect: Effect) => void>;
  28217. /**
  28218. * Callback that will be called if an error occurs during shader compilation.
  28219. */
  28220. onError: Nullable<(effect: Effect, errors: string) => void>;
  28221. /**
  28222. * Callback that will be called when effect is bound.
  28223. */
  28224. onBind: Nullable<(effect: Effect) => void>;
  28225. /**
  28226. * Unique ID of the effect.
  28227. */
  28228. uniqueId: number;
  28229. /**
  28230. * Observable that will be called when the shader is compiled.
  28231. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28232. */
  28233. onCompileObservable: Observable<Effect>;
  28234. /**
  28235. * Observable that will be called if an error occurs during shader compilation.
  28236. */
  28237. onErrorObservable: Observable<Effect>;
  28238. /** @hidden */
  28239. _onBindObservable: Nullable<Observable<Effect>>;
  28240. /**
  28241. * Observable that will be called when effect is bound.
  28242. */
  28243. readonly onBindObservable: Observable<Effect>;
  28244. /** @hidden */
  28245. _bonesComputationForcedToCPU: boolean;
  28246. private static _uniqueIdSeed;
  28247. private _engine;
  28248. private _uniformBuffersNames;
  28249. private _uniformsNames;
  28250. private _samplerList;
  28251. private _samplers;
  28252. private _isReady;
  28253. private _compilationError;
  28254. private _attributesNames;
  28255. private _attributes;
  28256. private _uniforms;
  28257. /**
  28258. * Key for the effect.
  28259. * @hidden
  28260. */
  28261. _key: string;
  28262. private _indexParameters;
  28263. private _fallbacks;
  28264. private _vertexSourceCode;
  28265. private _fragmentSourceCode;
  28266. private _vertexSourceCodeOverride;
  28267. private _fragmentSourceCodeOverride;
  28268. private _transformFeedbackVaryings;
  28269. /**
  28270. * Compiled shader to webGL program.
  28271. * @hidden
  28272. */
  28273. _pipelineContext: Nullable<IPipelineContext>;
  28274. private _valueCache;
  28275. private static _baseCache;
  28276. /**
  28277. * Instantiates an effect.
  28278. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28279. * @param baseName Name of the effect.
  28280. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28281. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28282. * @param samplers List of sampler variables that will be passed to the shader.
  28283. * @param engine Engine to be used to render the effect
  28284. * @param defines Define statements to be added to the shader.
  28285. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28286. * @param onCompiled Callback that will be called when the shader is compiled.
  28287. * @param onError Callback that will be called if an error occurs during shader compilation.
  28288. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28289. */
  28290. 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);
  28291. private _useFinalCode;
  28292. /**
  28293. * Unique key for this effect
  28294. */
  28295. readonly key: string;
  28296. /**
  28297. * If the effect has been compiled and prepared.
  28298. * @returns if the effect is compiled and prepared.
  28299. */
  28300. isReady(): boolean;
  28301. /**
  28302. * The engine the effect was initialized with.
  28303. * @returns the engine.
  28304. */
  28305. getEngine(): Engine;
  28306. /**
  28307. * The pipeline context for this effect
  28308. * @returns the associated pipeline context
  28309. */
  28310. getPipelineContext(): Nullable<IPipelineContext>;
  28311. /**
  28312. * The set of names of attribute variables for the shader.
  28313. * @returns An array of attribute names.
  28314. */
  28315. getAttributesNames(): string[];
  28316. /**
  28317. * Returns the attribute at the given index.
  28318. * @param index The index of the attribute.
  28319. * @returns The location of the attribute.
  28320. */
  28321. getAttributeLocation(index: number): number;
  28322. /**
  28323. * Returns the attribute based on the name of the variable.
  28324. * @param name of the attribute to look up.
  28325. * @returns the attribute location.
  28326. */
  28327. getAttributeLocationByName(name: string): number;
  28328. /**
  28329. * The number of attributes.
  28330. * @returns the numnber of attributes.
  28331. */
  28332. getAttributesCount(): number;
  28333. /**
  28334. * Gets the index of a uniform variable.
  28335. * @param uniformName of the uniform to look up.
  28336. * @returns the index.
  28337. */
  28338. getUniformIndex(uniformName: string): number;
  28339. /**
  28340. * Returns the attribute based on the name of the variable.
  28341. * @param uniformName of the uniform to look up.
  28342. * @returns the location of the uniform.
  28343. */
  28344. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28345. /**
  28346. * Returns an array of sampler variable names
  28347. * @returns The array of sampler variable neames.
  28348. */
  28349. getSamplers(): string[];
  28350. /**
  28351. * The error from the last compilation.
  28352. * @returns the error string.
  28353. */
  28354. getCompilationError(): string;
  28355. /**
  28356. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28357. * @param func The callback to be used.
  28358. */
  28359. executeWhenCompiled(func: (effect: Effect) => void): void;
  28360. private _checkIsReady;
  28361. /** @hidden */
  28362. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28363. /** @hidden */
  28364. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28365. /** @hidden */
  28366. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28367. /**
  28368. * Recompiles the webGL program
  28369. * @param vertexSourceCode The source code for the vertex shader.
  28370. * @param fragmentSourceCode The source code for the fragment shader.
  28371. * @param onCompiled Callback called when completed.
  28372. * @param onError Callback called on error.
  28373. * @hidden
  28374. */
  28375. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28376. /**
  28377. * Prepares the effect
  28378. * @hidden
  28379. */
  28380. _prepareEffect(): void;
  28381. /**
  28382. * Checks if the effect is supported. (Must be called after compilation)
  28383. */
  28384. readonly isSupported: boolean;
  28385. /**
  28386. * Binds a texture to the engine to be used as output of the shader.
  28387. * @param channel Name of the output variable.
  28388. * @param texture Texture to bind.
  28389. * @hidden
  28390. */
  28391. _bindTexture(channel: string, texture: InternalTexture): void;
  28392. /**
  28393. * Sets a texture on the engine to be used in the shader.
  28394. * @param channel Name of the sampler variable.
  28395. * @param texture Texture to set.
  28396. */
  28397. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28398. /**
  28399. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28400. * @param channel Name of the sampler variable.
  28401. * @param texture Texture to set.
  28402. */
  28403. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28404. /**
  28405. * Sets an array of textures on the engine to be used in the shader.
  28406. * @param channel Name of the variable.
  28407. * @param textures Textures to set.
  28408. */
  28409. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28410. /**
  28411. * 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)
  28412. * @param channel Name of the sampler variable.
  28413. * @param postProcess Post process to get the input texture from.
  28414. */
  28415. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28416. /**
  28417. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28418. * 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)
  28419. * @param channel Name of the sampler variable.
  28420. * @param postProcess Post process to get the output texture from.
  28421. */
  28422. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28423. /** @hidden */
  28424. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28425. /** @hidden */
  28426. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28427. /** @hidden */
  28428. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28429. /** @hidden */
  28430. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28431. /**
  28432. * Binds a buffer to a uniform.
  28433. * @param buffer Buffer to bind.
  28434. * @param name Name of the uniform variable to bind to.
  28435. */
  28436. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28437. /**
  28438. * Binds block to a uniform.
  28439. * @param blockName Name of the block to bind.
  28440. * @param index Index to bind.
  28441. */
  28442. bindUniformBlock(blockName: string, index: number): void;
  28443. /**
  28444. * Sets an interger value on a uniform variable.
  28445. * @param uniformName Name of the variable.
  28446. * @param value Value to be set.
  28447. * @returns this effect.
  28448. */
  28449. setInt(uniformName: string, value: number): Effect;
  28450. /**
  28451. * Sets an int array on a uniform variable.
  28452. * @param uniformName Name of the variable.
  28453. * @param array array to be set.
  28454. * @returns this effect.
  28455. */
  28456. setIntArray(uniformName: string, array: Int32Array): Effect;
  28457. /**
  28458. * 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)
  28459. * @param uniformName Name of the variable.
  28460. * @param array array to be set.
  28461. * @returns this effect.
  28462. */
  28463. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28464. /**
  28465. * 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)
  28466. * @param uniformName Name of the variable.
  28467. * @param array array to be set.
  28468. * @returns this effect.
  28469. */
  28470. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28471. /**
  28472. * 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)
  28473. * @param uniformName Name of the variable.
  28474. * @param array array to be set.
  28475. * @returns this effect.
  28476. */
  28477. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28478. /**
  28479. * Sets an float array on a uniform variable.
  28480. * @param uniformName Name of the variable.
  28481. * @param array array to be set.
  28482. * @returns this effect.
  28483. */
  28484. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28485. /**
  28486. * 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)
  28487. * @param uniformName Name of the variable.
  28488. * @param array array to be set.
  28489. * @returns this effect.
  28490. */
  28491. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28492. /**
  28493. * 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)
  28494. * @param uniformName Name of the variable.
  28495. * @param array array to be set.
  28496. * @returns this effect.
  28497. */
  28498. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28499. /**
  28500. * 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)
  28501. * @param uniformName Name of the variable.
  28502. * @param array array to be set.
  28503. * @returns this effect.
  28504. */
  28505. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28506. /**
  28507. * Sets an array on a uniform variable.
  28508. * @param uniformName Name of the variable.
  28509. * @param array array to be set.
  28510. * @returns this effect.
  28511. */
  28512. setArray(uniformName: string, array: number[]): Effect;
  28513. /**
  28514. * 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)
  28515. * @param uniformName Name of the variable.
  28516. * @param array array to be set.
  28517. * @returns this effect.
  28518. */
  28519. setArray2(uniformName: string, array: number[]): Effect;
  28520. /**
  28521. * 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)
  28522. * @param uniformName Name of the variable.
  28523. * @param array array to be set.
  28524. * @returns this effect.
  28525. */
  28526. setArray3(uniformName: string, array: number[]): Effect;
  28527. /**
  28528. * 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)
  28529. * @param uniformName Name of the variable.
  28530. * @param array array to be set.
  28531. * @returns this effect.
  28532. */
  28533. setArray4(uniformName: string, array: number[]): Effect;
  28534. /**
  28535. * Sets matrices on a uniform variable.
  28536. * @param uniformName Name of the variable.
  28537. * @param matrices matrices to be set.
  28538. * @returns this effect.
  28539. */
  28540. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28541. /**
  28542. * Sets matrix on a uniform variable.
  28543. * @param uniformName Name of the variable.
  28544. * @param matrix matrix to be set.
  28545. * @returns this effect.
  28546. */
  28547. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28548. /**
  28549. * 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)
  28550. * @param uniformName Name of the variable.
  28551. * @param matrix matrix to be set.
  28552. * @returns this effect.
  28553. */
  28554. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28555. /**
  28556. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28557. * @param uniformName Name of the variable.
  28558. * @param matrix matrix to be set.
  28559. * @returns this effect.
  28560. */
  28561. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28562. /**
  28563. * Sets a float on a uniform variable.
  28564. * @param uniformName Name of the variable.
  28565. * @param value value to be set.
  28566. * @returns this effect.
  28567. */
  28568. setFloat(uniformName: string, value: number): Effect;
  28569. /**
  28570. * Sets a boolean on a uniform variable.
  28571. * @param uniformName Name of the variable.
  28572. * @param bool value to be set.
  28573. * @returns this effect.
  28574. */
  28575. setBool(uniformName: string, bool: boolean): Effect;
  28576. /**
  28577. * Sets a Vector2 on a uniform variable.
  28578. * @param uniformName Name of the variable.
  28579. * @param vector2 vector2 to be set.
  28580. * @returns this effect.
  28581. */
  28582. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28583. /**
  28584. * Sets a float2 on a uniform variable.
  28585. * @param uniformName Name of the variable.
  28586. * @param x First float in float2.
  28587. * @param y Second float in float2.
  28588. * @returns this effect.
  28589. */
  28590. setFloat2(uniformName: string, x: number, y: number): Effect;
  28591. /**
  28592. * Sets a Vector3 on a uniform variable.
  28593. * @param uniformName Name of the variable.
  28594. * @param vector3 Value to be set.
  28595. * @returns this effect.
  28596. */
  28597. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28598. /**
  28599. * Sets a float3 on a uniform variable.
  28600. * @param uniformName Name of the variable.
  28601. * @param x First float in float3.
  28602. * @param y Second float in float3.
  28603. * @param z Third float in float3.
  28604. * @returns this effect.
  28605. */
  28606. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28607. /**
  28608. * Sets a Vector4 on a uniform variable.
  28609. * @param uniformName Name of the variable.
  28610. * @param vector4 Value to be set.
  28611. * @returns this effect.
  28612. */
  28613. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28614. /**
  28615. * Sets a float4 on a uniform variable.
  28616. * @param uniformName Name of the variable.
  28617. * @param x First float in float4.
  28618. * @param y Second float in float4.
  28619. * @param z Third float in float4.
  28620. * @param w Fourth float in float4.
  28621. * @returns this effect.
  28622. */
  28623. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28624. /**
  28625. * Sets a Color3 on a uniform variable.
  28626. * @param uniformName Name of the variable.
  28627. * @param color3 Value to be set.
  28628. * @returns this effect.
  28629. */
  28630. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28631. /**
  28632. * Sets a Color4 on a uniform variable.
  28633. * @param uniformName Name of the variable.
  28634. * @param color3 Value to be set.
  28635. * @param alpha Alpha value to be set.
  28636. * @returns this effect.
  28637. */
  28638. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28639. /**
  28640. * Sets a Color4 on a uniform variable
  28641. * @param uniformName defines the name of the variable
  28642. * @param color4 defines the value to be set
  28643. * @returns this effect.
  28644. */
  28645. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28646. /** Release all associated resources */
  28647. dispose(): void;
  28648. /**
  28649. * This function will add a new shader to the shader store
  28650. * @param name the name of the shader
  28651. * @param pixelShader optional pixel shader content
  28652. * @param vertexShader optional vertex shader content
  28653. */
  28654. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28655. /**
  28656. * Store of each shader (The can be looked up using effect.key)
  28657. */
  28658. static ShadersStore: {
  28659. [key: string]: string;
  28660. };
  28661. /**
  28662. * Store of each included file for a shader (The can be looked up using effect.key)
  28663. */
  28664. static IncludesShadersStore: {
  28665. [key: string]: string;
  28666. };
  28667. /**
  28668. * Resets the cache of effects.
  28669. */
  28670. static ResetCache(): void;
  28671. }
  28672. }
  28673. declare module BABYLON {
  28674. /**
  28675. * Uniform buffer objects.
  28676. *
  28677. * Handles blocks of uniform on the GPU.
  28678. *
  28679. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28680. *
  28681. * For more information, please refer to :
  28682. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28683. */
  28684. export class UniformBuffer {
  28685. private _engine;
  28686. private _buffer;
  28687. private _data;
  28688. private _bufferData;
  28689. private _dynamic?;
  28690. private _uniformLocations;
  28691. private _uniformSizes;
  28692. private _uniformLocationPointer;
  28693. private _needSync;
  28694. private _noUBO;
  28695. private _currentEffect;
  28696. private static _MAX_UNIFORM_SIZE;
  28697. private static _tempBuffer;
  28698. /**
  28699. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  28700. * This is dynamic to allow compat with webgl 1 and 2.
  28701. * You will need to pass the name of the uniform as well as the value.
  28702. */
  28703. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  28704. /**
  28705. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  28706. * This is dynamic to allow compat with webgl 1 and 2.
  28707. * You will need to pass the name of the uniform as well as the value.
  28708. */
  28709. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  28710. /**
  28711. * Lambda to Update a single float in a uniform buffer.
  28712. * This is dynamic to allow compat with webgl 1 and 2.
  28713. * You will need to pass the name of the uniform as well as the value.
  28714. */
  28715. updateFloat: (name: string, x: number) => void;
  28716. /**
  28717. * Lambda to Update a vec2 of float in a uniform buffer.
  28718. * This is dynamic to allow compat with webgl 1 and 2.
  28719. * You will need to pass the name of the uniform as well as the value.
  28720. */
  28721. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  28722. /**
  28723. * Lambda to Update a vec3 of float in a uniform buffer.
  28724. * This is dynamic to allow compat with webgl 1 and 2.
  28725. * You will need to pass the name of the uniform as well as the value.
  28726. */
  28727. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  28728. /**
  28729. * Lambda to Update a vec4 of float in a uniform buffer.
  28730. * This is dynamic to allow compat with webgl 1 and 2.
  28731. * You will need to pass the name of the uniform as well as the value.
  28732. */
  28733. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  28734. /**
  28735. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  28736. * This is dynamic to allow compat with webgl 1 and 2.
  28737. * You will need to pass the name of the uniform as well as the value.
  28738. */
  28739. updateMatrix: (name: string, mat: Matrix) => void;
  28740. /**
  28741. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  28742. * This is dynamic to allow compat with webgl 1 and 2.
  28743. * You will need to pass the name of the uniform as well as the value.
  28744. */
  28745. updateVector3: (name: string, vector: Vector3) => void;
  28746. /**
  28747. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  28748. * This is dynamic to allow compat with webgl 1 and 2.
  28749. * You will need to pass the name of the uniform as well as the value.
  28750. */
  28751. updateVector4: (name: string, vector: Vector4) => void;
  28752. /**
  28753. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  28754. * This is dynamic to allow compat with webgl 1 and 2.
  28755. * You will need to pass the name of the uniform as well as the value.
  28756. */
  28757. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  28758. /**
  28759. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  28760. * This is dynamic to allow compat with webgl 1 and 2.
  28761. * You will need to pass the name of the uniform as well as the value.
  28762. */
  28763. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  28764. /**
  28765. * Instantiates a new Uniform buffer objects.
  28766. *
  28767. * Handles blocks of uniform on the GPU.
  28768. *
  28769. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28770. *
  28771. * For more information, please refer to :
  28772. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28773. * @param engine Define the engine the buffer is associated with
  28774. * @param data Define the data contained in the buffer
  28775. * @param dynamic Define if the buffer is updatable
  28776. */
  28777. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  28778. /**
  28779. * Indicates if the buffer is using the WebGL2 UBO implementation,
  28780. * or just falling back on setUniformXXX calls.
  28781. */
  28782. readonly useUbo: boolean;
  28783. /**
  28784. * Indicates if the WebGL underlying uniform buffer is in sync
  28785. * with the javascript cache data.
  28786. */
  28787. readonly isSync: boolean;
  28788. /**
  28789. * Indicates if the WebGL underlying uniform buffer is dynamic.
  28790. * Also, a dynamic UniformBuffer will disable cache verification and always
  28791. * update the underlying WebGL uniform buffer to the GPU.
  28792. * @returns if Dynamic, otherwise false
  28793. */
  28794. isDynamic(): boolean;
  28795. /**
  28796. * The data cache on JS side.
  28797. * @returns the underlying data as a float array
  28798. */
  28799. getData(): Float32Array;
  28800. /**
  28801. * The underlying WebGL Uniform buffer.
  28802. * @returns the webgl buffer
  28803. */
  28804. getBuffer(): Nullable<DataBuffer>;
  28805. /**
  28806. * std140 layout specifies how to align data within an UBO structure.
  28807. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  28808. * for specs.
  28809. */
  28810. private _fillAlignment;
  28811. /**
  28812. * Adds an uniform in the buffer.
  28813. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  28814. * for the layout to be correct !
  28815. * @param name Name of the uniform, as used in the uniform block in the shader.
  28816. * @param size Data size, or data directly.
  28817. */
  28818. addUniform(name: string, size: number | number[]): void;
  28819. /**
  28820. * Adds a Matrix 4x4 to the uniform buffer.
  28821. * @param name Name of the uniform, as used in the uniform block in the shader.
  28822. * @param mat A 4x4 matrix.
  28823. */
  28824. addMatrix(name: string, mat: Matrix): void;
  28825. /**
  28826. * Adds a vec2 to the uniform buffer.
  28827. * @param name Name of the uniform, as used in the uniform block in the shader.
  28828. * @param x Define the x component value of the vec2
  28829. * @param y Define the y component value of the vec2
  28830. */
  28831. addFloat2(name: string, x: number, y: number): void;
  28832. /**
  28833. * Adds a vec3 to the uniform buffer.
  28834. * @param name Name of the uniform, as used in the uniform block in the shader.
  28835. * @param x Define the x component value of the vec3
  28836. * @param y Define the y component value of the vec3
  28837. * @param z Define the z component value of the vec3
  28838. */
  28839. addFloat3(name: string, x: number, y: number, z: number): void;
  28840. /**
  28841. * Adds a vec3 to the uniform buffer.
  28842. * @param name Name of the uniform, as used in the uniform block in the shader.
  28843. * @param color Define the vec3 from a Color
  28844. */
  28845. addColor3(name: string, color: Color3): void;
  28846. /**
  28847. * Adds a vec4 to the uniform buffer.
  28848. * @param name Name of the uniform, as used in the uniform block in the shader.
  28849. * @param color Define the rgb components from a Color
  28850. * @param alpha Define the a component of the vec4
  28851. */
  28852. addColor4(name: string, color: Color3, alpha: number): void;
  28853. /**
  28854. * Adds a vec3 to the uniform buffer.
  28855. * @param name Name of the uniform, as used in the uniform block in the shader.
  28856. * @param vector Define the vec3 components from a Vector
  28857. */
  28858. addVector3(name: string, vector: Vector3): void;
  28859. /**
  28860. * Adds a Matrix 3x3 to the uniform buffer.
  28861. * @param name Name of the uniform, as used in the uniform block in the shader.
  28862. */
  28863. addMatrix3x3(name: string): void;
  28864. /**
  28865. * Adds a Matrix 2x2 to the uniform buffer.
  28866. * @param name Name of the uniform, as used in the uniform block in the shader.
  28867. */
  28868. addMatrix2x2(name: string): void;
  28869. /**
  28870. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  28871. */
  28872. create(): void;
  28873. /** @hidden */
  28874. _rebuild(): void;
  28875. /**
  28876. * Updates the WebGL Uniform Buffer on the GPU.
  28877. * If the `dynamic` flag is set to true, no cache comparison is done.
  28878. * Otherwise, the buffer will be updated only if the cache differs.
  28879. */
  28880. update(): void;
  28881. /**
  28882. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  28883. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28884. * @param data Define the flattened data
  28885. * @param size Define the size of the data.
  28886. */
  28887. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  28888. private _updateMatrix3x3ForUniform;
  28889. private _updateMatrix3x3ForEffect;
  28890. private _updateMatrix2x2ForEffect;
  28891. private _updateMatrix2x2ForUniform;
  28892. private _updateFloatForEffect;
  28893. private _updateFloatForUniform;
  28894. private _updateFloat2ForEffect;
  28895. private _updateFloat2ForUniform;
  28896. private _updateFloat3ForEffect;
  28897. private _updateFloat3ForUniform;
  28898. private _updateFloat4ForEffect;
  28899. private _updateFloat4ForUniform;
  28900. private _updateMatrixForEffect;
  28901. private _updateMatrixForUniform;
  28902. private _updateVector3ForEffect;
  28903. private _updateVector3ForUniform;
  28904. private _updateVector4ForEffect;
  28905. private _updateVector4ForUniform;
  28906. private _updateColor3ForEffect;
  28907. private _updateColor3ForUniform;
  28908. private _updateColor4ForEffect;
  28909. private _updateColor4ForUniform;
  28910. /**
  28911. * Sets a sampler uniform on the effect.
  28912. * @param name Define the name of the sampler.
  28913. * @param texture Define the texture to set in the sampler
  28914. */
  28915. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  28916. /**
  28917. * Directly updates the value of the uniform in the cache AND on the GPU.
  28918. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28919. * @param data Define the flattened data
  28920. */
  28921. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  28922. /**
  28923. * Binds this uniform buffer to an effect.
  28924. * @param effect Define the effect to bind the buffer to
  28925. * @param name Name of the uniform block in the shader.
  28926. */
  28927. bindToEffect(effect: Effect, name: string): void;
  28928. /**
  28929. * Disposes the uniform buffer.
  28930. */
  28931. dispose(): void;
  28932. }
  28933. }
  28934. declare module BABYLON {
  28935. /**
  28936. * Class used to work with sound analyzer using fast fourier transform (FFT)
  28937. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28938. */
  28939. export class Analyser {
  28940. /**
  28941. * Gets or sets the smoothing
  28942. * @ignorenaming
  28943. */
  28944. SMOOTHING: number;
  28945. /**
  28946. * Gets or sets the FFT table size
  28947. * @ignorenaming
  28948. */
  28949. FFT_SIZE: number;
  28950. /**
  28951. * Gets or sets the bar graph amplitude
  28952. * @ignorenaming
  28953. */
  28954. BARGRAPHAMPLITUDE: number;
  28955. /**
  28956. * Gets or sets the position of the debug canvas
  28957. * @ignorenaming
  28958. */
  28959. DEBUGCANVASPOS: {
  28960. x: number;
  28961. y: number;
  28962. };
  28963. /**
  28964. * Gets or sets the debug canvas size
  28965. * @ignorenaming
  28966. */
  28967. DEBUGCANVASSIZE: {
  28968. width: number;
  28969. height: number;
  28970. };
  28971. private _byteFreqs;
  28972. private _byteTime;
  28973. private _floatFreqs;
  28974. private _webAudioAnalyser;
  28975. private _debugCanvas;
  28976. private _debugCanvasContext;
  28977. private _scene;
  28978. private _registerFunc;
  28979. private _audioEngine;
  28980. /**
  28981. * Creates a new analyser
  28982. * @param scene defines hosting scene
  28983. */
  28984. constructor(scene: Scene);
  28985. /**
  28986. * Get the number of data values you will have to play with for the visualization
  28987. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  28988. * @returns a number
  28989. */
  28990. getFrequencyBinCount(): number;
  28991. /**
  28992. * Gets the current frequency data as a byte array
  28993. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  28994. * @returns a Uint8Array
  28995. */
  28996. getByteFrequencyData(): Uint8Array;
  28997. /**
  28998. * Gets the current waveform as a byte array
  28999. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29000. * @returns a Uint8Array
  29001. */
  29002. getByteTimeDomainData(): Uint8Array;
  29003. /**
  29004. * Gets the current frequency data as a float array
  29005. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29006. * @returns a Float32Array
  29007. */
  29008. getFloatFrequencyData(): Float32Array;
  29009. /**
  29010. * Renders the debug canvas
  29011. */
  29012. drawDebugCanvas(): void;
  29013. /**
  29014. * Stops rendering the debug canvas and removes it
  29015. */
  29016. stopDebugCanvas(): void;
  29017. /**
  29018. * Connects two audio nodes
  29019. * @param inputAudioNode defines first node to connect
  29020. * @param outputAudioNode defines second node to connect
  29021. */
  29022. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29023. /**
  29024. * Releases all associated resources
  29025. */
  29026. dispose(): void;
  29027. }
  29028. }
  29029. declare module BABYLON {
  29030. /**
  29031. * This represents an audio engine and it is responsible
  29032. * to play, synchronize and analyse sounds throughout the application.
  29033. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29034. */
  29035. export interface IAudioEngine extends IDisposable {
  29036. /**
  29037. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29038. */
  29039. readonly canUseWebAudio: boolean;
  29040. /**
  29041. * Gets the current AudioContext if available.
  29042. */
  29043. readonly audioContext: Nullable<AudioContext>;
  29044. /**
  29045. * The master gain node defines the global audio volume of your audio engine.
  29046. */
  29047. readonly masterGain: GainNode;
  29048. /**
  29049. * Gets whether or not mp3 are supported by your browser.
  29050. */
  29051. readonly isMP3supported: boolean;
  29052. /**
  29053. * Gets whether or not ogg are supported by your browser.
  29054. */
  29055. readonly isOGGsupported: boolean;
  29056. /**
  29057. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29058. * @ignoreNaming
  29059. */
  29060. WarnedWebAudioUnsupported: boolean;
  29061. /**
  29062. * Defines if the audio engine relies on a custom unlocked button.
  29063. * In this case, the embedded button will not be displayed.
  29064. */
  29065. useCustomUnlockedButton: boolean;
  29066. /**
  29067. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29068. */
  29069. readonly unlocked: boolean;
  29070. /**
  29071. * Event raised when audio has been unlocked on the browser.
  29072. */
  29073. onAudioUnlockedObservable: Observable<AudioEngine>;
  29074. /**
  29075. * Event raised when audio has been locked on the browser.
  29076. */
  29077. onAudioLockedObservable: Observable<AudioEngine>;
  29078. /**
  29079. * Flags the audio engine in Locked state.
  29080. * This happens due to new browser policies preventing audio to autoplay.
  29081. */
  29082. lock(): void;
  29083. /**
  29084. * Unlocks the audio engine once a user action has been done on the dom.
  29085. * This is helpful to resume play once browser policies have been satisfied.
  29086. */
  29087. unlock(): void;
  29088. }
  29089. /**
  29090. * This represents the default audio engine used in babylon.
  29091. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29092. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29093. */
  29094. export class AudioEngine implements IAudioEngine {
  29095. private _audioContext;
  29096. private _audioContextInitialized;
  29097. private _muteButton;
  29098. private _hostElement;
  29099. /**
  29100. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29101. */
  29102. canUseWebAudio: boolean;
  29103. /**
  29104. * The master gain node defines the global audio volume of your audio engine.
  29105. */
  29106. masterGain: GainNode;
  29107. /**
  29108. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29109. * @ignoreNaming
  29110. */
  29111. WarnedWebAudioUnsupported: boolean;
  29112. /**
  29113. * Gets whether or not mp3 are supported by your browser.
  29114. */
  29115. isMP3supported: boolean;
  29116. /**
  29117. * Gets whether or not ogg are supported by your browser.
  29118. */
  29119. isOGGsupported: boolean;
  29120. /**
  29121. * Gets whether audio has been unlocked on the device.
  29122. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29123. * a user interaction has happened.
  29124. */
  29125. unlocked: boolean;
  29126. /**
  29127. * Defines if the audio engine relies on a custom unlocked button.
  29128. * In this case, the embedded button will not be displayed.
  29129. */
  29130. useCustomUnlockedButton: boolean;
  29131. /**
  29132. * Event raised when audio has been unlocked on the browser.
  29133. */
  29134. onAudioUnlockedObservable: Observable<AudioEngine>;
  29135. /**
  29136. * Event raised when audio has been locked on the browser.
  29137. */
  29138. onAudioLockedObservable: Observable<AudioEngine>;
  29139. /**
  29140. * Gets the current AudioContext if available.
  29141. */
  29142. readonly audioContext: Nullable<AudioContext>;
  29143. private _connectedAnalyser;
  29144. /**
  29145. * Instantiates a new audio engine.
  29146. *
  29147. * There should be only one per page as some browsers restrict the number
  29148. * of audio contexts you can create.
  29149. * @param hostElement defines the host element where to display the mute icon if necessary
  29150. */
  29151. constructor(hostElement?: Nullable<HTMLElement>);
  29152. /**
  29153. * Flags the audio engine in Locked state.
  29154. * This happens due to new browser policies preventing audio to autoplay.
  29155. */
  29156. lock(): void;
  29157. /**
  29158. * Unlocks the audio engine once a user action has been done on the dom.
  29159. * This is helpful to resume play once browser policies have been satisfied.
  29160. */
  29161. unlock(): void;
  29162. private _resumeAudioContext;
  29163. private _initializeAudioContext;
  29164. private _tryToRun;
  29165. private _triggerRunningState;
  29166. private _triggerSuspendedState;
  29167. private _displayMuteButton;
  29168. private _moveButtonToTopLeft;
  29169. private _onResize;
  29170. private _hideMuteButton;
  29171. /**
  29172. * Destroy and release the resources associated with the audio ccontext.
  29173. */
  29174. dispose(): void;
  29175. /**
  29176. * Gets the global volume sets on the master gain.
  29177. * @returns the global volume if set or -1 otherwise
  29178. */
  29179. getGlobalVolume(): number;
  29180. /**
  29181. * Sets the global volume of your experience (sets on the master gain).
  29182. * @param newVolume Defines the new global volume of the application
  29183. */
  29184. setGlobalVolume(newVolume: number): void;
  29185. /**
  29186. * Connect the audio engine to an audio analyser allowing some amazing
  29187. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  29188. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  29189. * @param analyser The analyser to connect to the engine
  29190. */
  29191. connectToAnalyser(analyser: Analyser): void;
  29192. }
  29193. }
  29194. declare module BABYLON {
  29195. /**
  29196. * Interface used to present a loading screen while loading a scene
  29197. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29198. */
  29199. export interface ILoadingScreen {
  29200. /**
  29201. * Function called to display the loading screen
  29202. */
  29203. displayLoadingUI: () => void;
  29204. /**
  29205. * Function called to hide the loading screen
  29206. */
  29207. hideLoadingUI: () => void;
  29208. /**
  29209. * Gets or sets the color to use for the background
  29210. */
  29211. loadingUIBackgroundColor: string;
  29212. /**
  29213. * Gets or sets the text to display while loading
  29214. */
  29215. loadingUIText: string;
  29216. }
  29217. /**
  29218. * Class used for the default loading screen
  29219. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29220. */
  29221. export class DefaultLoadingScreen implements ILoadingScreen {
  29222. private _renderingCanvas;
  29223. private _loadingText;
  29224. private _loadingDivBackgroundColor;
  29225. private _loadingDiv;
  29226. private _loadingTextDiv;
  29227. /** Gets or sets the logo url to use for the default loading screen */
  29228. static DefaultLogoUrl: string;
  29229. /** Gets or sets the spinner url to use for the default loading screen */
  29230. static DefaultSpinnerUrl: string;
  29231. /**
  29232. * Creates a new default loading screen
  29233. * @param _renderingCanvas defines the canvas used to render the scene
  29234. * @param _loadingText defines the default text to display
  29235. * @param _loadingDivBackgroundColor defines the default background color
  29236. */
  29237. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  29238. /**
  29239. * Function called to display the loading screen
  29240. */
  29241. displayLoadingUI(): void;
  29242. /**
  29243. * Function called to hide the loading screen
  29244. */
  29245. hideLoadingUI(): void;
  29246. /**
  29247. * Gets or sets the text to display while loading
  29248. */
  29249. loadingUIText: string;
  29250. /**
  29251. * Gets or sets the color to use for the background
  29252. */
  29253. loadingUIBackgroundColor: string;
  29254. private _resizeLoadingUI;
  29255. }
  29256. }
  29257. declare module BABYLON {
  29258. /** @hidden */
  29259. export class WebGLPipelineContext implements IPipelineContext {
  29260. engine: Engine;
  29261. program: Nullable<WebGLProgram>;
  29262. context?: WebGLRenderingContext;
  29263. vertexShader?: WebGLShader;
  29264. fragmentShader?: WebGLShader;
  29265. isParallelCompiled: boolean;
  29266. onCompiled?: () => void;
  29267. transformFeedback?: WebGLTransformFeedback | null;
  29268. readonly isAsync: boolean;
  29269. readonly isReady: boolean;
  29270. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  29271. }
  29272. }
  29273. declare module BABYLON {
  29274. /** @hidden */
  29275. export class WebGLDataBuffer extends DataBuffer {
  29276. private _buffer;
  29277. constructor(resource: WebGLBuffer);
  29278. readonly underlyingResource: any;
  29279. }
  29280. }
  29281. declare module BABYLON {
  29282. /** @hidden */
  29283. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29284. attributeProcessor(attribute: string): string;
  29285. varyingProcessor(varying: string, isFragment: boolean): string;
  29286. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29287. }
  29288. }
  29289. declare module BABYLON {
  29290. /**
  29291. * This class is used to track a performance counter which is number based.
  29292. * The user has access to many properties which give statistics of different nature.
  29293. *
  29294. * The implementer can track two kinds of Performance Counter: time and count.
  29295. * 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.
  29296. * 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.
  29297. */
  29298. export class PerfCounter {
  29299. /**
  29300. * Gets or sets a global boolean to turn on and off all the counters
  29301. */
  29302. static Enabled: boolean;
  29303. /**
  29304. * Returns the smallest value ever
  29305. */
  29306. readonly min: number;
  29307. /**
  29308. * Returns the biggest value ever
  29309. */
  29310. readonly max: number;
  29311. /**
  29312. * Returns the average value since the performance counter is running
  29313. */
  29314. readonly average: number;
  29315. /**
  29316. * Returns the average value of the last second the counter was monitored
  29317. */
  29318. readonly lastSecAverage: number;
  29319. /**
  29320. * Returns the current value
  29321. */
  29322. readonly current: number;
  29323. /**
  29324. * Gets the accumulated total
  29325. */
  29326. readonly total: number;
  29327. /**
  29328. * Gets the total value count
  29329. */
  29330. readonly count: number;
  29331. /**
  29332. * Creates a new counter
  29333. */
  29334. constructor();
  29335. /**
  29336. * Call this method to start monitoring a new frame.
  29337. * 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.
  29338. */
  29339. fetchNewFrame(): void;
  29340. /**
  29341. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29342. * @param newCount the count value to add to the monitored count
  29343. * @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.
  29344. */
  29345. addCount(newCount: number, fetchResult: boolean): void;
  29346. /**
  29347. * Start monitoring this performance counter
  29348. */
  29349. beginMonitoring(): void;
  29350. /**
  29351. * Compute the time lapsed since the previous beginMonitoring() call.
  29352. * @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
  29353. */
  29354. endMonitoring(newFrame?: boolean): void;
  29355. private _fetchResult;
  29356. private _startMonitoringTime;
  29357. private _min;
  29358. private _max;
  29359. private _average;
  29360. private _current;
  29361. private _totalValueCount;
  29362. private _totalAccumulated;
  29363. private _lastSecAverage;
  29364. private _lastSecAccumulated;
  29365. private _lastSecTime;
  29366. private _lastSecValueCount;
  29367. }
  29368. }
  29369. declare module BABYLON {
  29370. /**
  29371. * Interface for any object that can request an animation frame
  29372. */
  29373. export interface ICustomAnimationFrameRequester {
  29374. /**
  29375. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  29376. */
  29377. renderFunction?: Function;
  29378. /**
  29379. * Called to request the next frame to render to
  29380. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  29381. */
  29382. requestAnimationFrame: Function;
  29383. /**
  29384. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  29385. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  29386. */
  29387. requestID?: number;
  29388. }
  29389. }
  29390. declare module BABYLON {
  29391. /**
  29392. * Settings for finer control over video usage
  29393. */
  29394. export interface VideoTextureSettings {
  29395. /**
  29396. * Applies `autoplay` to video, if specified
  29397. */
  29398. autoPlay?: boolean;
  29399. /**
  29400. * Applies `loop` to video, if specified
  29401. */
  29402. loop?: boolean;
  29403. /**
  29404. * Automatically updates internal texture from video at every frame in the render loop
  29405. */
  29406. autoUpdateTexture: boolean;
  29407. /**
  29408. * Image src displayed during the video loading or until the user interacts with the video.
  29409. */
  29410. poster?: string;
  29411. }
  29412. /**
  29413. * If you want to display a video in your scene, this is the special texture for that.
  29414. * This special texture works similar to other textures, with the exception of a few parameters.
  29415. * @see https://doc.babylonjs.com/how_to/video_texture
  29416. */
  29417. export class VideoTexture extends Texture {
  29418. /**
  29419. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29420. */
  29421. readonly autoUpdateTexture: boolean;
  29422. /**
  29423. * The video instance used by the texture internally
  29424. */
  29425. readonly video: HTMLVideoElement;
  29426. private _onUserActionRequestedObservable;
  29427. /**
  29428. * Event triggerd when a dom action is required by the user to play the video.
  29429. * This happens due to recent changes in browser policies preventing video to auto start.
  29430. */
  29431. readonly onUserActionRequestedObservable: Observable<Texture>;
  29432. private _generateMipMaps;
  29433. private _engine;
  29434. private _stillImageCaptured;
  29435. private _displayingPosterTexture;
  29436. private _settings;
  29437. private _createInternalTextureOnEvent;
  29438. /**
  29439. * Creates a video texture.
  29440. * If you want to display a video in your scene, this is the special texture for that.
  29441. * This special texture works similar to other textures, with the exception of a few parameters.
  29442. * @see https://doc.babylonjs.com/how_to/video_texture
  29443. * @param name optional name, will detect from video source, if not defined
  29444. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29445. * @param scene is obviously the current scene.
  29446. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29447. * @param invertY is false by default but can be used to invert video on Y axis
  29448. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29449. * @param settings allows finer control over video usage
  29450. */
  29451. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29452. private _getName;
  29453. private _getVideo;
  29454. private _createInternalTexture;
  29455. private reset;
  29456. /**
  29457. * @hidden Internal method to initiate `update`.
  29458. */
  29459. _rebuild(): void;
  29460. /**
  29461. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29462. */
  29463. update(): void;
  29464. /**
  29465. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29466. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29467. */
  29468. updateTexture(isVisible: boolean): void;
  29469. protected _updateInternalTexture: () => void;
  29470. /**
  29471. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29472. * @param url New url.
  29473. */
  29474. updateURL(url: string): void;
  29475. /**
  29476. * Dispose the texture and release its associated resources.
  29477. */
  29478. dispose(): void;
  29479. /**
  29480. * Creates a video texture straight from a stream.
  29481. * @param scene Define the scene the texture should be created in
  29482. * @param stream Define the stream the texture should be created from
  29483. * @returns The created video texture as a promise
  29484. */
  29485. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29486. /**
  29487. * Creates a video texture straight from your WebCam video feed.
  29488. * @param scene Define the scene the texture should be created in
  29489. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29490. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29491. * @returns The created video texture as a promise
  29492. */
  29493. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29494. minWidth: number;
  29495. maxWidth: number;
  29496. minHeight: number;
  29497. maxHeight: number;
  29498. deviceId: string;
  29499. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29500. /**
  29501. * Creates a video texture straight from your WebCam video feed.
  29502. * @param scene Define the scene the texture should be created in
  29503. * @param onReady Define a callback to triggered once the texture will be ready
  29504. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29505. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29506. */
  29507. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29508. minWidth: number;
  29509. maxWidth: number;
  29510. minHeight: number;
  29511. maxHeight: number;
  29512. deviceId: string;
  29513. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29514. }
  29515. }
  29516. declare module BABYLON {
  29517. /**
  29518. * Defines the interface used by objects containing a viewport (like a camera)
  29519. */
  29520. interface IViewportOwnerLike {
  29521. /**
  29522. * Gets or sets the viewport
  29523. */
  29524. viewport: IViewportLike;
  29525. }
  29526. /**
  29527. * Interface for attribute information associated with buffer instanciation
  29528. */
  29529. export class InstancingAttributeInfo {
  29530. /**
  29531. * Index/offset of the attribute in the vertex shader
  29532. */
  29533. index: number;
  29534. /**
  29535. * size of the attribute, 1, 2, 3 or 4
  29536. */
  29537. attributeSize: number;
  29538. /**
  29539. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29540. * default is FLOAT
  29541. */
  29542. attribyteType: number;
  29543. /**
  29544. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29545. */
  29546. normalized: boolean;
  29547. /**
  29548. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29549. */
  29550. offset: number;
  29551. /**
  29552. * Name of the GLSL attribute, for debugging purpose only
  29553. */
  29554. attributeName: string;
  29555. }
  29556. /**
  29557. * Define options used to create a depth texture
  29558. */
  29559. export class DepthTextureCreationOptions {
  29560. /** Specifies whether or not a stencil should be allocated in the texture */
  29561. generateStencil?: boolean;
  29562. /** Specifies whether or not bilinear filtering is enable on the texture */
  29563. bilinearFiltering?: boolean;
  29564. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  29565. comparisonFunction?: number;
  29566. /** Specifies if the created texture is a cube texture */
  29567. isCube?: boolean;
  29568. }
  29569. /**
  29570. * Class used to describe the capabilities of the engine relatively to the current browser
  29571. */
  29572. export class EngineCapabilities {
  29573. /** Maximum textures units per fragment shader */
  29574. maxTexturesImageUnits: number;
  29575. /** Maximum texture units per vertex shader */
  29576. maxVertexTextureImageUnits: number;
  29577. /** Maximum textures units in the entire pipeline */
  29578. maxCombinedTexturesImageUnits: number;
  29579. /** Maximum texture size */
  29580. maxTextureSize: number;
  29581. /** Maximum cube texture size */
  29582. maxCubemapTextureSize: number;
  29583. /** Maximum render texture size */
  29584. maxRenderTextureSize: number;
  29585. /** Maximum number of vertex attributes */
  29586. maxVertexAttribs: number;
  29587. /** Maximum number of varyings */
  29588. maxVaryingVectors: number;
  29589. /** Maximum number of uniforms per vertex shader */
  29590. maxVertexUniformVectors: number;
  29591. /** Maximum number of uniforms per fragment shader */
  29592. maxFragmentUniformVectors: number;
  29593. /** Defines if standard derivates (dx/dy) are supported */
  29594. standardDerivatives: boolean;
  29595. /** Defines if s3tc texture compression is supported */
  29596. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29597. /** Defines if pvrtc texture compression is supported */
  29598. pvrtc: any;
  29599. /** Defines if etc1 texture compression is supported */
  29600. etc1: any;
  29601. /** Defines if etc2 texture compression is supported */
  29602. etc2: any;
  29603. /** Defines if astc texture compression is supported */
  29604. astc: any;
  29605. /** Defines if float textures are supported */
  29606. textureFloat: boolean;
  29607. /** Defines if vertex array objects are supported */
  29608. vertexArrayObject: boolean;
  29609. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29610. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29611. /** Gets the maximum level of anisotropy supported */
  29612. maxAnisotropy: number;
  29613. /** Defines if instancing is supported */
  29614. instancedArrays: boolean;
  29615. /** Defines if 32 bits indices are supported */
  29616. uintIndices: boolean;
  29617. /** Defines if high precision shaders are supported */
  29618. highPrecisionShaderSupported: boolean;
  29619. /** Defines if depth reading in the fragment shader is supported */
  29620. fragmentDepthSupported: boolean;
  29621. /** Defines if float texture linear filtering is supported*/
  29622. textureFloatLinearFiltering: boolean;
  29623. /** Defines if rendering to float textures is supported */
  29624. textureFloatRender: boolean;
  29625. /** Defines if half float textures are supported*/
  29626. textureHalfFloat: boolean;
  29627. /** Defines if half float texture linear filtering is supported*/
  29628. textureHalfFloatLinearFiltering: boolean;
  29629. /** Defines if rendering to half float textures is supported */
  29630. textureHalfFloatRender: boolean;
  29631. /** Defines if textureLOD shader command is supported */
  29632. textureLOD: boolean;
  29633. /** Defines if draw buffers extension is supported */
  29634. drawBuffersExtension: boolean;
  29635. /** Defines if depth textures are supported */
  29636. depthTextureExtension: boolean;
  29637. /** Defines if float color buffer are supported */
  29638. colorBufferFloat: boolean;
  29639. /** Gets disjoint timer query extension (null if not supported) */
  29640. timerQuery: EXT_disjoint_timer_query;
  29641. /** Defines if timestamp can be used with timer query */
  29642. canUseTimestampForTimerQuery: boolean;
  29643. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29644. multiview: any;
  29645. /** Function used to let the system compiles shaders in background */
  29646. parallelShaderCompile: {
  29647. COMPLETION_STATUS_KHR: number;
  29648. };
  29649. /** Max number of texture samples for MSAA */
  29650. maxMSAASamples: number;
  29651. }
  29652. /** Interface defining initialization parameters for Engine class */
  29653. export interface EngineOptions extends WebGLContextAttributes {
  29654. /**
  29655. * Defines if the engine should no exceed a specified device ratio
  29656. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29657. */
  29658. limitDeviceRatio?: number;
  29659. /**
  29660. * Defines if webvr should be enabled automatically
  29661. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29662. */
  29663. autoEnableWebVR?: boolean;
  29664. /**
  29665. * Defines if webgl2 should be turned off even if supported
  29666. * @see http://doc.babylonjs.com/features/webgl2
  29667. */
  29668. disableWebGL2Support?: boolean;
  29669. /**
  29670. * Defines if webaudio should be initialized as well
  29671. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29672. */
  29673. audioEngine?: boolean;
  29674. /**
  29675. * Defines if animations should run using a deterministic lock step
  29676. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29677. */
  29678. deterministicLockstep?: boolean;
  29679. /** Defines the maximum steps to use with deterministic lock step mode */
  29680. lockstepMaxSteps?: number;
  29681. /**
  29682. * Defines that engine should ignore context lost events
  29683. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29684. */
  29685. doNotHandleContextLost?: boolean;
  29686. /**
  29687. * Defines that engine should ignore modifying touch action attribute and style
  29688. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29689. */
  29690. doNotHandleTouchAction?: boolean;
  29691. /**
  29692. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29693. */
  29694. useHighPrecisionFloats?: boolean;
  29695. }
  29696. /**
  29697. * Defines the interface used by display changed events
  29698. */
  29699. export interface IDisplayChangedEventArgs {
  29700. /** Gets the vrDisplay object (if any) */
  29701. vrDisplay: Nullable<any>;
  29702. /** Gets a boolean indicating if webVR is supported */
  29703. vrSupported: boolean;
  29704. }
  29705. /**
  29706. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  29707. */
  29708. export class Engine {
  29709. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29710. static ExceptionList: ({
  29711. key: string;
  29712. capture: string;
  29713. captureConstraint: number;
  29714. targets: string[];
  29715. } | {
  29716. key: string;
  29717. capture: null;
  29718. captureConstraint: null;
  29719. targets: string[];
  29720. })[];
  29721. /** Gets the list of created engines */
  29722. static readonly Instances: Engine[];
  29723. /**
  29724. * Gets the latest created engine
  29725. */
  29726. static readonly LastCreatedEngine: Nullable<Engine>;
  29727. /**
  29728. * Gets the latest created scene
  29729. */
  29730. static readonly LastCreatedScene: Nullable<Scene>;
  29731. /**
  29732. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  29733. * @param flag defines which part of the materials must be marked as dirty
  29734. * @param predicate defines a predicate used to filter which materials should be affected
  29735. */
  29736. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  29737. /** @hidden */
  29738. static _TextureLoaders: IInternalTextureLoader[];
  29739. /** Defines that alpha blending is disabled */
  29740. static readonly ALPHA_DISABLE: number;
  29741. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  29742. static readonly ALPHA_ADD: number;
  29743. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  29744. static readonly ALPHA_COMBINE: number;
  29745. /** Defines that alpha blending to DEST - SRC * DEST */
  29746. static readonly ALPHA_SUBTRACT: number;
  29747. /** Defines that alpha blending to SRC * DEST */
  29748. static readonly ALPHA_MULTIPLY: number;
  29749. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  29750. static readonly ALPHA_MAXIMIZED: number;
  29751. /** Defines that alpha blending to SRC + DEST */
  29752. static readonly ALPHA_ONEONE: number;
  29753. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  29754. static readonly ALPHA_PREMULTIPLIED: number;
  29755. /**
  29756. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  29757. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  29758. */
  29759. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  29760. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  29761. static readonly ALPHA_INTERPOLATE: number;
  29762. /**
  29763. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  29764. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  29765. */
  29766. static readonly ALPHA_SCREENMODE: number;
  29767. /** Defines that the ressource is not delayed*/
  29768. static readonly DELAYLOADSTATE_NONE: number;
  29769. /** Defines that the ressource was successfully delay loaded */
  29770. static readonly DELAYLOADSTATE_LOADED: number;
  29771. /** Defines that the ressource is currently delay loading */
  29772. static readonly DELAYLOADSTATE_LOADING: number;
  29773. /** Defines that the ressource is delayed and has not started loading */
  29774. static readonly DELAYLOADSTATE_NOTLOADED: number;
  29775. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  29776. static readonly NEVER: number;
  29777. /** 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 */
  29778. static readonly ALWAYS: number;
  29779. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  29780. static readonly LESS: number;
  29781. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  29782. static readonly EQUAL: number;
  29783. /** 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 */
  29784. static readonly LEQUAL: number;
  29785. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  29786. static readonly GREATER: number;
  29787. /** 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 */
  29788. static readonly GEQUAL: number;
  29789. /** 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 */
  29790. static readonly NOTEQUAL: number;
  29791. /** Passed to stencilOperation to specify that stencil value must be kept */
  29792. static readonly KEEP: number;
  29793. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29794. static readonly REPLACE: number;
  29795. /** Passed to stencilOperation to specify that stencil value must be incremented */
  29796. static readonly INCR: number;
  29797. /** Passed to stencilOperation to specify that stencil value must be decremented */
  29798. static readonly DECR: number;
  29799. /** Passed to stencilOperation to specify that stencil value must be inverted */
  29800. static readonly INVERT: number;
  29801. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  29802. static readonly INCR_WRAP: number;
  29803. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  29804. static readonly DECR_WRAP: number;
  29805. /** Texture is not repeating outside of 0..1 UVs */
  29806. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  29807. /** Texture is repeating outside of 0..1 UVs */
  29808. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  29809. /** Texture is repeating and mirrored */
  29810. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  29811. /** ALPHA */
  29812. static readonly TEXTUREFORMAT_ALPHA: number;
  29813. /** LUMINANCE */
  29814. static readonly TEXTUREFORMAT_LUMINANCE: number;
  29815. /** LUMINANCE_ALPHA */
  29816. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  29817. /** RGB */
  29818. static readonly TEXTUREFORMAT_RGB: number;
  29819. /** RGBA */
  29820. static readonly TEXTUREFORMAT_RGBA: number;
  29821. /** RED */
  29822. static readonly TEXTUREFORMAT_RED: number;
  29823. /** RED (2nd reference) */
  29824. static readonly TEXTUREFORMAT_R: number;
  29825. /** RG */
  29826. static readonly TEXTUREFORMAT_RG: number;
  29827. /** RED_INTEGER */
  29828. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  29829. /** RED_INTEGER (2nd reference) */
  29830. static readonly TEXTUREFORMAT_R_INTEGER: number;
  29831. /** RG_INTEGER */
  29832. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  29833. /** RGB_INTEGER */
  29834. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  29835. /** RGBA_INTEGER */
  29836. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  29837. /** UNSIGNED_BYTE */
  29838. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  29839. /** UNSIGNED_BYTE (2nd reference) */
  29840. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  29841. /** FLOAT */
  29842. static readonly TEXTURETYPE_FLOAT: number;
  29843. /** HALF_FLOAT */
  29844. static readonly TEXTURETYPE_HALF_FLOAT: number;
  29845. /** BYTE */
  29846. static readonly TEXTURETYPE_BYTE: number;
  29847. /** SHORT */
  29848. static readonly TEXTURETYPE_SHORT: number;
  29849. /** UNSIGNED_SHORT */
  29850. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  29851. /** INT */
  29852. static readonly TEXTURETYPE_INT: number;
  29853. /** UNSIGNED_INT */
  29854. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  29855. /** UNSIGNED_SHORT_4_4_4_4 */
  29856. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  29857. /** UNSIGNED_SHORT_5_5_5_1 */
  29858. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  29859. /** UNSIGNED_SHORT_5_6_5 */
  29860. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  29861. /** UNSIGNED_INT_2_10_10_10_REV */
  29862. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  29863. /** UNSIGNED_INT_24_8 */
  29864. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  29865. /** UNSIGNED_INT_10F_11F_11F_REV */
  29866. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  29867. /** UNSIGNED_INT_5_9_9_9_REV */
  29868. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  29869. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  29870. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  29871. /** nearest is mag = nearest and min = nearest and mip = linear */
  29872. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  29873. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29874. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  29875. /** Trilinear is mag = linear and min = linear and mip = linear */
  29876. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  29877. /** nearest is mag = nearest and min = nearest and mip = linear */
  29878. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  29879. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29880. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  29881. /** Trilinear is mag = linear and min = linear and mip = linear */
  29882. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  29883. /** mag = nearest and min = nearest and mip = nearest */
  29884. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  29885. /** mag = nearest and min = linear and mip = nearest */
  29886. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  29887. /** mag = nearest and min = linear and mip = linear */
  29888. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  29889. /** mag = nearest and min = linear and mip = none */
  29890. static readonly TEXTURE_NEAREST_LINEAR: number;
  29891. /** mag = nearest and min = nearest and mip = none */
  29892. static readonly TEXTURE_NEAREST_NEAREST: number;
  29893. /** mag = linear and min = nearest and mip = nearest */
  29894. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  29895. /** mag = linear and min = nearest and mip = linear */
  29896. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  29897. /** mag = linear and min = linear and mip = none */
  29898. static readonly TEXTURE_LINEAR_LINEAR: number;
  29899. /** mag = linear and min = nearest and mip = none */
  29900. static readonly TEXTURE_LINEAR_NEAREST: number;
  29901. /** Explicit coordinates mode */
  29902. static readonly TEXTURE_EXPLICIT_MODE: number;
  29903. /** Spherical coordinates mode */
  29904. static readonly TEXTURE_SPHERICAL_MODE: number;
  29905. /** Planar coordinates mode */
  29906. static readonly TEXTURE_PLANAR_MODE: number;
  29907. /** Cubic coordinates mode */
  29908. static readonly TEXTURE_CUBIC_MODE: number;
  29909. /** Projection coordinates mode */
  29910. static readonly TEXTURE_PROJECTION_MODE: number;
  29911. /** Skybox coordinates mode */
  29912. static readonly TEXTURE_SKYBOX_MODE: number;
  29913. /** Inverse Cubic coordinates mode */
  29914. static readonly TEXTURE_INVCUBIC_MODE: number;
  29915. /** Equirectangular coordinates mode */
  29916. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  29917. /** Equirectangular Fixed coordinates mode */
  29918. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  29919. /** Equirectangular Fixed Mirrored coordinates mode */
  29920. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29921. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  29922. static readonly SCALEMODE_FLOOR: number;
  29923. /** Defines that texture rescaling will look for the nearest power of 2 size */
  29924. static readonly SCALEMODE_NEAREST: number;
  29925. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  29926. static readonly SCALEMODE_CEILING: number;
  29927. /**
  29928. * Returns the current npm package of the sdk
  29929. */
  29930. static readonly NpmPackage: string;
  29931. /**
  29932. * Returns the current version of the framework
  29933. */
  29934. static readonly Version: string;
  29935. /**
  29936. * Returns a string describing the current engine
  29937. */
  29938. readonly description: string;
  29939. /**
  29940. * Gets or sets the epsilon value used by collision engine
  29941. */
  29942. static CollisionsEpsilon: number;
  29943. /**
  29944. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29945. */
  29946. static ShadersRepository: string;
  29947. /**
  29948. * Method called to create the default loading screen.
  29949. * This can be overriden in your own app.
  29950. * @param canvas The rendering canvas element
  29951. * @returns The loading screen
  29952. */
  29953. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  29954. /**
  29955. * Method called to create the default rescale post process on each engine.
  29956. */
  29957. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  29958. /** @hidden */
  29959. _shaderProcessor: IShaderProcessor;
  29960. /**
  29961. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29962. */
  29963. forcePOTTextures: boolean;
  29964. /**
  29965. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29966. */
  29967. isFullscreen: boolean;
  29968. /**
  29969. * Gets a boolean indicating if the pointer is currently locked
  29970. */
  29971. isPointerLock: boolean;
  29972. /**
  29973. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29974. */
  29975. cullBackFaces: boolean;
  29976. /**
  29977. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29978. */
  29979. renderEvenInBackground: boolean;
  29980. /**
  29981. * Gets or sets a boolean indicating that cache can be kept between frames
  29982. */
  29983. preventCacheWipeBetweenFrames: boolean;
  29984. /**
  29985. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  29986. **/
  29987. enableOfflineSupport: boolean;
  29988. /**
  29989. * 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)
  29990. **/
  29991. disableManifestCheck: boolean;
  29992. /**
  29993. * Gets the list of created scenes
  29994. */
  29995. scenes: Scene[];
  29996. /**
  29997. * Event raised when a new scene is created
  29998. */
  29999. onNewSceneAddedObservable: Observable<Scene>;
  30000. /**
  30001. * Gets the list of created postprocesses
  30002. */
  30003. postProcesses: PostProcess[];
  30004. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30005. validateShaderPrograms: boolean;
  30006. /**
  30007. * Observable event triggered each time the rendering canvas is resized
  30008. */
  30009. onResizeObservable: Observable<Engine>;
  30010. /**
  30011. * Observable event triggered each time the canvas loses focus
  30012. */
  30013. onCanvasBlurObservable: Observable<Engine>;
  30014. /**
  30015. * Observable event triggered each time the canvas gains focus
  30016. */
  30017. onCanvasFocusObservable: Observable<Engine>;
  30018. /**
  30019. * Observable event triggered each time the canvas receives pointerout event
  30020. */
  30021. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30022. /**
  30023. * Observable event triggered before each texture is initialized
  30024. */
  30025. onBeforeTextureInitObservable: Observable<Texture>;
  30026. /**
  30027. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30028. */
  30029. disableUniformBuffers: boolean;
  30030. /** @hidden */
  30031. _uniformBuffers: UniformBuffer[];
  30032. /**
  30033. * Gets a boolean indicating that the engine supports uniform buffers
  30034. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30035. */
  30036. readonly supportsUniformBuffers: boolean;
  30037. /**
  30038. * Observable raised when the engine begins a new frame
  30039. */
  30040. onBeginFrameObservable: Observable<Engine>;
  30041. /**
  30042. * If set, will be used to request the next animation frame for the render loop
  30043. */
  30044. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30045. /**
  30046. * Observable raised when the engine ends the current frame
  30047. */
  30048. onEndFrameObservable: Observable<Engine>;
  30049. /**
  30050. * Observable raised when the engine is about to compile a shader
  30051. */
  30052. onBeforeShaderCompilationObservable: Observable<Engine>;
  30053. /**
  30054. * Observable raised when the engine has jsut compiled a shader
  30055. */
  30056. onAfterShaderCompilationObservable: Observable<Engine>;
  30057. /** @hidden */
  30058. _gl: WebGLRenderingContext;
  30059. private _renderingCanvas;
  30060. private _windowIsBackground;
  30061. private _webGLVersion;
  30062. protected _highPrecisionShadersAllowed: boolean;
  30063. /** @hidden */
  30064. readonly _shouldUseHighPrecisionShader: boolean;
  30065. /**
  30066. * Gets a boolean indicating that only power of 2 textures are supported
  30067. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30068. */
  30069. readonly needPOTTextures: boolean;
  30070. /** @hidden */
  30071. _badOS: boolean;
  30072. /** @hidden */
  30073. _badDesktopOS: boolean;
  30074. /**
  30075. * Gets the audio engine
  30076. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30077. * @ignorenaming
  30078. */
  30079. static audioEngine: IAudioEngine;
  30080. /**
  30081. * Default AudioEngine factory responsible of creating the Audio Engine.
  30082. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30083. */
  30084. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30085. /**
  30086. * Default offline support factory responsible of creating a tool used to store data locally.
  30087. * By default, this will create a Database object if the workload has been embedded.
  30088. */
  30089. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30090. private _onFocus;
  30091. private _onBlur;
  30092. private _onCanvasPointerOut;
  30093. private _onCanvasBlur;
  30094. private _onCanvasFocus;
  30095. private _onFullscreenChange;
  30096. private _onPointerLockChange;
  30097. private _hardwareScalingLevel;
  30098. /** @hidden */
  30099. _caps: EngineCapabilities;
  30100. private _pointerLockRequested;
  30101. private _isStencilEnable;
  30102. private _colorWrite;
  30103. private _loadingScreen;
  30104. /** @hidden */
  30105. _drawCalls: PerfCounter;
  30106. private _glVersion;
  30107. private _glRenderer;
  30108. private _glVendor;
  30109. private _videoTextureSupported;
  30110. private _renderingQueueLaunched;
  30111. private _activeRenderLoops;
  30112. private _deterministicLockstep;
  30113. private _lockstepMaxSteps;
  30114. /**
  30115. * Observable signaled when a context lost event is raised
  30116. */
  30117. onContextLostObservable: Observable<Engine>;
  30118. /**
  30119. * Observable signaled when a context restored event is raised
  30120. */
  30121. onContextRestoredObservable: Observable<Engine>;
  30122. private _onContextLost;
  30123. private _onContextRestored;
  30124. private _contextWasLost;
  30125. /** @hidden */
  30126. _doNotHandleContextLost: boolean;
  30127. /**
  30128. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30129. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30130. */
  30131. doNotHandleContextLost: boolean;
  30132. private _performanceMonitor;
  30133. private _fps;
  30134. private _deltaTime;
  30135. /**
  30136. * Turn this value on if you want to pause FPS computation when in background
  30137. */
  30138. disablePerformanceMonitorInBackground: boolean;
  30139. /**
  30140. * Gets the performance monitor attached to this engine
  30141. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30142. */
  30143. readonly performanceMonitor: PerformanceMonitor;
  30144. /**
  30145. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30146. */
  30147. disableVertexArrayObjects: boolean;
  30148. /** @hidden */
  30149. protected _depthCullingState: _DepthCullingState;
  30150. /** @hidden */
  30151. protected _stencilState: _StencilState;
  30152. /** @hidden */
  30153. protected _alphaState: _AlphaState;
  30154. /** @hidden */
  30155. protected _alphaMode: number;
  30156. /** @hidden */
  30157. _internalTexturesCache: InternalTexture[];
  30158. /** @hidden */
  30159. protected _activeChannel: number;
  30160. private _currentTextureChannel;
  30161. /** @hidden */
  30162. protected _boundTexturesCache: {
  30163. [key: string]: Nullable<InternalTexture>;
  30164. };
  30165. /** @hidden */
  30166. protected _currentEffect: Nullable<Effect>;
  30167. /** @hidden */
  30168. protected _currentProgram: Nullable<WebGLProgram>;
  30169. private _compiledEffects;
  30170. private _vertexAttribArraysEnabled;
  30171. /** @hidden */
  30172. protected _cachedViewport: Nullable<IViewportLike>;
  30173. private _cachedVertexArrayObject;
  30174. /** @hidden */
  30175. protected _cachedVertexBuffers: any;
  30176. /** @hidden */
  30177. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30178. /** @hidden */
  30179. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30180. /** @hidden */
  30181. _currentRenderTarget: Nullable<InternalTexture>;
  30182. private _uintIndicesCurrentlySet;
  30183. private _currentBoundBuffer;
  30184. /** @hidden */
  30185. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30186. private _currentBufferPointers;
  30187. private _currentInstanceLocations;
  30188. private _currentInstanceBuffers;
  30189. private _textureUnits;
  30190. /** @hidden */
  30191. _workingCanvas: Nullable<HTMLCanvasElement>;
  30192. /** @hidden */
  30193. _workingContext: Nullable<CanvasRenderingContext2D>;
  30194. private _rescalePostProcess;
  30195. private _dummyFramebuffer;
  30196. private _externalData;
  30197. /** @hidden */
  30198. _bindedRenderFunction: any;
  30199. private _vaoRecordInProgress;
  30200. private _mustWipeVertexAttributes;
  30201. private _emptyTexture;
  30202. private _emptyCubeTexture;
  30203. private _emptyTexture3D;
  30204. /** @hidden */
  30205. _frameHandler: number;
  30206. private _nextFreeTextureSlots;
  30207. private _maxSimultaneousTextures;
  30208. private _activeRequests;
  30209. private _texturesSupported;
  30210. /** @hidden */
  30211. _textureFormatInUse: Nullable<string>;
  30212. /**
  30213. * Gets the list of texture formats supported
  30214. */
  30215. readonly texturesSupported: Array<string>;
  30216. /**
  30217. * Gets the list of texture formats in use
  30218. */
  30219. readonly textureFormatInUse: Nullable<string>;
  30220. /**
  30221. * Gets the current viewport
  30222. */
  30223. readonly currentViewport: Nullable<IViewportLike>;
  30224. /**
  30225. * Gets the default empty texture
  30226. */
  30227. readonly emptyTexture: InternalTexture;
  30228. /**
  30229. * Gets the default empty 3D texture
  30230. */
  30231. readonly emptyTexture3D: InternalTexture;
  30232. /**
  30233. * Gets the default empty cube texture
  30234. */
  30235. readonly emptyCubeTexture: InternalTexture;
  30236. /**
  30237. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30238. */
  30239. readonly premultipliedAlpha: boolean;
  30240. /**
  30241. * Creates a new engine
  30242. * @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
  30243. * @param antialias defines enable antialiasing (default: false)
  30244. * @param options defines further options to be sent to the getContext() function
  30245. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30246. */
  30247. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30248. /**
  30249. * Initializes a webVR display and starts listening to display change events
  30250. * The onVRDisplayChangedObservable will be notified upon these changes
  30251. * @returns The onVRDisplayChangedObservable
  30252. */
  30253. initWebVR(): Observable<IDisplayChangedEventArgs>;
  30254. /** @hidden */
  30255. _prepareVRComponent(): void;
  30256. /** @hidden */
  30257. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  30258. /** @hidden */
  30259. _submitVRFrame(): void;
  30260. /**
  30261. * Call this function to leave webVR mode
  30262. * Will do nothing if webVR is not supported or if there is no webVR device
  30263. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30264. */
  30265. disableVR(): void;
  30266. /**
  30267. * Gets a boolean indicating that the system is in VR mode and is presenting
  30268. * @returns true if VR mode is engaged
  30269. */
  30270. isVRPresenting(): boolean;
  30271. /** @hidden */
  30272. _requestVRFrame(): void;
  30273. private _disableTouchAction;
  30274. private _rebuildInternalTextures;
  30275. private _rebuildEffects;
  30276. /**
  30277. * Gets a boolean indicating if all created effects are ready
  30278. * @returns true if all effects are ready
  30279. */
  30280. areAllEffectsReady(): boolean;
  30281. private _rebuildBuffers;
  30282. private _initGLContext;
  30283. /**
  30284. * Gets version of the current webGL context
  30285. */
  30286. readonly webGLVersion: number;
  30287. /**
  30288. * Gets a string idenfifying the name of the class
  30289. * @returns "Engine" string
  30290. */
  30291. getClassName(): string;
  30292. /**
  30293. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30294. */
  30295. readonly isStencilEnable: boolean;
  30296. /** @hidden */
  30297. _prepareWorkingCanvas(): void;
  30298. /**
  30299. * Reset the texture cache to empty state
  30300. */
  30301. resetTextureCache(): void;
  30302. /**
  30303. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  30304. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30305. * @returns true if engine is in deterministic lock step mode
  30306. */
  30307. isDeterministicLockStep(): boolean;
  30308. /**
  30309. * Gets the max steps when engine is running in deterministic lock step
  30310. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30311. * @returns the max steps
  30312. */
  30313. getLockstepMaxSteps(): number;
  30314. /**
  30315. * Gets an object containing information about the current webGL context
  30316. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30317. */
  30318. getGlInfo(): {
  30319. vendor: string;
  30320. renderer: string;
  30321. version: string;
  30322. };
  30323. /**
  30324. * Gets current aspect ratio
  30325. * @param viewportOwner defines the camera to use to get the aspect ratio
  30326. * @param useScreen defines if screen size must be used (or the current render target if any)
  30327. * @returns a number defining the aspect ratio
  30328. */
  30329. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  30330. /**
  30331. * Gets current screen aspect ratio
  30332. * @returns a number defining the aspect ratio
  30333. */
  30334. getScreenAspectRatio(): number;
  30335. /**
  30336. * Gets the current render width
  30337. * @param useScreen defines if screen size must be used (or the current render target if any)
  30338. * @returns a number defining the current render width
  30339. */
  30340. getRenderWidth(useScreen?: boolean): number;
  30341. /**
  30342. * Gets the current render height
  30343. * @param useScreen defines if screen size must be used (or the current render target if any)
  30344. * @returns a number defining the current render height
  30345. */
  30346. getRenderHeight(useScreen?: boolean): number;
  30347. /**
  30348. * Gets the HTML canvas attached with the current webGL context
  30349. * @returns a HTML canvas
  30350. */
  30351. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30352. /**
  30353. * Gets host window
  30354. * @returns the host window object
  30355. */
  30356. getHostWindow(): Window;
  30357. /**
  30358. * Gets host document
  30359. * @returns the host document object
  30360. */
  30361. getHostDocument(): Document;
  30362. /**
  30363. * Gets the client rect of the HTML canvas attached with the current webGL context
  30364. * @returns a client rectanglee
  30365. */
  30366. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  30367. /**
  30368. * Defines the hardware scaling level.
  30369. * By default the hardware scaling level is computed from the window device ratio.
  30370. * 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.
  30371. * @param level defines the level to use
  30372. */
  30373. setHardwareScalingLevel(level: number): void;
  30374. /**
  30375. * Gets the current hardware scaling level.
  30376. * By default the hardware scaling level is computed from the window device ratio.
  30377. * 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.
  30378. * @returns a number indicating the current hardware scaling level
  30379. */
  30380. getHardwareScalingLevel(): number;
  30381. /**
  30382. * Gets the list of loaded textures
  30383. * @returns an array containing all loaded textures
  30384. */
  30385. getLoadedTexturesCache(): InternalTexture[];
  30386. /**
  30387. * Gets the object containing all engine capabilities
  30388. * @returns the EngineCapabilities object
  30389. */
  30390. getCaps(): EngineCapabilities;
  30391. /**
  30392. * Gets the current depth function
  30393. * @returns a number defining the depth function
  30394. */
  30395. getDepthFunction(): Nullable<number>;
  30396. /**
  30397. * Sets the current depth function
  30398. * @param depthFunc defines the function to use
  30399. */
  30400. setDepthFunction(depthFunc: number): void;
  30401. /**
  30402. * Sets the current depth function to GREATER
  30403. */
  30404. setDepthFunctionToGreater(): void;
  30405. /**
  30406. * Sets the current depth function to GEQUAL
  30407. */
  30408. setDepthFunctionToGreaterOrEqual(): void;
  30409. /**
  30410. * Sets the current depth function to LESS
  30411. */
  30412. setDepthFunctionToLess(): void;
  30413. private _cachedStencilBuffer;
  30414. private _cachedStencilFunction;
  30415. private _cachedStencilMask;
  30416. private _cachedStencilOperationPass;
  30417. private _cachedStencilOperationFail;
  30418. private _cachedStencilOperationDepthFail;
  30419. private _cachedStencilReference;
  30420. /**
  30421. * Caches the the state of the stencil buffer
  30422. */
  30423. cacheStencilState(): void;
  30424. /**
  30425. * Restores the state of the stencil buffer
  30426. */
  30427. restoreStencilState(): void;
  30428. /**
  30429. * Sets the current depth function to LEQUAL
  30430. */
  30431. setDepthFunctionToLessOrEqual(): void;
  30432. /**
  30433. * Gets a boolean indicating if stencil buffer is enabled
  30434. * @returns the current stencil buffer state
  30435. */
  30436. getStencilBuffer(): boolean;
  30437. /**
  30438. * Enable or disable the stencil buffer
  30439. * @param enable defines if the stencil buffer must be enabled or disabled
  30440. */
  30441. setStencilBuffer(enable: boolean): void;
  30442. /**
  30443. * Gets the current stencil mask
  30444. * @returns a number defining the new stencil mask to use
  30445. */
  30446. getStencilMask(): number;
  30447. /**
  30448. * Sets the current stencil mask
  30449. * @param mask defines the new stencil mask to use
  30450. */
  30451. setStencilMask(mask: number): void;
  30452. /**
  30453. * Gets the current stencil function
  30454. * @returns a number defining the stencil function to use
  30455. */
  30456. getStencilFunction(): number;
  30457. /**
  30458. * Gets the current stencil reference value
  30459. * @returns a number defining the stencil reference value to use
  30460. */
  30461. getStencilFunctionReference(): number;
  30462. /**
  30463. * Gets the current stencil mask
  30464. * @returns a number defining the stencil mask to use
  30465. */
  30466. getStencilFunctionMask(): number;
  30467. /**
  30468. * Sets the current stencil function
  30469. * @param stencilFunc defines the new stencil function to use
  30470. */
  30471. setStencilFunction(stencilFunc: number): void;
  30472. /**
  30473. * Sets the current stencil reference
  30474. * @param reference defines the new stencil reference to use
  30475. */
  30476. setStencilFunctionReference(reference: number): void;
  30477. /**
  30478. * Sets the current stencil mask
  30479. * @param mask defines the new stencil mask to use
  30480. */
  30481. setStencilFunctionMask(mask: number): void;
  30482. /**
  30483. * Gets the current stencil operation when stencil fails
  30484. * @returns a number defining stencil operation to use when stencil fails
  30485. */
  30486. getStencilOperationFail(): number;
  30487. /**
  30488. * Gets the current stencil operation when depth fails
  30489. * @returns a number defining stencil operation to use when depth fails
  30490. */
  30491. getStencilOperationDepthFail(): number;
  30492. /**
  30493. * Gets the current stencil operation when stencil passes
  30494. * @returns a number defining stencil operation to use when stencil passes
  30495. */
  30496. getStencilOperationPass(): number;
  30497. /**
  30498. * Sets the stencil operation to use when stencil fails
  30499. * @param operation defines the stencil operation to use when stencil fails
  30500. */
  30501. setStencilOperationFail(operation: number): void;
  30502. /**
  30503. * Sets the stencil operation to use when depth fails
  30504. * @param operation defines the stencil operation to use when depth fails
  30505. */
  30506. setStencilOperationDepthFail(operation: number): void;
  30507. /**
  30508. * Sets the stencil operation to use when stencil passes
  30509. * @param operation defines the stencil operation to use when stencil passes
  30510. */
  30511. setStencilOperationPass(operation: number): void;
  30512. /**
  30513. * Sets a boolean indicating if the dithering state is enabled or disabled
  30514. * @param value defines the dithering state
  30515. */
  30516. setDitheringState(value: boolean): void;
  30517. /**
  30518. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  30519. * @param value defines the rasterizer state
  30520. */
  30521. setRasterizerState(value: boolean): void;
  30522. /**
  30523. * stop executing a render loop function and remove it from the execution array
  30524. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30525. */
  30526. stopRenderLoop(renderFunction?: () => void): void;
  30527. /** @hidden */
  30528. _renderLoop(): void;
  30529. /**
  30530. * Register and execute a render loop. The engine can have more than one render function
  30531. * @param renderFunction defines the function to continuously execute
  30532. */
  30533. runRenderLoop(renderFunction: () => void): void;
  30534. /**
  30535. * Toggle full screen mode
  30536. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30537. */
  30538. switchFullscreen(requestPointerLock: boolean): void;
  30539. /**
  30540. * Enters full screen mode
  30541. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30542. */
  30543. enterFullscreen(requestPointerLock: boolean): void;
  30544. /**
  30545. * Exits full screen mode
  30546. */
  30547. exitFullscreen(): void;
  30548. /**
  30549. * Enters Pointerlock mode
  30550. */
  30551. enterPointerlock(): void;
  30552. /**
  30553. * Exits Pointerlock mode
  30554. */
  30555. exitPointerlock(): void;
  30556. /**
  30557. * Clear the current render buffer or the current render target (if any is set up)
  30558. * @param color defines the color to use
  30559. * @param backBuffer defines if the back buffer must be cleared
  30560. * @param depth defines if the depth buffer must be cleared
  30561. * @param stencil defines if the stencil buffer must be cleared
  30562. */
  30563. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30564. /**
  30565. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  30566. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30567. * @param y defines the y-coordinate of the corner of the clear rectangle
  30568. * @param width defines the width of the clear rectangle
  30569. * @param height defines the height of the clear rectangle
  30570. * @param clearColor defines the clear color
  30571. */
  30572. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  30573. /**
  30574. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  30575. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30576. * @param y defines the y-coordinate of the corner of the clear rectangle
  30577. * @param width defines the width of the clear rectangle
  30578. * @param height defines the height of the clear rectangle
  30579. */
  30580. enableScissor(x: number, y: number, width: number, height: number): void;
  30581. /**
  30582. * Disable previously set scissor test rectangle
  30583. */
  30584. disableScissor(): void;
  30585. private _viewportCached;
  30586. /** @hidden */
  30587. _viewport(x: number, y: number, width: number, height: number): void;
  30588. /**
  30589. * Set the WebGL's viewport
  30590. * @param viewport defines the viewport element to be used
  30591. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30592. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30593. */
  30594. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30595. /**
  30596. * Directly set the WebGL Viewport
  30597. * @param x defines the x coordinate of the viewport (in screen space)
  30598. * @param y defines the y coordinate of the viewport (in screen space)
  30599. * @param width defines the width of the viewport (in screen space)
  30600. * @param height defines the height of the viewport (in screen space)
  30601. * @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
  30602. */
  30603. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  30604. /**
  30605. * Begin a new frame
  30606. */
  30607. beginFrame(): void;
  30608. /**
  30609. * Enf the current frame
  30610. */
  30611. endFrame(): void;
  30612. /**
  30613. * Resize the view according to the canvas' size
  30614. */
  30615. resize(): void;
  30616. /**
  30617. * Force a specific size of the canvas
  30618. * @param width defines the new canvas' width
  30619. * @param height defines the new canvas' height
  30620. */
  30621. setSize(width: number, height: number): void;
  30622. /**
  30623. * Binds the frame buffer to the specified texture.
  30624. * @param texture The texture to render to or null for the default canvas
  30625. * @param faceIndex The face of the texture to render to in case of cube texture
  30626. * @param requiredWidth The width of the target to render to
  30627. * @param requiredHeight The height of the target to render to
  30628. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30629. * @param depthStencilTexture The depth stencil texture to use to render
  30630. * @param lodLevel defines le lod level to bind to the frame buffer
  30631. */
  30632. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30633. /** @hidden */
  30634. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30635. /**
  30636. * Unbind the current render target texture from the webGL context
  30637. * @param texture defines the render target texture to unbind
  30638. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30639. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30640. */
  30641. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30642. /**
  30643. * Force the mipmap generation for the given render target texture
  30644. * @param texture defines the render target texture to use
  30645. */
  30646. generateMipMapsForCubemap(texture: InternalTexture): void;
  30647. /**
  30648. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30649. */
  30650. flushFramebuffer(): void;
  30651. /**
  30652. * Unbind the current render target and bind the default framebuffer
  30653. */
  30654. restoreDefaultFramebuffer(): void;
  30655. /**
  30656. * Create an uniform buffer
  30657. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30658. * @param elements defines the content of the uniform buffer
  30659. * @returns the webGL uniform buffer
  30660. */
  30661. createUniformBuffer(elements: FloatArray): DataBuffer;
  30662. /**
  30663. * Create a dynamic uniform buffer
  30664. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30665. * @param elements defines the content of the uniform buffer
  30666. * @returns the webGL uniform buffer
  30667. */
  30668. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  30669. /**
  30670. * Update an existing uniform buffer
  30671. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30672. * @param uniformBuffer defines the target uniform buffer
  30673. * @param elements defines the content to update
  30674. * @param offset defines the offset in the uniform buffer where update should start
  30675. * @param count defines the size of the data to update
  30676. */
  30677. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  30678. private _resetVertexBufferBinding;
  30679. /**
  30680. * Creates a vertex buffer
  30681. * @param data the data for the vertex buffer
  30682. * @returns the new WebGL static buffer
  30683. */
  30684. createVertexBuffer(data: DataArray): DataBuffer;
  30685. /**
  30686. * Creates a dynamic vertex buffer
  30687. * @param data the data for the dynamic vertex buffer
  30688. * @returns the new WebGL dynamic buffer
  30689. */
  30690. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30691. /**
  30692. * Update a dynamic index buffer
  30693. * @param indexBuffer defines the target index buffer
  30694. * @param indices defines the data to update
  30695. * @param offset defines the offset in the target index buffer where update should start
  30696. */
  30697. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  30698. /**
  30699. * Updates a dynamic vertex buffer.
  30700. * @param vertexBuffer the vertex buffer to update
  30701. * @param data the data used to update the vertex buffer
  30702. * @param byteOffset the byte offset of the data
  30703. * @param byteLength the byte length of the data
  30704. */
  30705. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30706. private _resetIndexBufferBinding;
  30707. /**
  30708. * Creates a new index buffer
  30709. * @param indices defines the content of the index buffer
  30710. * @param updatable defines if the index buffer must be updatable
  30711. * @returns a new webGL buffer
  30712. */
  30713. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30714. /**
  30715. * Bind a webGL buffer to the webGL context
  30716. * @param buffer defines the buffer to bind
  30717. */
  30718. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30719. /**
  30720. * Bind an uniform buffer to the current webGL context
  30721. * @param buffer defines the buffer to bind
  30722. */
  30723. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  30724. /**
  30725. * Bind a buffer to the current webGL context at a given location
  30726. * @param buffer defines the buffer to bind
  30727. * @param location defines the index where to bind the buffer
  30728. */
  30729. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  30730. /**
  30731. * Bind a specific block at a given index in a specific shader program
  30732. * @param pipelineContext defines the pipeline context to use
  30733. * @param blockName defines the block name
  30734. * @param index defines the index where to bind the block
  30735. */
  30736. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  30737. private bindIndexBuffer;
  30738. private bindBuffer;
  30739. /**
  30740. * update the bound buffer with the given data
  30741. * @param data defines the data to update
  30742. */
  30743. updateArrayBuffer(data: Float32Array): void;
  30744. private _vertexAttribPointer;
  30745. private _bindIndexBufferWithCache;
  30746. private _bindVertexBuffersAttributes;
  30747. /**
  30748. * Records a vertex array object
  30749. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30750. * @param vertexBuffers defines the list of vertex buffers to store
  30751. * @param indexBuffer defines the index buffer to store
  30752. * @param effect defines the effect to store
  30753. * @returns the new vertex array object
  30754. */
  30755. recordVertexArrayObject(vertexBuffers: {
  30756. [key: string]: VertexBuffer;
  30757. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30758. /**
  30759. * Bind a specific vertex array object
  30760. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30761. * @param vertexArrayObject defines the vertex array object to bind
  30762. * @param indexBuffer defines the index buffer to bind
  30763. */
  30764. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30765. /**
  30766. * Bind webGl buffers directly to the webGL context
  30767. * @param vertexBuffer defines the vertex buffer to bind
  30768. * @param indexBuffer defines the index buffer to bind
  30769. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30770. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30771. * @param effect defines the effect associated with the vertex buffer
  30772. */
  30773. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30774. private _unbindVertexArrayObject;
  30775. /**
  30776. * Bind a list of vertex buffers to the webGL context
  30777. * @param vertexBuffers defines the list of vertex buffers to bind
  30778. * @param indexBuffer defines the index buffer to bind
  30779. * @param effect defines the effect associated with the vertex buffers
  30780. */
  30781. bindBuffers(vertexBuffers: {
  30782. [key: string]: Nullable<VertexBuffer>;
  30783. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30784. /**
  30785. * Unbind all instance attributes
  30786. */
  30787. unbindInstanceAttributes(): void;
  30788. /**
  30789. * Release and free the memory of a vertex array object
  30790. * @param vao defines the vertex array object to delete
  30791. */
  30792. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30793. /** @hidden */
  30794. _releaseBuffer(buffer: DataBuffer): boolean;
  30795. /**
  30796. * Creates a webGL buffer to use with instanciation
  30797. * @param capacity defines the size of the buffer
  30798. * @returns the webGL buffer
  30799. */
  30800. createInstancesBuffer(capacity: number): DataBuffer;
  30801. /**
  30802. * Delete a webGL buffer used with instanciation
  30803. * @param buffer defines the webGL buffer to delete
  30804. */
  30805. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30806. /**
  30807. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30808. * @param instancesBuffer defines the webGL buffer to update and bind
  30809. * @param data defines the data to store in the buffer
  30810. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30811. */
  30812. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30813. /**
  30814. * Apply all cached states (depth, culling, stencil and alpha)
  30815. */
  30816. applyStates(): void;
  30817. /**
  30818. * Send a draw order
  30819. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30820. * @param indexStart defines the starting index
  30821. * @param indexCount defines the number of index to draw
  30822. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30823. */
  30824. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30825. /**
  30826. * Draw a list of points
  30827. * @param verticesStart defines the index of first vertex to draw
  30828. * @param verticesCount defines the count of vertices to draw
  30829. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30830. */
  30831. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30832. /**
  30833. * Draw a list of unindexed primitives
  30834. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30835. * @param verticesStart defines the index of first vertex to draw
  30836. * @param verticesCount defines the count of vertices to draw
  30837. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30838. */
  30839. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30840. /**
  30841. * Draw a list of indexed primitives
  30842. * @param fillMode defines the primitive to use
  30843. * @param indexStart defines the starting index
  30844. * @param indexCount defines the number of index to draw
  30845. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30846. */
  30847. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30848. /**
  30849. * Draw a list of unindexed primitives
  30850. * @param fillMode defines the primitive to use
  30851. * @param verticesStart defines the index of first vertex to draw
  30852. * @param verticesCount defines the count of vertices to draw
  30853. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30854. */
  30855. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30856. private _drawMode;
  30857. /** @hidden */
  30858. _releaseEffect(effect: Effect): void;
  30859. /** @hidden */
  30860. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30861. /**
  30862. * Create a new effect (used to store vertex/fragment shaders)
  30863. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30864. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30865. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30866. * @param samplers defines an array of string used to represent textures
  30867. * @param defines defines the string containing the defines to use to compile the shaders
  30868. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30869. * @param onCompiled defines a function to call when the effect creation is successful
  30870. * @param onError defines a function to call when the effect creation has failed
  30871. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30872. * @returns the new Effect
  30873. */
  30874. 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;
  30875. private _compileShader;
  30876. private _compileRawShader;
  30877. /**
  30878. * Directly creates a webGL program
  30879. * @param pipelineContext defines the pipeline context to attach to
  30880. * @param vertexCode defines the vertex shader code to use
  30881. * @param fragmentCode defines the fragment shader code to use
  30882. * @param context defines the webGL context to use (if not set, the current one will be used)
  30883. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30884. * @returns the new webGL program
  30885. */
  30886. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30887. /**
  30888. * Creates a webGL program
  30889. * @param pipelineContext defines the pipeline context to attach to
  30890. * @param vertexCode defines the vertex shader code to use
  30891. * @param fragmentCode defines the fragment shader code to use
  30892. * @param defines defines the string containing the defines to use to compile the shaders
  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. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30898. /**
  30899. * Creates a new pipeline context
  30900. * @returns the new pipeline
  30901. */
  30902. createPipelineContext(): WebGLPipelineContext;
  30903. private _createShaderProgram;
  30904. private _finalizePipelineContext;
  30905. /** @hidden */
  30906. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30907. /** @hidden */
  30908. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30909. /** @hidden */
  30910. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30911. /**
  30912. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30913. * @param pipelineContext defines the pipeline context to use
  30914. * @param uniformsNames defines the list of uniform names
  30915. * @returns an array of webGL uniform locations
  30916. */
  30917. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30918. /**
  30919. * Gets the lsit of active attributes for a given webGL program
  30920. * @param pipelineContext defines the pipeline context to use
  30921. * @param attributesNames defines the list of attribute names to get
  30922. * @returns an array of indices indicating the offset of each attribute
  30923. */
  30924. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30925. /**
  30926. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30927. * @param effect defines the effect to activate
  30928. */
  30929. enableEffect(effect: Nullable<Effect>): void;
  30930. /**
  30931. * Set the value of an uniform to an array of int32
  30932. * @param uniform defines the webGL uniform location where to store the value
  30933. * @param array defines the array of int32 to store
  30934. */
  30935. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30936. /**
  30937. * Set the value of an uniform to an array of int32 (stored as vec2)
  30938. * @param uniform defines the webGL uniform location where to store the value
  30939. * @param array defines the array of int32 to store
  30940. */
  30941. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30942. /**
  30943. * Set the value of an uniform to an array of int32 (stored as vec3)
  30944. * @param uniform defines the webGL uniform location where to store the value
  30945. * @param array defines the array of int32 to store
  30946. */
  30947. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30948. /**
  30949. * Set the value of an uniform to an array of int32 (stored as vec4)
  30950. * @param uniform defines the webGL uniform location where to store the value
  30951. * @param array defines the array of int32 to store
  30952. */
  30953. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30954. /**
  30955. * Set the value of an uniform to an array of float32
  30956. * @param uniform defines the webGL uniform location where to store the value
  30957. * @param array defines the array of float32 to store
  30958. */
  30959. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30960. /**
  30961. * Set the value of an uniform to an array of float32 (stored as vec2)
  30962. * @param uniform defines the webGL uniform location where to store the value
  30963. * @param array defines the array of float32 to store
  30964. */
  30965. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30966. /**
  30967. * Set the value of an uniform to an array of float32 (stored as vec3)
  30968. * @param uniform defines the webGL uniform location where to store the value
  30969. * @param array defines the array of float32 to store
  30970. */
  30971. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30972. /**
  30973. * Set the value of an uniform to an array of float32 (stored as vec4)
  30974. * @param uniform defines the webGL uniform location where to store the value
  30975. * @param array defines the array of float32 to store
  30976. */
  30977. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30978. /**
  30979. * Set the value of an uniform to an array of number
  30980. * @param uniform defines the webGL uniform location where to store the value
  30981. * @param array defines the array of number to store
  30982. */
  30983. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30984. /**
  30985. * Set the value of an uniform to an array of number (stored as vec2)
  30986. * @param uniform defines the webGL uniform location where to store the value
  30987. * @param array defines the array of number to store
  30988. */
  30989. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30990. /**
  30991. * Set the value of an uniform to an array of number (stored as vec3)
  30992. * @param uniform defines the webGL uniform location where to store the value
  30993. * @param array defines the array of number to store
  30994. */
  30995. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30996. /**
  30997. * Set the value of an uniform to an array of number (stored as vec4)
  30998. * @param uniform defines the webGL uniform location where to store the value
  30999. * @param array defines the array of number to store
  31000. */
  31001. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31002. /**
  31003. * Set the value of an uniform to an array of float32 (stored as matrices)
  31004. * @param uniform defines the webGL uniform location where to store the value
  31005. * @param matrices defines the array of float32 to store
  31006. */
  31007. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31008. /**
  31009. * Set the value of an uniform to a matrix (3x3)
  31010. * @param uniform defines the webGL uniform location where to store the value
  31011. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31012. */
  31013. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31014. /**
  31015. * Set the value of an uniform to a matrix (2x2)
  31016. * @param uniform defines the webGL uniform location where to store the value
  31017. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31018. */
  31019. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31020. /**
  31021. * Set the value of an uniform to a number (int)
  31022. * @param uniform defines the webGL uniform location where to store the value
  31023. * @param value defines the int number to store
  31024. */
  31025. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31026. /**
  31027. * Set the value of an uniform to a number (float)
  31028. * @param uniform defines the webGL uniform location where to store the value
  31029. * @param value defines the float number to store
  31030. */
  31031. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31032. /**
  31033. * Set the value of an uniform to a vec2
  31034. * @param uniform defines the webGL uniform location where to store the value
  31035. * @param x defines the 1st component of the value
  31036. * @param y defines the 2nd component of the value
  31037. */
  31038. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31039. /**
  31040. * Set the value of an uniform to a vec3
  31041. * @param uniform defines the webGL uniform location where to store the value
  31042. * @param x defines the 1st component of the value
  31043. * @param y defines the 2nd component of the value
  31044. * @param z defines the 3rd component of the value
  31045. */
  31046. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31047. /**
  31048. * Set the value of an uniform to a boolean
  31049. * @param uniform defines the webGL uniform location where to store the value
  31050. * @param bool defines the boolean to store
  31051. */
  31052. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31053. /**
  31054. * Set the value of an uniform to a vec4
  31055. * @param uniform defines the webGL uniform location where to store the value
  31056. * @param x defines the 1st component of the value
  31057. * @param y defines the 2nd component of the value
  31058. * @param z defines the 3rd component of the value
  31059. * @param w defines the 4th component of the value
  31060. */
  31061. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31062. /**
  31063. * Sets a Color4 on a uniform variable
  31064. * @param uniform defines the uniform location
  31065. * @param color4 defines the value to be set
  31066. */
  31067. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31068. /**
  31069. * Set various states to the webGL context
  31070. * @param culling defines backface culling state
  31071. * @param zOffset defines the value to apply to zOffset (0 by default)
  31072. * @param force defines if states must be applied even if cache is up to date
  31073. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31074. */
  31075. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31076. /**
  31077. * Set the z offset to apply to current rendering
  31078. * @param value defines the offset to apply
  31079. */
  31080. setZOffset(value: number): void;
  31081. /**
  31082. * Gets the current value of the zOffset
  31083. * @returns the current zOffset state
  31084. */
  31085. getZOffset(): number;
  31086. /**
  31087. * Enable or disable depth buffering
  31088. * @param enable defines the state to set
  31089. */
  31090. setDepthBuffer(enable: boolean): void;
  31091. /**
  31092. * Gets a boolean indicating if depth writing is enabled
  31093. * @returns the current depth writing state
  31094. */
  31095. getDepthWrite(): boolean;
  31096. /**
  31097. * Enable or disable depth writing
  31098. * @param enable defines the state to set
  31099. */
  31100. setDepthWrite(enable: boolean): void;
  31101. /**
  31102. * Enable or disable color writing
  31103. * @param enable defines the state to set
  31104. */
  31105. setColorWrite(enable: boolean): void;
  31106. /**
  31107. * Gets a boolean indicating if color writing is enabled
  31108. * @returns the current color writing state
  31109. */
  31110. getColorWrite(): boolean;
  31111. /**
  31112. * Sets alpha constants used by some alpha blending modes
  31113. * @param r defines the red component
  31114. * @param g defines the green component
  31115. * @param b defines the blue component
  31116. * @param a defines the alpha component
  31117. */
  31118. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31119. /**
  31120. * Sets the current alpha mode
  31121. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31122. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31123. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31124. */
  31125. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31126. /**
  31127. * Gets the current alpha mode
  31128. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31129. * @returns the current alpha mode
  31130. */
  31131. getAlphaMode(): number;
  31132. /**
  31133. * Clears the list of texture accessible through engine.
  31134. * This can help preventing texture load conflict due to name collision.
  31135. */
  31136. clearInternalTexturesCache(): void;
  31137. /**
  31138. * Force the entire cache to be cleared
  31139. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31140. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31141. */
  31142. wipeCaches(bruteForce?: boolean): void;
  31143. /**
  31144. * Set the compressed texture format to use, based on the formats you have, and the formats
  31145. * supported by the hardware / browser.
  31146. *
  31147. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31148. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31149. * to API arguments needed to compressed textures. This puts the burden on the container
  31150. * generator to house the arcane code for determining these for current & future formats.
  31151. *
  31152. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31153. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31154. *
  31155. * Note: The result of this call is not taken into account when a texture is base64.
  31156. *
  31157. * @param formatsAvailable defines the list of those format families you have created
  31158. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31159. *
  31160. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31161. * @returns The extension selected.
  31162. */
  31163. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31164. /** @hidden */
  31165. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31166. min: number;
  31167. mag: number;
  31168. };
  31169. /** @hidden */
  31170. _createTexture(): WebGLTexture;
  31171. /**
  31172. * Usually called from Texture.ts.
  31173. * Passed information to create a WebGLTexture
  31174. * @param urlArg defines a value which contains one of the following:
  31175. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31176. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31177. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31178. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31179. * @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)
  31180. * @param scene needed for loading to the correct scene
  31181. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31182. * @param onLoad optional callback to be called upon successful completion
  31183. * @param onError optional callback to be called upon failure
  31184. * @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
  31185. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31186. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31187. * @param forcedExtension defines the extension to use to pick the right loader
  31188. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31189. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31190. */
  31191. 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;
  31192. /**
  31193. * @hidden
  31194. * Rescales a texture
  31195. * @param source input texutre
  31196. * @param destination destination texture
  31197. * @param scene scene to use to render the resize
  31198. * @param internalFormat format to use when resizing
  31199. * @param onComplete callback to be called when resize has completed
  31200. */
  31201. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  31202. private _unpackFlipYCached;
  31203. /**
  31204. * In case you are sharing the context with other applications, it might
  31205. * be interested to not cache the unpack flip y state to ensure a consistent
  31206. * value would be set.
  31207. */
  31208. enableUnpackFlipYCached: boolean;
  31209. /** @hidden */
  31210. _unpackFlipY(value: boolean): void;
  31211. /** @hidden */
  31212. _getUnpackAlignement(): number;
  31213. /**
  31214. * Creates a dynamic texture
  31215. * @param width defines the width of the texture
  31216. * @param height defines the height of the texture
  31217. * @param generateMipMaps defines if the engine should generate the mip levels
  31218. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31219. * @returns the dynamic texture inside an InternalTexture
  31220. */
  31221. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  31222. /**
  31223. * Update the sampling mode of a given texture
  31224. * @param samplingMode defines the required sampling mode
  31225. * @param texture defines the texture to update
  31226. */
  31227. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  31228. /**
  31229. * Update the content of a dynamic texture
  31230. * @param texture defines the texture to update
  31231. * @param canvas defines the canvas containing the source
  31232. * @param invertY defines if data must be stored with Y axis inverted
  31233. * @param premulAlpha defines if alpha is stored as premultiplied
  31234. * @param format defines the format of the data
  31235. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  31236. */
  31237. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  31238. /**
  31239. * Update a video texture
  31240. * @param texture defines the texture to update
  31241. * @param video defines the video element to use
  31242. * @param invertY defines if data must be stored with Y axis inverted
  31243. */
  31244. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31245. /**
  31246. * Updates a depth texture Comparison Mode and Function.
  31247. * If the comparison Function is equal to 0, the mode will be set to none.
  31248. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31249. * @param texture The texture to set the comparison function for
  31250. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31251. */
  31252. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  31253. /** @hidden */
  31254. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31255. width: number;
  31256. height: number;
  31257. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31258. /**
  31259. * Creates a depth stencil texture.
  31260. * This is only available in WebGL 2 or with the depth texture extension available.
  31261. * @param size The size of face edge in the texture.
  31262. * @param options The options defining the texture.
  31263. * @returns The texture
  31264. */
  31265. createDepthStencilTexture(size: number | {
  31266. width: number;
  31267. height: number;
  31268. }, options: DepthTextureCreationOptions): InternalTexture;
  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. private _createDepthStencilTexture;
  31277. /**
  31278. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31279. * @param renderTarget The render target to set the frame buffer for
  31280. */
  31281. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31282. /**
  31283. * Creates a new render target texture
  31284. * @param size defines the size of the texture
  31285. * @param options defines the options used to create the texture
  31286. * @returns a new render target texture stored in an InternalTexture
  31287. */
  31288. createRenderTargetTexture(size: number | {
  31289. width: number;
  31290. height: number;
  31291. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  31292. /** @hidden */
  31293. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31294. /**
  31295. * Updates the sample count of a render target texture
  31296. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31297. * @param texture defines the texture to update
  31298. * @param samples defines the sample count to set
  31299. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31300. */
  31301. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31302. /** @hidden */
  31303. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31304. /** @hidden */
  31305. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31306. /** @hidden */
  31307. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31308. /** @hidden */
  31309. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  31310. /**
  31311. * @hidden
  31312. */
  31313. _setCubeMapTextureParams(loadMipmap: boolean): void;
  31314. private _prepareWebGLTextureContinuation;
  31315. private _prepareWebGLTexture;
  31316. /** @hidden */
  31317. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31318. /** @hidden */
  31319. _releaseFramebufferObjects(texture: InternalTexture): void;
  31320. /** @hidden */
  31321. _releaseTexture(texture: InternalTexture): void;
  31322. private setProgram;
  31323. private _boundUniforms;
  31324. /**
  31325. * Binds an effect to the webGL context
  31326. * @param effect defines the effect to bind
  31327. */
  31328. bindSamplers(effect: Effect): void;
  31329. private _activateCurrentTexture;
  31330. /** @hidden */
  31331. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31332. /** @hidden */
  31333. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31334. /**
  31335. * Sets a texture to the webGL context from a postprocess
  31336. * @param channel defines the channel to use
  31337. * @param postProcess defines the source postprocess
  31338. */
  31339. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31340. /**
  31341. * Binds the output of the passed in post process to the texture channel specified
  31342. * @param channel The channel the texture should be bound to
  31343. * @param postProcess The post process which's output should be bound
  31344. */
  31345. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31346. /**
  31347. * Unbind all textures from the webGL context
  31348. */
  31349. unbindAllTextures(): void;
  31350. /**
  31351. * Sets a texture to the according uniform.
  31352. * @param channel The texture channel
  31353. * @param uniform The uniform to set
  31354. * @param texture The texture to apply
  31355. */
  31356. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31357. /**
  31358. * Sets a depth stencil texture from a render target to the according uniform.
  31359. * @param channel The texture channel
  31360. * @param uniform The uniform to set
  31361. * @param texture The render target texture containing the depth stencil texture to apply
  31362. */
  31363. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31364. private _bindSamplerUniformToChannel;
  31365. private _getTextureWrapMode;
  31366. private _setTexture;
  31367. /**
  31368. * Sets an array of texture to the webGL context
  31369. * @param channel defines the channel where the texture array must be set
  31370. * @param uniform defines the associated uniform location
  31371. * @param textures defines the array of textures to bind
  31372. */
  31373. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31374. /** @hidden */
  31375. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31376. private _setTextureParameterFloat;
  31377. private _setTextureParameterInteger;
  31378. /**
  31379. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31380. * @param x defines the x coordinate of the rectangle where pixels must be read
  31381. * @param y defines the y coordinate of the rectangle where pixels must be read
  31382. * @param width defines the width of the rectangle where pixels must be read
  31383. * @param height defines the height of the rectangle where pixels must be read
  31384. * @returns a Uint8Array containing RGBA colors
  31385. */
  31386. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31387. /**
  31388. * Add an externaly attached data from its key.
  31389. * This method call will fail and return false, if such key already exists.
  31390. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  31391. * @param key the unique key that identifies the data
  31392. * @param data the data object to associate to the key for this Engine instance
  31393. * @return true if no such key were already present and the data was added successfully, false otherwise
  31394. */
  31395. addExternalData<T>(key: string, data: T): boolean;
  31396. /**
  31397. * Get an externaly attached data from its key
  31398. * @param key the unique key that identifies the data
  31399. * @return the associated data, if present (can be null), or undefined if not present
  31400. */
  31401. getExternalData<T>(key: string): T;
  31402. /**
  31403. * Get an externaly attached data from its key, create it using a factory if it's not already present
  31404. * @param key the unique key that identifies the data
  31405. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  31406. * @return the associated data, can be null if the factory returned null.
  31407. */
  31408. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  31409. /**
  31410. * Remove an externaly attached data from the Engine instance
  31411. * @param key the unique key that identifies the data
  31412. * @return true if the data was successfully removed, false if it doesn't exist
  31413. */
  31414. removeExternalData(key: string): boolean;
  31415. /**
  31416. * Unbind all vertex attributes from the webGL context
  31417. */
  31418. unbindAllAttributes(): void;
  31419. /**
  31420. * 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
  31421. */
  31422. releaseEffects(): void;
  31423. /**
  31424. * Dispose and release all associated resources
  31425. */
  31426. dispose(): void;
  31427. /**
  31428. * Display the loading screen
  31429. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31430. */
  31431. displayLoadingUI(): void;
  31432. /**
  31433. * Hide the loading screen
  31434. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31435. */
  31436. hideLoadingUI(): void;
  31437. /**
  31438. * Gets the current loading screen object
  31439. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31440. */
  31441. /**
  31442. * Sets the current loading screen object
  31443. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31444. */
  31445. loadingScreen: ILoadingScreen;
  31446. /**
  31447. * Sets the current loading screen text
  31448. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31449. */
  31450. loadingUIText: string;
  31451. /**
  31452. * Sets the current loading screen background color
  31453. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31454. */
  31455. loadingUIBackgroundColor: string;
  31456. /**
  31457. * Attach a new callback raised when context lost event is fired
  31458. * @param callback defines the callback to call
  31459. */
  31460. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31461. /**
  31462. * Attach a new callback raised when context restored event is fired
  31463. * @param callback defines the callback to call
  31464. */
  31465. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31466. /**
  31467. * Gets the source code of the vertex shader associated with a specific webGL program
  31468. * @param program defines the program to use
  31469. * @returns a string containing the source code of the vertex shader associated with the program
  31470. */
  31471. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31472. /**
  31473. * Gets the source code of the fragment shader associated with a specific webGL program
  31474. * @param program defines the program to use
  31475. * @returns a string containing the source code of the fragment shader associated with the program
  31476. */
  31477. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31478. /**
  31479. * Get the current error code of the webGL context
  31480. * @returns the error code
  31481. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31482. */
  31483. getError(): number;
  31484. /**
  31485. * Gets the current framerate
  31486. * @returns a number representing the framerate
  31487. */
  31488. getFps(): number;
  31489. /**
  31490. * Gets the time spent between current and previous frame
  31491. * @returns a number representing the delta time in ms
  31492. */
  31493. getDeltaTime(): number;
  31494. private _measureFps;
  31495. /** @hidden */
  31496. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31497. private _canRenderToFloatFramebuffer;
  31498. private _canRenderToHalfFloatFramebuffer;
  31499. private _canRenderToFramebuffer;
  31500. /** @hidden */
  31501. _getWebGLTextureType(type: number): number;
  31502. /** @hidden */
  31503. _getInternalFormat(format: number): number;
  31504. /** @hidden */
  31505. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31506. /** @hidden */
  31507. _getRGBAMultiSampleBufferFormat(type: number): number;
  31508. /** @hidden */
  31509. _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;
  31510. /** @hidden */
  31511. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31512. /**
  31513. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31514. * @returns true if the engine can be created
  31515. * @ignorenaming
  31516. */
  31517. static isSupported(): boolean;
  31518. /**
  31519. * Find the next highest power of two.
  31520. * @param x Number to start search from.
  31521. * @return Next highest power of two.
  31522. */
  31523. static CeilingPOT(x: number): number;
  31524. /**
  31525. * Find the next lowest power of two.
  31526. * @param x Number to start search from.
  31527. * @return Next lowest power of two.
  31528. */
  31529. static FloorPOT(x: number): number;
  31530. /**
  31531. * Find the nearest power of two.
  31532. * @param x Number to start search from.
  31533. * @return Next nearest power of two.
  31534. */
  31535. static NearestPOT(x: number): number;
  31536. /**
  31537. * Get the closest exponent of two
  31538. * @param value defines the value to approximate
  31539. * @param max defines the maximum value to return
  31540. * @param mode defines how to define the closest value
  31541. * @returns closest exponent of two of the given value
  31542. */
  31543. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31544. /**
  31545. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31546. * @param func - the function to be called
  31547. * @param requester - the object that will request the next frame. Falls back to window.
  31548. * @returns frame number
  31549. */
  31550. static QueueNewFrame(func: () => void, requester?: any): number;
  31551. /**
  31552. * Ask the browser to promote the current element to pointerlock mode
  31553. * @param element defines the DOM element to promote
  31554. */
  31555. static _RequestPointerlock(element: HTMLElement): void;
  31556. /**
  31557. * Asks the browser to exit pointerlock mode
  31558. */
  31559. static _ExitPointerlock(): void;
  31560. /**
  31561. * Ask the browser to promote the current element to fullscreen rendering mode
  31562. * @param element defines the DOM element to promote
  31563. */
  31564. static _RequestFullscreen(element: HTMLElement): void;
  31565. /**
  31566. * Asks the browser to exit fullscreen mode
  31567. */
  31568. static _ExitFullscreen(): void;
  31569. }
  31570. }
  31571. declare module BABYLON {
  31572. /**
  31573. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31574. * during the life time of the application.
  31575. */
  31576. export class EngineStore {
  31577. /** Gets the list of created engines */
  31578. static Instances: Engine[];
  31579. /** @hidden */
  31580. static _LastCreatedScene: Nullable<Scene>;
  31581. /**
  31582. * Gets the latest created engine
  31583. */
  31584. static readonly LastCreatedEngine: Nullable<Engine>;
  31585. /**
  31586. * Gets the latest created scene
  31587. */
  31588. static readonly LastCreatedScene: Nullable<Scene>;
  31589. /**
  31590. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31591. * @ignorenaming
  31592. */
  31593. static UseFallbackTexture: boolean;
  31594. /**
  31595. * Texture content used if a texture cannot loaded
  31596. * @ignorenaming
  31597. */
  31598. static FallbackTexture: string;
  31599. }
  31600. }
  31601. declare module BABYLON {
  31602. /**
  31603. * Helper class that provides a small promise polyfill
  31604. */
  31605. export class PromisePolyfill {
  31606. /**
  31607. * Static function used to check if the polyfill is required
  31608. * If this is the case then the function will inject the polyfill to window.Promise
  31609. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31610. */
  31611. static Apply(force?: boolean): void;
  31612. }
  31613. }
  31614. declare module BABYLON {
  31615. /**
  31616. * Interface for screenshot methods with describe argument called `size` as object with options
  31617. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31618. */
  31619. export interface IScreenshotSize {
  31620. /**
  31621. * number in pixels for canvas height
  31622. */
  31623. height?: number;
  31624. /**
  31625. * multiplier allowing render at a higher or lower resolution
  31626. * If value is defined then height and width will be ignored and taken from camera
  31627. */
  31628. precision?: number;
  31629. /**
  31630. * number in pixels for canvas width
  31631. */
  31632. width?: number;
  31633. }
  31634. }
  31635. declare module BABYLON {
  31636. interface IColor4Like {
  31637. r: float;
  31638. g: float;
  31639. b: float;
  31640. a: float;
  31641. }
  31642. /**
  31643. * Class containing a set of static utilities functions
  31644. */
  31645. export class Tools {
  31646. /**
  31647. * Gets or sets the base URL to use to load assets
  31648. */
  31649. static BaseUrl: string;
  31650. /**
  31651. * Enable/Disable Custom HTTP Request Headers globally.
  31652. * default = false
  31653. * @see CustomRequestHeaders
  31654. */
  31655. static UseCustomRequestHeaders: boolean;
  31656. /**
  31657. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31658. * i.e. when loading files, where the server/service expects an Authorization header
  31659. */
  31660. static CustomRequestHeaders: {
  31661. [key: string]: string;
  31662. };
  31663. /**
  31664. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31665. */
  31666. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31667. /**
  31668. * Default behaviour for cors in the application.
  31669. * It can be a string if the expected behavior is identical in the entire app.
  31670. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31671. */
  31672. static CorsBehavior: string | ((url: string | string[]) => string);
  31673. /**
  31674. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31675. * @ignorenaming
  31676. */
  31677. static UseFallbackTexture: boolean;
  31678. /**
  31679. * Use this object to register external classes like custom textures or material
  31680. * to allow the laoders to instantiate them
  31681. */
  31682. static RegisteredExternalClasses: {
  31683. [key: string]: Object;
  31684. };
  31685. /**
  31686. * Texture content used if a texture cannot loaded
  31687. * @ignorenaming
  31688. */
  31689. static fallbackTexture: string;
  31690. /**
  31691. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31692. * @param u defines the coordinate on X axis
  31693. * @param v defines the coordinate on Y axis
  31694. * @param width defines the width of the source data
  31695. * @param height defines the height of the source data
  31696. * @param pixels defines the source byte array
  31697. * @param color defines the output color
  31698. */
  31699. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31700. /**
  31701. * Interpolates between a and b via alpha
  31702. * @param a The lower value (returned when alpha = 0)
  31703. * @param b The upper value (returned when alpha = 1)
  31704. * @param alpha The interpolation-factor
  31705. * @return The mixed value
  31706. */
  31707. static Mix(a: number, b: number, alpha: number): number;
  31708. /**
  31709. * Tries to instantiate a new object from a given class name
  31710. * @param className defines the class name to instantiate
  31711. * @returns the new object or null if the system was not able to do the instantiation
  31712. */
  31713. static Instantiate(className: string): any;
  31714. /**
  31715. * Provides a slice function that will work even on IE
  31716. * @param data defines the array to slice
  31717. * @param start defines the start of the data (optional)
  31718. * @param end defines the end of the data (optional)
  31719. * @returns the new sliced array
  31720. */
  31721. static Slice<T>(data: T, start?: number, end?: number): T;
  31722. /**
  31723. * Polyfill for setImmediate
  31724. * @param action defines the action to execute after the current execution block
  31725. */
  31726. static SetImmediate(action: () => void): void;
  31727. /**
  31728. * Function indicating if a number is an exponent of 2
  31729. * @param value defines the value to test
  31730. * @returns true if the value is an exponent of 2
  31731. */
  31732. static IsExponentOfTwo(value: number): boolean;
  31733. private static _tmpFloatArray;
  31734. /**
  31735. * Returns the nearest 32-bit single precision float representation of a Number
  31736. * @param value A Number. If the parameter is of a different type, it will get converted
  31737. * to a number or to NaN if it cannot be converted
  31738. * @returns number
  31739. */
  31740. static FloatRound(value: number): number;
  31741. /**
  31742. * Extracts the filename from a path
  31743. * @param path defines the path to use
  31744. * @returns the filename
  31745. */
  31746. static GetFilename(path: string): string;
  31747. /**
  31748. * Extracts the "folder" part of a path (everything before the filename).
  31749. * @param uri The URI to extract the info from
  31750. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31751. * @returns The "folder" part of the path
  31752. */
  31753. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31754. /**
  31755. * Extracts text content from a DOM element hierarchy
  31756. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31757. */
  31758. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31759. /**
  31760. * Convert an angle in radians to degrees
  31761. * @param angle defines the angle to convert
  31762. * @returns the angle in degrees
  31763. */
  31764. static ToDegrees(angle: number): number;
  31765. /**
  31766. * Convert an angle in degrees to radians
  31767. * @param angle defines the angle to convert
  31768. * @returns the angle in radians
  31769. */
  31770. static ToRadians(angle: number): number;
  31771. /**
  31772. * Encode a buffer to a base64 string
  31773. * @param buffer defines the buffer to encode
  31774. * @returns the encoded string
  31775. */
  31776. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31777. /**
  31778. * Returns an array if obj is not an array
  31779. * @param obj defines the object to evaluate as an array
  31780. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31781. * @returns either obj directly if obj is an array or a new array containing obj
  31782. */
  31783. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31784. /**
  31785. * Gets the pointer prefix to use
  31786. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31787. */
  31788. static GetPointerPrefix(): string;
  31789. /**
  31790. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31791. * @param url define the url we are trying
  31792. * @param element define the dom element where to configure the cors policy
  31793. */
  31794. static SetCorsBehavior(url: string | string[], element: {
  31795. crossOrigin: string | null;
  31796. }): void;
  31797. /**
  31798. * Removes unwanted characters from an url
  31799. * @param url defines the url to clean
  31800. * @returns the cleaned url
  31801. */
  31802. static CleanUrl(url: string): string;
  31803. /**
  31804. * Gets or sets a function used to pre-process url before using them to load assets
  31805. */
  31806. static PreprocessUrl: (url: string) => string;
  31807. /**
  31808. * Loads an image as an HTMLImageElement.
  31809. * @param input url string, ArrayBuffer, or Blob to load
  31810. * @param onLoad callback called when the image successfully loads
  31811. * @param onError callback called when the image fails to load
  31812. * @param offlineProvider offline provider for caching
  31813. * @returns the HTMLImageElement of the loaded image
  31814. */
  31815. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31816. /**
  31817. * Loads a file
  31818. * @param url url string, ArrayBuffer, or Blob to load
  31819. * @param onSuccess callback called when the file successfully loads
  31820. * @param onProgress callback called while file is loading (if the server supports this mode)
  31821. * @param offlineProvider defines the offline provider for caching
  31822. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31823. * @param onError callback called when the file fails to load
  31824. * @returns a file request object
  31825. */
  31826. 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;
  31827. /**
  31828. * Loads a file from a url
  31829. * @param url the file url to load
  31830. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31831. */
  31832. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31833. /**
  31834. * Load a script (identified by an url). When the url returns, the
  31835. * content of this file is added into a new script element, attached to the DOM (body element)
  31836. * @param scriptUrl defines the url of the script to laod
  31837. * @param onSuccess defines the callback called when the script is loaded
  31838. * @param onError defines the callback to call if an error occurs
  31839. * @param scriptId defines the id of the script element
  31840. */
  31841. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31842. /**
  31843. * Load an asynchronous script (identified by an url). When the url returns, the
  31844. * content of this file is added into a new script element, attached to the DOM (body element)
  31845. * @param scriptUrl defines the url of the script to laod
  31846. * @param scriptId defines the id of the script element
  31847. * @returns a promise request object
  31848. */
  31849. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31850. /**
  31851. * Loads a file from a blob
  31852. * @param fileToLoad defines the blob to use
  31853. * @param callback defines the callback to call when data is loaded
  31854. * @param progressCallback defines the callback to call during loading process
  31855. * @returns a file request object
  31856. */
  31857. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31858. /**
  31859. * Loads a file
  31860. * @param fileToLoad defines the file to load
  31861. * @param callback defines the callback to call when data is loaded
  31862. * @param progressCallBack defines the callback to call during loading process
  31863. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31864. * @returns a file request object
  31865. */
  31866. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31867. /**
  31868. * Creates a data url from a given string content
  31869. * @param content defines the content to convert
  31870. * @returns the new data url link
  31871. */
  31872. static FileAsURL(content: string): string;
  31873. /**
  31874. * Format the given number to a specific decimal format
  31875. * @param value defines the number to format
  31876. * @param decimals defines the number of decimals to use
  31877. * @returns the formatted string
  31878. */
  31879. static Format(value: number, decimals?: number): string;
  31880. /**
  31881. * Tries to copy an object by duplicating every property
  31882. * @param source defines the source object
  31883. * @param destination defines the target object
  31884. * @param doNotCopyList defines a list of properties to avoid
  31885. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31886. */
  31887. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31888. /**
  31889. * Gets a boolean indicating if the given object has no own property
  31890. * @param obj defines the object to test
  31891. * @returns true if object has no own property
  31892. */
  31893. static IsEmpty(obj: any): boolean;
  31894. /**
  31895. * Function used to register events at window level
  31896. * @param windowElement defines the Window object to use
  31897. * @param events defines the events to register
  31898. */
  31899. static RegisterTopRootEvents(windowElement: Window, events: {
  31900. name: string;
  31901. handler: Nullable<(e: FocusEvent) => any>;
  31902. }[]): void;
  31903. /**
  31904. * Function used to unregister events from window level
  31905. * @param windowElement defines the Window object to use
  31906. * @param events defines the events to unregister
  31907. */
  31908. static UnregisterTopRootEvents(windowElement: Window, events: {
  31909. name: string;
  31910. handler: Nullable<(e: FocusEvent) => any>;
  31911. }[]): void;
  31912. /**
  31913. * @ignore
  31914. */
  31915. static _ScreenshotCanvas: HTMLCanvasElement;
  31916. /**
  31917. * Dumps the current bound framebuffer
  31918. * @param width defines the rendering width
  31919. * @param height defines the rendering height
  31920. * @param engine defines the hosting engine
  31921. * @param successCallback defines the callback triggered once the data are available
  31922. * @param mimeType defines the mime type of the result
  31923. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31924. */
  31925. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31926. /**
  31927. * Converts the canvas data to blob.
  31928. * This acts as a polyfill for browsers not supporting the to blob function.
  31929. * @param canvas Defines the canvas to extract the data from
  31930. * @param successCallback Defines the callback triggered once the data are available
  31931. * @param mimeType Defines the mime type of the result
  31932. */
  31933. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31934. /**
  31935. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31936. * @param successCallback defines the callback triggered once the data are available
  31937. * @param mimeType defines the mime type of the result
  31938. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31939. */
  31940. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31941. /**
  31942. * Downloads a blob in the browser
  31943. * @param blob defines the blob to download
  31944. * @param fileName defines the name of the downloaded file
  31945. */
  31946. static Download(blob: Blob, fileName: string): void;
  31947. /**
  31948. * Captures a screenshot of the current rendering
  31949. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31950. * @param engine defines the rendering engine
  31951. * @param camera defines the source camera
  31952. * @param size This parameter can be set to a single number or to an object with the
  31953. * following (optional) properties: precision, width, height. If a single number is passed,
  31954. * it will be used for both width and height. If an object is passed, the screenshot size
  31955. * will be derived from the parameters. The precision property is a multiplier allowing
  31956. * rendering at a higher or lower resolution
  31957. * @param successCallback defines the callback receives a single parameter which contains the
  31958. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31959. * src parameter of an <img> to display it
  31960. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31961. * Check your browser for supported MIME types
  31962. */
  31963. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  31964. /**
  31965. * Captures a screenshot of the current rendering
  31966. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31967. * @param engine defines the rendering engine
  31968. * @param camera defines the source camera
  31969. * @param size This parameter can be set to a single number or to an object with the
  31970. * following (optional) properties: precision, width, height. If a single number is passed,
  31971. * it will be used for both width and height. If an object is passed, the screenshot size
  31972. * will be derived from the parameters. The precision property is a multiplier allowing
  31973. * rendering at a higher or lower resolution
  31974. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31975. * Check your browser for supported MIME types
  31976. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31977. * to the src parameter of an <img> to display it
  31978. */
  31979. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  31980. /**
  31981. * Generates an image screenshot from the specified camera.
  31982. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31983. * @param engine The engine to use for rendering
  31984. * @param camera The camera to use for rendering
  31985. * @param size This parameter can be set to a single number or to an object with the
  31986. * following (optional) properties: precision, width, height. If a single number is passed,
  31987. * it will be used for both width and height. If an object is passed, the screenshot size
  31988. * will be derived from the parameters. The precision property is a multiplier allowing
  31989. * rendering at a higher or lower resolution
  31990. * @param successCallback The callback receives a single parameter which contains the
  31991. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31992. * src parameter of an <img> to display it
  31993. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31994. * Check your browser for supported MIME types
  31995. * @param samples Texture samples (default: 1)
  31996. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31997. * @param fileName A name for for the downloaded file.
  31998. */
  31999. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32000. /**
  32001. * Generates an image screenshot from the specified camera.
  32002. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32003. * @param engine The engine to use for rendering
  32004. * @param camera The camera to use for rendering
  32005. * @param size This parameter can be set to a single number or to an object with the
  32006. * following (optional) properties: precision, width, height. If a single number is passed,
  32007. * it will be used for both width and height. If an object is passed, the screenshot size
  32008. * will be derived from the parameters. The precision property is a multiplier allowing
  32009. * rendering at a higher or lower resolution
  32010. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32011. * Check your browser for supported MIME types
  32012. * @param samples Texture samples (default: 1)
  32013. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32014. * @param fileName A name for for the downloaded file.
  32015. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32016. * to the src parameter of an <img> to display it
  32017. */
  32018. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32019. /**
  32020. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32021. * Be aware Math.random() could cause collisions, but:
  32022. * "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"
  32023. * @returns a pseudo random id
  32024. */
  32025. static RandomId(): string;
  32026. /**
  32027. * Test if the given uri is a base64 string
  32028. * @param uri The uri to test
  32029. * @return True if the uri is a base64 string or false otherwise
  32030. */
  32031. static IsBase64(uri: string): boolean;
  32032. /**
  32033. * Decode the given base64 uri.
  32034. * @param uri The uri to decode
  32035. * @return The decoded base64 data.
  32036. */
  32037. static DecodeBase64(uri: string): ArrayBuffer;
  32038. /**
  32039. * Gets the absolute url.
  32040. * @param url the input url
  32041. * @return the absolute url
  32042. */
  32043. static GetAbsoluteUrl(url: string): string;
  32044. /**
  32045. * No log
  32046. */
  32047. static readonly NoneLogLevel: number;
  32048. /**
  32049. * Only message logs
  32050. */
  32051. static readonly MessageLogLevel: number;
  32052. /**
  32053. * Only warning logs
  32054. */
  32055. static readonly WarningLogLevel: number;
  32056. /**
  32057. * Only error logs
  32058. */
  32059. static readonly ErrorLogLevel: number;
  32060. /**
  32061. * All logs
  32062. */
  32063. static readonly AllLogLevel: number;
  32064. /**
  32065. * Gets a value indicating the number of loading errors
  32066. * @ignorenaming
  32067. */
  32068. static readonly errorsCount: number;
  32069. /**
  32070. * Callback called when a new log is added
  32071. */
  32072. static OnNewCacheEntry: (entry: string) => void;
  32073. /**
  32074. * Log a message to the console
  32075. * @param message defines the message to log
  32076. */
  32077. static Log(message: string): void;
  32078. /**
  32079. * Write a warning message to the console
  32080. * @param message defines the message to log
  32081. */
  32082. static Warn(message: string): void;
  32083. /**
  32084. * Write an error message to the console
  32085. * @param message defines the message to log
  32086. */
  32087. static Error(message: string): void;
  32088. /**
  32089. * Gets current log cache (list of logs)
  32090. */
  32091. static readonly LogCache: string;
  32092. /**
  32093. * Clears the log cache
  32094. */
  32095. static ClearLogCache(): void;
  32096. /**
  32097. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32098. */
  32099. static LogLevels: number;
  32100. /**
  32101. * Checks if the window object exists
  32102. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32103. */
  32104. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32105. /**
  32106. * No performance log
  32107. */
  32108. static readonly PerformanceNoneLogLevel: number;
  32109. /**
  32110. * Use user marks to log performance
  32111. */
  32112. static readonly PerformanceUserMarkLogLevel: number;
  32113. /**
  32114. * Log performance to the console
  32115. */
  32116. static readonly PerformanceConsoleLogLevel: number;
  32117. private static _performance;
  32118. /**
  32119. * Sets the current performance log level
  32120. */
  32121. static PerformanceLogLevel: number;
  32122. private static _StartPerformanceCounterDisabled;
  32123. private static _EndPerformanceCounterDisabled;
  32124. private static _StartUserMark;
  32125. private static _EndUserMark;
  32126. private static _StartPerformanceConsole;
  32127. private static _EndPerformanceConsole;
  32128. /**
  32129. * Starts a performance counter
  32130. */
  32131. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32132. /**
  32133. * Ends a specific performance coutner
  32134. */
  32135. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32136. /**
  32137. * Gets either window.performance.now() if supported or Date.now() else
  32138. */
  32139. static readonly Now: number;
  32140. /**
  32141. * This method will return the name of the class used to create the instance of the given object.
  32142. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32143. * @param object the object to get the class name from
  32144. * @param isType defines if the object is actually a type
  32145. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32146. */
  32147. static GetClassName(object: any, isType?: boolean): string;
  32148. /**
  32149. * Gets the first element of an array satisfying a given predicate
  32150. * @param array defines the array to browse
  32151. * @param predicate defines the predicate to use
  32152. * @returns null if not found or the element
  32153. */
  32154. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32155. /**
  32156. * This method will return the name of the full name of the class, including its owning module (if any).
  32157. * 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).
  32158. * @param object the object to get the class name from
  32159. * @param isType defines if the object is actually a type
  32160. * @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.
  32161. * @ignorenaming
  32162. */
  32163. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32164. /**
  32165. * Returns a promise that resolves after the given amount of time.
  32166. * @param delay Number of milliseconds to delay
  32167. * @returns Promise that resolves after the given amount of time
  32168. */
  32169. static DelayAsync(delay: number): Promise<void>;
  32170. }
  32171. /**
  32172. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32173. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32174. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32175. * @param name The name of the class, case should be preserved
  32176. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32177. */
  32178. export function className(name: string, module?: string): (target: Object) => void;
  32179. /**
  32180. * An implementation of a loop for asynchronous functions.
  32181. */
  32182. export class AsyncLoop {
  32183. /**
  32184. * Defines the number of iterations for the loop
  32185. */
  32186. iterations: number;
  32187. /**
  32188. * Defines the current index of the loop.
  32189. */
  32190. index: number;
  32191. private _done;
  32192. private _fn;
  32193. private _successCallback;
  32194. /**
  32195. * Constructor.
  32196. * @param iterations the number of iterations.
  32197. * @param func the function to run each iteration
  32198. * @param successCallback the callback that will be called upon succesful execution
  32199. * @param offset starting offset.
  32200. */
  32201. constructor(
  32202. /**
  32203. * Defines the number of iterations for the loop
  32204. */
  32205. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32206. /**
  32207. * Execute the next iteration. Must be called after the last iteration was finished.
  32208. */
  32209. executeNext(): void;
  32210. /**
  32211. * Break the loop and run the success callback.
  32212. */
  32213. breakLoop(): void;
  32214. /**
  32215. * Create and run an async loop.
  32216. * @param iterations the number of iterations.
  32217. * @param fn the function to run each iteration
  32218. * @param successCallback the callback that will be called upon succesful execution
  32219. * @param offset starting offset.
  32220. * @returns the created async loop object
  32221. */
  32222. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32223. /**
  32224. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32225. * @param iterations total number of iterations
  32226. * @param syncedIterations number of synchronous iterations in each async iteration.
  32227. * @param fn the function to call each iteration.
  32228. * @param callback a success call back that will be called when iterating stops.
  32229. * @param breakFunction a break condition (optional)
  32230. * @param timeout timeout settings for the setTimeout function. default - 0.
  32231. * @returns the created async loop object
  32232. */
  32233. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32234. }
  32235. }
  32236. declare module BABYLON {
  32237. /** @hidden */
  32238. export interface ICollisionCoordinator {
  32239. createCollider(): Collider;
  32240. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32241. init(scene: Scene): void;
  32242. }
  32243. /** @hidden */
  32244. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32245. private _scene;
  32246. private _scaledPosition;
  32247. private _scaledVelocity;
  32248. private _finalPosition;
  32249. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32250. createCollider(): Collider;
  32251. init(scene: Scene): void;
  32252. private _collideWithWorld;
  32253. }
  32254. }
  32255. declare module BABYLON {
  32256. /**
  32257. * Class used to manage all inputs for the scene.
  32258. */
  32259. export class InputManager {
  32260. /** The distance in pixel that you have to move to prevent some events */
  32261. static DragMovementThreshold: number;
  32262. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32263. static LongPressDelay: number;
  32264. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32265. static DoubleClickDelay: number;
  32266. /** If you need to check double click without raising a single click at first click, enable this flag */
  32267. static ExclusiveDoubleClickMode: boolean;
  32268. private _wheelEventName;
  32269. private _onPointerMove;
  32270. private _onPointerDown;
  32271. private _onPointerUp;
  32272. private _initClickEvent;
  32273. private _initActionManager;
  32274. private _delayedSimpleClick;
  32275. private _delayedSimpleClickTimeout;
  32276. private _previousDelayedSimpleClickTimeout;
  32277. private _meshPickProceed;
  32278. private _previousButtonPressed;
  32279. private _currentPickResult;
  32280. private _previousPickResult;
  32281. private _totalPointersPressed;
  32282. private _doubleClickOccured;
  32283. private _pointerOverMesh;
  32284. private _pickedDownMesh;
  32285. private _pickedUpMesh;
  32286. private _pointerX;
  32287. private _pointerY;
  32288. private _unTranslatedPointerX;
  32289. private _unTranslatedPointerY;
  32290. private _startingPointerPosition;
  32291. private _previousStartingPointerPosition;
  32292. private _startingPointerTime;
  32293. private _previousStartingPointerTime;
  32294. private _pointerCaptures;
  32295. private _onKeyDown;
  32296. private _onKeyUp;
  32297. private _onCanvasFocusObserver;
  32298. private _onCanvasBlurObserver;
  32299. private _scene;
  32300. /**
  32301. * Creates a new InputManager
  32302. * @param scene defines the hosting scene
  32303. */
  32304. constructor(scene: Scene);
  32305. /**
  32306. * Gets the mesh that is currently under the pointer
  32307. */
  32308. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32309. /**
  32310. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32311. */
  32312. readonly unTranslatedPointer: Vector2;
  32313. /**
  32314. * Gets or sets the current on-screen X position of the pointer
  32315. */
  32316. pointerX: number;
  32317. /**
  32318. * Gets or sets the current on-screen Y position of the pointer
  32319. */
  32320. pointerY: number;
  32321. private _updatePointerPosition;
  32322. private _processPointerMove;
  32323. private _setRayOnPointerInfo;
  32324. private _checkPrePointerObservable;
  32325. /**
  32326. * Use this method to simulate a pointer move on a mesh
  32327. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32328. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32329. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32330. */
  32331. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32332. /**
  32333. * Use this method to simulate a pointer down on a mesh
  32334. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32335. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32336. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32337. */
  32338. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32339. private _processPointerDown;
  32340. /** @hidden */
  32341. _isPointerSwiping(): boolean;
  32342. /**
  32343. * Use this method to simulate a pointer up on a mesh
  32344. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32345. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32346. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32347. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32348. */
  32349. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32350. private _processPointerUp;
  32351. /**
  32352. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32353. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32354. * @returns true if the pointer was captured
  32355. */
  32356. isPointerCaptured(pointerId?: number): boolean;
  32357. /**
  32358. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32359. * @param attachUp defines if you want to attach events to pointerup
  32360. * @param attachDown defines if you want to attach events to pointerdown
  32361. * @param attachMove defines if you want to attach events to pointermove
  32362. */
  32363. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32364. /**
  32365. * Detaches all event handlers
  32366. */
  32367. detachControl(): void;
  32368. /**
  32369. * Force the value of meshUnderPointer
  32370. * @param mesh defines the mesh to use
  32371. */
  32372. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32373. /**
  32374. * Gets the mesh under the pointer
  32375. * @returns a Mesh or null if no mesh is under the pointer
  32376. */
  32377. getPointerOverMesh(): Nullable<AbstractMesh>;
  32378. }
  32379. }
  32380. declare module BABYLON {
  32381. /**
  32382. * Helper class used to generate session unique ID
  32383. */
  32384. export class UniqueIdGenerator {
  32385. private static _UniqueIdCounter;
  32386. /**
  32387. * Gets an unique (relatively to the current scene) Id
  32388. */
  32389. static readonly UniqueId: number;
  32390. }
  32391. }
  32392. declare module BABYLON {
  32393. /**
  32394. * This class defines the direct association between an animation and a target
  32395. */
  32396. export class TargetedAnimation {
  32397. /**
  32398. * Animation to perform
  32399. */
  32400. animation: Animation;
  32401. /**
  32402. * Target to animate
  32403. */
  32404. target: any;
  32405. /**
  32406. * Serialize the object
  32407. * @returns the JSON object representing the current entity
  32408. */
  32409. serialize(): any;
  32410. }
  32411. /**
  32412. * Use this class to create coordinated animations on multiple targets
  32413. */
  32414. export class AnimationGroup implements IDisposable {
  32415. /** The name of the animation group */
  32416. name: string;
  32417. private _scene;
  32418. private _targetedAnimations;
  32419. private _animatables;
  32420. private _from;
  32421. private _to;
  32422. private _isStarted;
  32423. private _isPaused;
  32424. private _speedRatio;
  32425. private _loopAnimation;
  32426. /**
  32427. * Gets or sets the unique id of the node
  32428. */
  32429. uniqueId: number;
  32430. /**
  32431. * This observable will notify when one animation have ended
  32432. */
  32433. onAnimationEndObservable: Observable<TargetedAnimation>;
  32434. /**
  32435. * Observer raised when one animation loops
  32436. */
  32437. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32438. /**
  32439. * This observable will notify when all animations have ended.
  32440. */
  32441. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32442. /**
  32443. * This observable will notify when all animations have paused.
  32444. */
  32445. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32446. /**
  32447. * This observable will notify when all animations are playing.
  32448. */
  32449. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32450. /**
  32451. * Gets the first frame
  32452. */
  32453. readonly from: number;
  32454. /**
  32455. * Gets the last frame
  32456. */
  32457. readonly to: number;
  32458. /**
  32459. * Define if the animations are started
  32460. */
  32461. readonly isStarted: boolean;
  32462. /**
  32463. * Gets a value indicating that the current group is playing
  32464. */
  32465. readonly isPlaying: boolean;
  32466. /**
  32467. * Gets or sets the speed ratio to use for all animations
  32468. */
  32469. /**
  32470. * Gets or sets the speed ratio to use for all animations
  32471. */
  32472. speedRatio: number;
  32473. /**
  32474. * Gets or sets if all animations should loop or not
  32475. */
  32476. loopAnimation: boolean;
  32477. /**
  32478. * Gets the targeted animations for this animation group
  32479. */
  32480. readonly targetedAnimations: Array<TargetedAnimation>;
  32481. /**
  32482. * returning the list of animatables controlled by this animation group.
  32483. */
  32484. readonly animatables: Array<Animatable>;
  32485. /**
  32486. * Instantiates a new Animation Group.
  32487. * This helps managing several animations at once.
  32488. * @see http://doc.babylonjs.com/how_to/group
  32489. * @param name Defines the name of the group
  32490. * @param scene Defines the scene the group belongs to
  32491. */
  32492. constructor(
  32493. /** The name of the animation group */
  32494. name: string, scene?: Nullable<Scene>);
  32495. /**
  32496. * Add an animation (with its target) in the group
  32497. * @param animation defines the animation we want to add
  32498. * @param target defines the target of the animation
  32499. * @returns the TargetedAnimation object
  32500. */
  32501. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32502. /**
  32503. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32504. * It can add constant keys at begin or end
  32505. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32506. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32507. * @returns the animation group
  32508. */
  32509. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32510. /**
  32511. * Start all animations on given targets
  32512. * @param loop defines if animations must loop
  32513. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32514. * @param from defines the from key (optional)
  32515. * @param to defines the to key (optional)
  32516. * @returns the current animation group
  32517. */
  32518. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32519. /**
  32520. * Pause all animations
  32521. * @returns the animation group
  32522. */
  32523. pause(): AnimationGroup;
  32524. /**
  32525. * Play all animations to initial state
  32526. * This function will start() the animations if they were not started or will restart() them if they were paused
  32527. * @param loop defines if animations must loop
  32528. * @returns the animation group
  32529. */
  32530. play(loop?: boolean): AnimationGroup;
  32531. /**
  32532. * Reset all animations to initial state
  32533. * @returns the animation group
  32534. */
  32535. reset(): AnimationGroup;
  32536. /**
  32537. * Restart animations from key 0
  32538. * @returns the animation group
  32539. */
  32540. restart(): AnimationGroup;
  32541. /**
  32542. * Stop all animations
  32543. * @returns the animation group
  32544. */
  32545. stop(): AnimationGroup;
  32546. /**
  32547. * Set animation weight for all animatables
  32548. * @param weight defines the weight to use
  32549. * @return the animationGroup
  32550. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32551. */
  32552. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32553. /**
  32554. * Synchronize and normalize all animatables with a source animatable
  32555. * @param root defines the root animatable to synchronize with
  32556. * @return the animationGroup
  32557. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32558. */
  32559. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32560. /**
  32561. * Goes to a specific frame in this animation group
  32562. * @param frame the frame number to go to
  32563. * @return the animationGroup
  32564. */
  32565. goToFrame(frame: number): AnimationGroup;
  32566. /**
  32567. * Dispose all associated resources
  32568. */
  32569. dispose(): void;
  32570. private _checkAnimationGroupEnded;
  32571. /**
  32572. * Clone the current animation group and returns a copy
  32573. * @param newName defines the name of the new group
  32574. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32575. * @returns the new aniamtion group
  32576. */
  32577. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32578. /**
  32579. * Serializes the animationGroup to an object
  32580. * @returns Serialized object
  32581. */
  32582. serialize(): any;
  32583. /**
  32584. * Returns a new AnimationGroup object parsed from the source provided.
  32585. * @param parsedAnimationGroup defines the source
  32586. * @param scene defines the scene that will receive the animationGroup
  32587. * @returns a new AnimationGroup
  32588. */
  32589. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32590. /**
  32591. * Returns the string "AnimationGroup"
  32592. * @returns "AnimationGroup"
  32593. */
  32594. getClassName(): string;
  32595. /**
  32596. * Creates a detailled string about the object
  32597. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32598. * @returns a string representing the object
  32599. */
  32600. toString(fullDetails?: boolean): string;
  32601. }
  32602. }
  32603. declare module BABYLON {
  32604. /**
  32605. * Define an interface for all classes that will hold resources
  32606. */
  32607. export interface IDisposable {
  32608. /**
  32609. * Releases all held resources
  32610. */
  32611. dispose(): void;
  32612. }
  32613. /** Interface defining initialization parameters for Scene class */
  32614. export interface SceneOptions {
  32615. /**
  32616. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32617. * It will improve performance when the number of geometries becomes important.
  32618. */
  32619. useGeometryUniqueIdsMap?: boolean;
  32620. /**
  32621. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32622. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32623. */
  32624. useMaterialMeshMap?: boolean;
  32625. /**
  32626. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32627. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32628. */
  32629. useClonedMeshhMap?: boolean;
  32630. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32631. virtual?: boolean;
  32632. }
  32633. /**
  32634. * Represents a scene to be rendered by the engine.
  32635. * @see http://doc.babylonjs.com/features/scene
  32636. */
  32637. export class Scene extends AbstractScene implements IAnimatable {
  32638. /** The fog is deactivated */
  32639. static readonly FOGMODE_NONE: number;
  32640. /** The fog density is following an exponential function */
  32641. static readonly FOGMODE_EXP: number;
  32642. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32643. static readonly FOGMODE_EXP2: number;
  32644. /** The fog density is following a linear function. */
  32645. static readonly FOGMODE_LINEAR: number;
  32646. /**
  32647. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32648. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32649. */
  32650. static MinDeltaTime: number;
  32651. /**
  32652. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32653. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32654. */
  32655. static MaxDeltaTime: number;
  32656. /**
  32657. * Factory used to create the default material.
  32658. * @param name The name of the material to create
  32659. * @param scene The scene to create the material for
  32660. * @returns The default material
  32661. */
  32662. static DefaultMaterialFactory(scene: Scene): Material;
  32663. /**
  32664. * Factory used to create the a collision coordinator.
  32665. * @returns The collision coordinator
  32666. */
  32667. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32668. /** @hidden */
  32669. _inputManager: InputManager;
  32670. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32671. cameraToUseForPointers: Nullable<Camera>;
  32672. /** @hidden */
  32673. readonly _isScene: boolean;
  32674. /**
  32675. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32676. */
  32677. autoClear: boolean;
  32678. /**
  32679. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32680. */
  32681. autoClearDepthAndStencil: boolean;
  32682. /**
  32683. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32684. */
  32685. clearColor: Color4;
  32686. /**
  32687. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32688. */
  32689. ambientColor: Color3;
  32690. /**
  32691. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32692. * It should only be one of the following (if not the default embedded one):
  32693. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32694. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32695. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32696. * The material properties need to be setup according to the type of texture in use.
  32697. */
  32698. environmentBRDFTexture: BaseTexture;
  32699. /** @hidden */
  32700. protected _environmentTexture: Nullable<BaseTexture>;
  32701. /**
  32702. * Texture used in all pbr material as the reflection texture.
  32703. * As in the majority of the scene they are the same (exception for multi room and so on),
  32704. * this is easier to reference from here than from all the materials.
  32705. */
  32706. /**
  32707. * Texture used in all pbr material as the reflection texture.
  32708. * As in the majority of the scene they are the same (exception for multi room and so on),
  32709. * this is easier to set here than in all the materials.
  32710. */
  32711. environmentTexture: Nullable<BaseTexture>;
  32712. /** @hidden */
  32713. protected _environmentIntensity: number;
  32714. /**
  32715. * Intensity of the environment in all pbr material.
  32716. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32717. * As in the majority of the scene they are the same (exception for multi room and so on),
  32718. * this is easier to reference from here than from all the materials.
  32719. */
  32720. /**
  32721. * Intensity of the environment in all pbr material.
  32722. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32723. * As in the majority of the scene they are the same (exception for multi room and so on),
  32724. * this is easier to set here than in all the materials.
  32725. */
  32726. environmentIntensity: number;
  32727. /** @hidden */
  32728. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32729. /**
  32730. * Default image processing configuration used either in the rendering
  32731. * Forward main pass or through the imageProcessingPostProcess if present.
  32732. * As in the majority of the scene they are the same (exception for multi camera),
  32733. * this is easier to reference from here than from all the materials and post process.
  32734. *
  32735. * No setter as we it is a shared configuration, you can set the values instead.
  32736. */
  32737. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32738. private _forceWireframe;
  32739. /**
  32740. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32741. */
  32742. forceWireframe: boolean;
  32743. private _forcePointsCloud;
  32744. /**
  32745. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32746. */
  32747. forcePointsCloud: boolean;
  32748. /**
  32749. * Gets or sets the active clipplane 1
  32750. */
  32751. clipPlane: Nullable<Plane>;
  32752. /**
  32753. * Gets or sets the active clipplane 2
  32754. */
  32755. clipPlane2: Nullable<Plane>;
  32756. /**
  32757. * Gets or sets the active clipplane 3
  32758. */
  32759. clipPlane3: Nullable<Plane>;
  32760. /**
  32761. * Gets or sets the active clipplane 4
  32762. */
  32763. clipPlane4: Nullable<Plane>;
  32764. /**
  32765. * Gets or sets a boolean indicating if animations are enabled
  32766. */
  32767. animationsEnabled: boolean;
  32768. private _animationPropertiesOverride;
  32769. /**
  32770. * Gets or sets the animation properties override
  32771. */
  32772. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32773. /**
  32774. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32775. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32776. */
  32777. useConstantAnimationDeltaTime: boolean;
  32778. /**
  32779. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32780. * Please note that it requires to run a ray cast through the scene on every frame
  32781. */
  32782. constantlyUpdateMeshUnderPointer: boolean;
  32783. /**
  32784. * Defines the HTML cursor to use when hovering over interactive elements
  32785. */
  32786. hoverCursor: string;
  32787. /**
  32788. * Defines the HTML default cursor to use (empty by default)
  32789. */
  32790. defaultCursor: string;
  32791. /**
  32792. * This is used to call preventDefault() on pointer down
  32793. * in order to block unwanted artifacts like system double clicks
  32794. */
  32795. preventDefaultOnPointerDown: boolean;
  32796. /**
  32797. * This is used to call preventDefault() on pointer up
  32798. * in order to block unwanted artifacts like system double clicks
  32799. */
  32800. preventDefaultOnPointerUp: boolean;
  32801. /**
  32802. * Gets or sets user defined metadata
  32803. */
  32804. metadata: any;
  32805. /**
  32806. * For internal use only. Please do not use.
  32807. */
  32808. reservedDataStore: any;
  32809. /**
  32810. * Gets the name of the plugin used to load this scene (null by default)
  32811. */
  32812. loadingPluginName: string;
  32813. /**
  32814. * Use this array to add regular expressions used to disable offline support for specific urls
  32815. */
  32816. disableOfflineSupportExceptionRules: RegExp[];
  32817. /**
  32818. * An event triggered when the scene is disposed.
  32819. */
  32820. onDisposeObservable: Observable<Scene>;
  32821. private _onDisposeObserver;
  32822. /** Sets a function to be executed when this scene is disposed. */
  32823. onDispose: () => void;
  32824. /**
  32825. * An event triggered before rendering the scene (right after animations and physics)
  32826. */
  32827. onBeforeRenderObservable: Observable<Scene>;
  32828. private _onBeforeRenderObserver;
  32829. /** Sets a function to be executed before rendering this scene */
  32830. beforeRender: Nullable<() => void>;
  32831. /**
  32832. * An event triggered after rendering the scene
  32833. */
  32834. onAfterRenderObservable: Observable<Scene>;
  32835. /**
  32836. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32837. */
  32838. onAfterRenderCameraObservable: Observable<Camera>;
  32839. private _onAfterRenderObserver;
  32840. /** Sets a function to be executed after rendering this scene */
  32841. afterRender: Nullable<() => void>;
  32842. /**
  32843. * An event triggered before animating the scene
  32844. */
  32845. onBeforeAnimationsObservable: Observable<Scene>;
  32846. /**
  32847. * An event triggered after animations processing
  32848. */
  32849. onAfterAnimationsObservable: Observable<Scene>;
  32850. /**
  32851. * An event triggered before draw calls are ready to be sent
  32852. */
  32853. onBeforeDrawPhaseObservable: Observable<Scene>;
  32854. /**
  32855. * An event triggered after draw calls have been sent
  32856. */
  32857. onAfterDrawPhaseObservable: Observable<Scene>;
  32858. /**
  32859. * An event triggered when the scene is ready
  32860. */
  32861. onReadyObservable: Observable<Scene>;
  32862. /**
  32863. * An event triggered before rendering a camera
  32864. */
  32865. onBeforeCameraRenderObservable: Observable<Camera>;
  32866. private _onBeforeCameraRenderObserver;
  32867. /** Sets a function to be executed before rendering a camera*/
  32868. beforeCameraRender: () => void;
  32869. /**
  32870. * An event triggered after rendering a camera
  32871. */
  32872. onAfterCameraRenderObservable: Observable<Camera>;
  32873. private _onAfterCameraRenderObserver;
  32874. /** Sets a function to be executed after rendering a camera*/
  32875. afterCameraRender: () => void;
  32876. /**
  32877. * An event triggered when active meshes evaluation is about to start
  32878. */
  32879. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32880. /**
  32881. * An event triggered when active meshes evaluation is done
  32882. */
  32883. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32884. /**
  32885. * An event triggered when particles rendering is about to start
  32886. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32887. */
  32888. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32889. /**
  32890. * An event triggered when particles rendering is done
  32891. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32892. */
  32893. onAfterParticlesRenderingObservable: Observable<Scene>;
  32894. /**
  32895. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32896. */
  32897. onDataLoadedObservable: Observable<Scene>;
  32898. /**
  32899. * An event triggered when a camera is created
  32900. */
  32901. onNewCameraAddedObservable: Observable<Camera>;
  32902. /**
  32903. * An event triggered when a camera is removed
  32904. */
  32905. onCameraRemovedObservable: Observable<Camera>;
  32906. /**
  32907. * An event triggered when a light is created
  32908. */
  32909. onNewLightAddedObservable: Observable<Light>;
  32910. /**
  32911. * An event triggered when a light is removed
  32912. */
  32913. onLightRemovedObservable: Observable<Light>;
  32914. /**
  32915. * An event triggered when a geometry is created
  32916. */
  32917. onNewGeometryAddedObservable: Observable<Geometry>;
  32918. /**
  32919. * An event triggered when a geometry is removed
  32920. */
  32921. onGeometryRemovedObservable: Observable<Geometry>;
  32922. /**
  32923. * An event triggered when a transform node is created
  32924. */
  32925. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32926. /**
  32927. * An event triggered when a transform node is removed
  32928. */
  32929. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32930. /**
  32931. * An event triggered when a mesh is created
  32932. */
  32933. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32934. /**
  32935. * An event triggered when a mesh is removed
  32936. */
  32937. onMeshRemovedObservable: Observable<AbstractMesh>;
  32938. /**
  32939. * An event triggered when a skeleton is created
  32940. */
  32941. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32942. /**
  32943. * An event triggered when a skeleton is removed
  32944. */
  32945. onSkeletonRemovedObservable: Observable<Skeleton>;
  32946. /**
  32947. * An event triggered when a material is created
  32948. */
  32949. onNewMaterialAddedObservable: Observable<Material>;
  32950. /**
  32951. * An event triggered when a material is removed
  32952. */
  32953. onMaterialRemovedObservable: Observable<Material>;
  32954. /**
  32955. * An event triggered when a texture is created
  32956. */
  32957. onNewTextureAddedObservable: Observable<BaseTexture>;
  32958. /**
  32959. * An event triggered when a texture is removed
  32960. */
  32961. onTextureRemovedObservable: Observable<BaseTexture>;
  32962. /**
  32963. * An event triggered when render targets are about to be rendered
  32964. * Can happen multiple times per frame.
  32965. */
  32966. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32967. /**
  32968. * An event triggered when render targets were rendered.
  32969. * Can happen multiple times per frame.
  32970. */
  32971. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32972. /**
  32973. * An event triggered before calculating deterministic simulation step
  32974. */
  32975. onBeforeStepObservable: Observable<Scene>;
  32976. /**
  32977. * An event triggered after calculating deterministic simulation step
  32978. */
  32979. onAfterStepObservable: Observable<Scene>;
  32980. /**
  32981. * An event triggered when the activeCamera property is updated
  32982. */
  32983. onActiveCameraChanged: Observable<Scene>;
  32984. /**
  32985. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32986. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32987. * 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)
  32988. */
  32989. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32990. /**
  32991. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32992. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32993. * 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)
  32994. */
  32995. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32996. /**
  32997. * This Observable will when a mesh has been imported into the scene.
  32998. */
  32999. onMeshImportedObservable: Observable<AbstractMesh>;
  33000. /**
  33001. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33002. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33003. */
  33004. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33005. /** @hidden */
  33006. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33007. /**
  33008. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33009. */
  33010. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33011. /**
  33012. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33013. */
  33014. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33015. /**
  33016. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33017. */
  33018. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33019. /** Callback called when a pointer move is detected */
  33020. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33021. /** Callback called when a pointer down is detected */
  33022. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33023. /** Callback called when a pointer up is detected */
  33024. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33025. /** Callback called when a pointer pick is detected */
  33026. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33027. /**
  33028. * 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).
  33029. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33030. */
  33031. onPrePointerObservable: Observable<PointerInfoPre>;
  33032. /**
  33033. * Observable event triggered each time an input event is received from the rendering canvas
  33034. */
  33035. onPointerObservable: Observable<PointerInfo>;
  33036. /**
  33037. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33038. */
  33039. readonly unTranslatedPointer: Vector2;
  33040. /**
  33041. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33042. */
  33043. static DragMovementThreshold: number;
  33044. /**
  33045. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33046. */
  33047. static LongPressDelay: number;
  33048. /**
  33049. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33050. */
  33051. static DoubleClickDelay: number;
  33052. /** If you need to check double click without raising a single click at first click, enable this flag */
  33053. static ExclusiveDoubleClickMode: boolean;
  33054. /** @hidden */
  33055. _mirroredCameraPosition: Nullable<Vector3>;
  33056. /**
  33057. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33058. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33059. */
  33060. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33061. /**
  33062. * Observable event triggered each time an keyboard event is received from the hosting window
  33063. */
  33064. onKeyboardObservable: Observable<KeyboardInfo>;
  33065. private _useRightHandedSystem;
  33066. /**
  33067. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33068. */
  33069. useRightHandedSystem: boolean;
  33070. private _timeAccumulator;
  33071. private _currentStepId;
  33072. private _currentInternalStep;
  33073. /**
  33074. * Sets the step Id used by deterministic lock step
  33075. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33076. * @param newStepId defines the step Id
  33077. */
  33078. setStepId(newStepId: number): void;
  33079. /**
  33080. * Gets the step Id used by deterministic lock step
  33081. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33082. * @returns the step Id
  33083. */
  33084. getStepId(): number;
  33085. /**
  33086. * Gets the internal step used by deterministic lock step
  33087. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33088. * @returns the internal step
  33089. */
  33090. getInternalStep(): number;
  33091. private _fogEnabled;
  33092. /**
  33093. * Gets or sets a boolean indicating if fog is enabled on this scene
  33094. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33095. * (Default is true)
  33096. */
  33097. fogEnabled: boolean;
  33098. private _fogMode;
  33099. /**
  33100. * Gets or sets the fog mode to use
  33101. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33102. * | mode | value |
  33103. * | --- | --- |
  33104. * | FOGMODE_NONE | 0 |
  33105. * | FOGMODE_EXP | 1 |
  33106. * | FOGMODE_EXP2 | 2 |
  33107. * | FOGMODE_LINEAR | 3 |
  33108. */
  33109. fogMode: number;
  33110. /**
  33111. * Gets or sets the fog color to use
  33112. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33113. * (Default is Color3(0.2, 0.2, 0.3))
  33114. */
  33115. fogColor: Color3;
  33116. /**
  33117. * Gets or sets the fog density to use
  33118. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33119. * (Default is 0.1)
  33120. */
  33121. fogDensity: number;
  33122. /**
  33123. * Gets or sets the fog start distance to use
  33124. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33125. * (Default is 0)
  33126. */
  33127. fogStart: number;
  33128. /**
  33129. * Gets or sets the fog end distance to use
  33130. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33131. * (Default is 1000)
  33132. */
  33133. fogEnd: number;
  33134. private _shadowsEnabled;
  33135. /**
  33136. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33137. */
  33138. shadowsEnabled: boolean;
  33139. private _lightsEnabled;
  33140. /**
  33141. * Gets or sets a boolean indicating if lights are enabled on this scene
  33142. */
  33143. lightsEnabled: boolean;
  33144. /** All of the active cameras added to this scene. */
  33145. activeCameras: Camera[];
  33146. /** @hidden */
  33147. _activeCamera: Nullable<Camera>;
  33148. /** Gets or sets the current active camera */
  33149. activeCamera: Nullable<Camera>;
  33150. private _defaultMaterial;
  33151. /** The default material used on meshes when no material is affected */
  33152. /** The default material used on meshes when no material is affected */
  33153. defaultMaterial: Material;
  33154. private _texturesEnabled;
  33155. /**
  33156. * Gets or sets a boolean indicating if textures are enabled on this scene
  33157. */
  33158. texturesEnabled: boolean;
  33159. /**
  33160. * Gets or sets a boolean indicating if particles are enabled on this scene
  33161. */
  33162. particlesEnabled: boolean;
  33163. /**
  33164. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33165. */
  33166. spritesEnabled: boolean;
  33167. private _skeletonsEnabled;
  33168. /**
  33169. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33170. */
  33171. skeletonsEnabled: boolean;
  33172. /**
  33173. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33174. */
  33175. lensFlaresEnabled: boolean;
  33176. /**
  33177. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33178. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33179. */
  33180. collisionsEnabled: boolean;
  33181. private _collisionCoordinator;
  33182. /** @hidden */
  33183. readonly collisionCoordinator: ICollisionCoordinator;
  33184. /**
  33185. * Defines the gravity applied to this scene (used only for collisions)
  33186. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33187. */
  33188. gravity: Vector3;
  33189. /**
  33190. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33191. */
  33192. postProcessesEnabled: boolean;
  33193. /**
  33194. * The list of postprocesses added to the scene
  33195. */
  33196. postProcesses: PostProcess[];
  33197. /**
  33198. * Gets the current postprocess manager
  33199. */
  33200. postProcessManager: PostProcessManager;
  33201. /**
  33202. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33203. */
  33204. renderTargetsEnabled: boolean;
  33205. /**
  33206. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33207. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33208. */
  33209. dumpNextRenderTargets: boolean;
  33210. /**
  33211. * The list of user defined render targets added to the scene
  33212. */
  33213. customRenderTargets: RenderTargetTexture[];
  33214. /**
  33215. * Defines if texture loading must be delayed
  33216. * If true, textures will only be loaded when they need to be rendered
  33217. */
  33218. useDelayedTextureLoading: boolean;
  33219. /**
  33220. * Gets the list of meshes imported to the scene through SceneLoader
  33221. */
  33222. importedMeshesFiles: String[];
  33223. /**
  33224. * Gets or sets a boolean indicating if probes are enabled on this scene
  33225. */
  33226. probesEnabled: boolean;
  33227. /**
  33228. * Gets or sets the current offline provider to use to store scene data
  33229. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33230. */
  33231. offlineProvider: IOfflineProvider;
  33232. /**
  33233. * Gets or sets the action manager associated with the scene
  33234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33235. */
  33236. actionManager: AbstractActionManager;
  33237. private _meshesForIntersections;
  33238. /**
  33239. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33240. */
  33241. proceduralTexturesEnabled: boolean;
  33242. private _engine;
  33243. private _totalVertices;
  33244. /** @hidden */
  33245. _activeIndices: PerfCounter;
  33246. /** @hidden */
  33247. _activeParticles: PerfCounter;
  33248. /** @hidden */
  33249. _activeBones: PerfCounter;
  33250. private _animationRatio;
  33251. /** @hidden */
  33252. _animationTimeLast: number;
  33253. /** @hidden */
  33254. _animationTime: number;
  33255. /**
  33256. * Gets or sets a general scale for animation speed
  33257. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33258. */
  33259. animationTimeScale: number;
  33260. /** @hidden */
  33261. _cachedMaterial: Nullable<Material>;
  33262. /** @hidden */
  33263. _cachedEffect: Nullable<Effect>;
  33264. /** @hidden */
  33265. _cachedVisibility: Nullable<number>;
  33266. private _renderId;
  33267. private _frameId;
  33268. private _executeWhenReadyTimeoutId;
  33269. private _intermediateRendering;
  33270. private _viewUpdateFlag;
  33271. private _projectionUpdateFlag;
  33272. /** @hidden */
  33273. _toBeDisposed: Nullable<IDisposable>[];
  33274. private _activeRequests;
  33275. /** @hidden */
  33276. _pendingData: any[];
  33277. private _isDisposed;
  33278. /**
  33279. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33280. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33281. */
  33282. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33283. private _activeMeshes;
  33284. private _processedMaterials;
  33285. private _renderTargets;
  33286. /** @hidden */
  33287. _activeParticleSystems: SmartArray<IParticleSystem>;
  33288. private _activeSkeletons;
  33289. private _softwareSkinnedMeshes;
  33290. private _renderingManager;
  33291. /** @hidden */
  33292. _activeAnimatables: Animatable[];
  33293. private _transformMatrix;
  33294. private _sceneUbo;
  33295. /** @hidden */
  33296. _viewMatrix: Matrix;
  33297. private _projectionMatrix;
  33298. /** @hidden */
  33299. _forcedViewPosition: Nullable<Vector3>;
  33300. /** @hidden */
  33301. _frustumPlanes: Plane[];
  33302. /**
  33303. * Gets the list of frustum planes (built from the active camera)
  33304. */
  33305. readonly frustumPlanes: Plane[];
  33306. /**
  33307. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33308. * This is useful if there are more lights that the maximum simulteanous authorized
  33309. */
  33310. requireLightSorting: boolean;
  33311. /** @hidden */
  33312. readonly useMaterialMeshMap: boolean;
  33313. /** @hidden */
  33314. readonly useClonedMeshhMap: boolean;
  33315. private _externalData;
  33316. private _uid;
  33317. /**
  33318. * @hidden
  33319. * Backing store of defined scene components.
  33320. */
  33321. _components: ISceneComponent[];
  33322. /**
  33323. * @hidden
  33324. * Backing store of defined scene components.
  33325. */
  33326. _serializableComponents: ISceneSerializableComponent[];
  33327. /**
  33328. * List of components to register on the next registration step.
  33329. */
  33330. private _transientComponents;
  33331. /**
  33332. * Registers the transient components if needed.
  33333. */
  33334. private _registerTransientComponents;
  33335. /**
  33336. * @hidden
  33337. * Add a component to the scene.
  33338. * Note that the ccomponent could be registered on th next frame if this is called after
  33339. * the register component stage.
  33340. * @param component Defines the component to add to the scene
  33341. */
  33342. _addComponent(component: ISceneComponent): void;
  33343. /**
  33344. * @hidden
  33345. * Gets a component from the scene.
  33346. * @param name defines the name of the component to retrieve
  33347. * @returns the component or null if not present
  33348. */
  33349. _getComponent(name: string): Nullable<ISceneComponent>;
  33350. /**
  33351. * @hidden
  33352. * Defines the actions happening before camera updates.
  33353. */
  33354. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33355. /**
  33356. * @hidden
  33357. * Defines the actions happening before clear the canvas.
  33358. */
  33359. _beforeClearStage: Stage<SimpleStageAction>;
  33360. /**
  33361. * @hidden
  33362. * Defines the actions when collecting render targets for the frame.
  33363. */
  33364. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33365. /**
  33366. * @hidden
  33367. * Defines the actions happening for one camera in the frame.
  33368. */
  33369. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33370. /**
  33371. * @hidden
  33372. * Defines the actions happening during the per mesh ready checks.
  33373. */
  33374. _isReadyForMeshStage: Stage<MeshStageAction>;
  33375. /**
  33376. * @hidden
  33377. * Defines the actions happening before evaluate active mesh checks.
  33378. */
  33379. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33380. /**
  33381. * @hidden
  33382. * Defines the actions happening during the evaluate sub mesh checks.
  33383. */
  33384. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33385. /**
  33386. * @hidden
  33387. * Defines the actions happening during the active mesh stage.
  33388. */
  33389. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33390. /**
  33391. * @hidden
  33392. * Defines the actions happening during the per camera render target step.
  33393. */
  33394. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33395. /**
  33396. * @hidden
  33397. * Defines the actions happening just before the active camera is drawing.
  33398. */
  33399. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33400. /**
  33401. * @hidden
  33402. * Defines the actions happening just before a render target is drawing.
  33403. */
  33404. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33405. /**
  33406. * @hidden
  33407. * Defines the actions happening just before a rendering group is drawing.
  33408. */
  33409. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33410. /**
  33411. * @hidden
  33412. * Defines the actions happening just before a mesh is drawing.
  33413. */
  33414. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33415. /**
  33416. * @hidden
  33417. * Defines the actions happening just after a mesh has been drawn.
  33418. */
  33419. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33420. /**
  33421. * @hidden
  33422. * Defines the actions happening just after a rendering group has been drawn.
  33423. */
  33424. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33425. /**
  33426. * @hidden
  33427. * Defines the actions happening just after the active camera has been drawn.
  33428. */
  33429. _afterCameraDrawStage: Stage<CameraStageAction>;
  33430. /**
  33431. * @hidden
  33432. * Defines the actions happening just after a render target has been drawn.
  33433. */
  33434. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33435. /**
  33436. * @hidden
  33437. * Defines the actions happening just after rendering all cameras and computing intersections.
  33438. */
  33439. _afterRenderStage: Stage<SimpleStageAction>;
  33440. /**
  33441. * @hidden
  33442. * Defines the actions happening when a pointer move event happens.
  33443. */
  33444. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33445. /**
  33446. * @hidden
  33447. * Defines the actions happening when a pointer down event happens.
  33448. */
  33449. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33450. /**
  33451. * @hidden
  33452. * Defines the actions happening when a pointer up event happens.
  33453. */
  33454. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33455. /**
  33456. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33457. */
  33458. private geometriesByUniqueId;
  33459. /**
  33460. * Creates a new Scene
  33461. * @param engine defines the engine to use to render this scene
  33462. * @param options defines the scene options
  33463. */
  33464. constructor(engine: Engine, options?: SceneOptions);
  33465. /**
  33466. * Gets a string idenfifying the name of the class
  33467. * @returns "Scene" string
  33468. */
  33469. getClassName(): string;
  33470. private _defaultMeshCandidates;
  33471. /**
  33472. * @hidden
  33473. */
  33474. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33475. private _defaultSubMeshCandidates;
  33476. /**
  33477. * @hidden
  33478. */
  33479. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33480. /**
  33481. * Sets the default candidate providers for the scene.
  33482. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33483. * and getCollidingSubMeshCandidates to their default function
  33484. */
  33485. setDefaultCandidateProviders(): void;
  33486. /**
  33487. * Gets the mesh that is currently under the pointer
  33488. */
  33489. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33490. /**
  33491. * Gets or sets the current on-screen X position of the pointer
  33492. */
  33493. pointerX: number;
  33494. /**
  33495. * Gets or sets the current on-screen Y position of the pointer
  33496. */
  33497. pointerY: number;
  33498. /**
  33499. * Gets the cached material (ie. the latest rendered one)
  33500. * @returns the cached material
  33501. */
  33502. getCachedMaterial(): Nullable<Material>;
  33503. /**
  33504. * Gets the cached effect (ie. the latest rendered one)
  33505. * @returns the cached effect
  33506. */
  33507. getCachedEffect(): Nullable<Effect>;
  33508. /**
  33509. * Gets the cached visibility state (ie. the latest rendered one)
  33510. * @returns the cached visibility state
  33511. */
  33512. getCachedVisibility(): Nullable<number>;
  33513. /**
  33514. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33515. * @param material defines the current material
  33516. * @param effect defines the current effect
  33517. * @param visibility defines the current visibility state
  33518. * @returns true if one parameter is not cached
  33519. */
  33520. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33521. /**
  33522. * Gets the engine associated with the scene
  33523. * @returns an Engine
  33524. */
  33525. getEngine(): Engine;
  33526. /**
  33527. * Gets the total number of vertices rendered per frame
  33528. * @returns the total number of vertices rendered per frame
  33529. */
  33530. getTotalVertices(): number;
  33531. /**
  33532. * Gets the performance counter for total vertices
  33533. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33534. */
  33535. readonly totalVerticesPerfCounter: PerfCounter;
  33536. /**
  33537. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33538. * @returns the total number of active indices rendered per frame
  33539. */
  33540. getActiveIndices(): number;
  33541. /**
  33542. * Gets the performance counter for active indices
  33543. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33544. */
  33545. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33546. /**
  33547. * Gets the total number of active particles rendered per frame
  33548. * @returns the total number of active particles rendered per frame
  33549. */
  33550. getActiveParticles(): number;
  33551. /**
  33552. * Gets the performance counter for active particles
  33553. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33554. */
  33555. readonly activeParticlesPerfCounter: PerfCounter;
  33556. /**
  33557. * Gets the total number of active bones rendered per frame
  33558. * @returns the total number of active bones rendered per frame
  33559. */
  33560. getActiveBones(): number;
  33561. /**
  33562. * Gets the performance counter for active bones
  33563. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33564. */
  33565. readonly activeBonesPerfCounter: PerfCounter;
  33566. /**
  33567. * Gets the array of active meshes
  33568. * @returns an array of AbstractMesh
  33569. */
  33570. getActiveMeshes(): SmartArray<AbstractMesh>;
  33571. /**
  33572. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33573. * @returns a number
  33574. */
  33575. getAnimationRatio(): number;
  33576. /**
  33577. * Gets an unique Id for the current render phase
  33578. * @returns a number
  33579. */
  33580. getRenderId(): number;
  33581. /**
  33582. * Gets an unique Id for the current frame
  33583. * @returns a number
  33584. */
  33585. getFrameId(): number;
  33586. /** Call this function if you want to manually increment the render Id*/
  33587. incrementRenderId(): void;
  33588. private _createUbo;
  33589. /**
  33590. * Use this method to simulate a pointer move on a mesh
  33591. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33592. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33593. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33594. * @returns the current scene
  33595. */
  33596. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33597. /**
  33598. * Use this method to simulate a pointer down on a mesh
  33599. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33600. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33601. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33602. * @returns the current scene
  33603. */
  33604. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33605. /**
  33606. * Use this method to simulate a pointer up on a mesh
  33607. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33608. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33609. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33610. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33611. * @returns the current scene
  33612. */
  33613. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33614. /**
  33615. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33616. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33617. * @returns true if the pointer was captured
  33618. */
  33619. isPointerCaptured(pointerId?: number): boolean;
  33620. /**
  33621. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33622. * @param attachUp defines if you want to attach events to pointerup
  33623. * @param attachDown defines if you want to attach events to pointerdown
  33624. * @param attachMove defines if you want to attach events to pointermove
  33625. */
  33626. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33627. /** Detaches all event handlers*/
  33628. detachControl(): void;
  33629. /**
  33630. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33631. * Delay loaded resources are not taking in account
  33632. * @return true if all required resources are ready
  33633. */
  33634. isReady(): boolean;
  33635. /** Resets all cached information relative to material (including effect and visibility) */
  33636. resetCachedMaterial(): void;
  33637. /**
  33638. * Registers a function to be called before every frame render
  33639. * @param func defines the function to register
  33640. */
  33641. registerBeforeRender(func: () => void): void;
  33642. /**
  33643. * Unregisters a function called before every frame render
  33644. * @param func defines the function to unregister
  33645. */
  33646. unregisterBeforeRender(func: () => void): void;
  33647. /**
  33648. * Registers a function to be called after every frame render
  33649. * @param func defines the function to register
  33650. */
  33651. registerAfterRender(func: () => void): void;
  33652. /**
  33653. * Unregisters a function called after every frame render
  33654. * @param func defines the function to unregister
  33655. */
  33656. unregisterAfterRender(func: () => void): void;
  33657. private _executeOnceBeforeRender;
  33658. /**
  33659. * The provided function will run before render once and will be disposed afterwards.
  33660. * A timeout delay can be provided so that the function will be executed in N ms.
  33661. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33662. * @param func The function to be executed.
  33663. * @param timeout optional delay in ms
  33664. */
  33665. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33666. /** @hidden */
  33667. _addPendingData(data: any): void;
  33668. /** @hidden */
  33669. _removePendingData(data: any): void;
  33670. /**
  33671. * Returns the number of items waiting to be loaded
  33672. * @returns the number of items waiting to be loaded
  33673. */
  33674. getWaitingItemsCount(): number;
  33675. /**
  33676. * Returns a boolean indicating if the scene is still loading data
  33677. */
  33678. readonly isLoading: boolean;
  33679. /**
  33680. * Registers a function to be executed when the scene is ready
  33681. * @param {Function} func - the function to be executed
  33682. */
  33683. executeWhenReady(func: () => void): void;
  33684. /**
  33685. * Returns a promise that resolves when the scene is ready
  33686. * @returns A promise that resolves when the scene is ready
  33687. */
  33688. whenReadyAsync(): Promise<void>;
  33689. /** @hidden */
  33690. _checkIsReady(): void;
  33691. /**
  33692. * Gets all animatable attached to the scene
  33693. */
  33694. readonly animatables: Animatable[];
  33695. /**
  33696. * Resets the last animation time frame.
  33697. * Useful to override when animations start running when loading a scene for the first time.
  33698. */
  33699. resetLastAnimationTimeFrame(): void;
  33700. /**
  33701. * Gets the current view matrix
  33702. * @returns a Matrix
  33703. */
  33704. getViewMatrix(): Matrix;
  33705. /**
  33706. * Gets the current projection matrix
  33707. * @returns a Matrix
  33708. */
  33709. getProjectionMatrix(): Matrix;
  33710. /**
  33711. * Gets the current transform matrix
  33712. * @returns a Matrix made of View * Projection
  33713. */
  33714. getTransformMatrix(): Matrix;
  33715. /**
  33716. * Sets the current transform matrix
  33717. * @param viewL defines the View matrix to use
  33718. * @param projectionL defines the Projection matrix to use
  33719. * @param viewR defines the right View matrix to use (if provided)
  33720. * @param projectionR defines the right Projection matrix to use (if provided)
  33721. */
  33722. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33723. /**
  33724. * Gets the uniform buffer used to store scene data
  33725. * @returns a UniformBuffer
  33726. */
  33727. getSceneUniformBuffer(): UniformBuffer;
  33728. /**
  33729. * Gets an unique (relatively to the current scene) Id
  33730. * @returns an unique number for the scene
  33731. */
  33732. getUniqueId(): number;
  33733. /**
  33734. * Add a mesh to the list of scene's meshes
  33735. * @param newMesh defines the mesh to add
  33736. * @param recursive if all child meshes should also be added to the scene
  33737. */
  33738. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33739. /**
  33740. * Remove a mesh for the list of scene's meshes
  33741. * @param toRemove defines the mesh to remove
  33742. * @param recursive if all child meshes should also be removed from the scene
  33743. * @returns the index where the mesh was in the mesh list
  33744. */
  33745. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33746. /**
  33747. * Add a transform node to the list of scene's transform nodes
  33748. * @param newTransformNode defines the transform node to add
  33749. */
  33750. addTransformNode(newTransformNode: TransformNode): void;
  33751. /**
  33752. * Remove a transform node for the list of scene's transform nodes
  33753. * @param toRemove defines the transform node to remove
  33754. * @returns the index where the transform node was in the transform node list
  33755. */
  33756. removeTransformNode(toRemove: TransformNode): number;
  33757. /**
  33758. * Remove a skeleton for the list of scene's skeletons
  33759. * @param toRemove defines the skeleton to remove
  33760. * @returns the index where the skeleton was in the skeleton list
  33761. */
  33762. removeSkeleton(toRemove: Skeleton): number;
  33763. /**
  33764. * Remove a morph target for the list of scene's morph targets
  33765. * @param toRemove defines the morph target to remove
  33766. * @returns the index where the morph target was in the morph target list
  33767. */
  33768. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33769. /**
  33770. * Remove a light for the list of scene's lights
  33771. * @param toRemove defines the light to remove
  33772. * @returns the index where the light was in the light list
  33773. */
  33774. removeLight(toRemove: Light): number;
  33775. /**
  33776. * Remove a camera for the list of scene's cameras
  33777. * @param toRemove defines the camera to remove
  33778. * @returns the index where the camera was in the camera list
  33779. */
  33780. removeCamera(toRemove: Camera): number;
  33781. /**
  33782. * Remove a particle system for the list of scene's particle systems
  33783. * @param toRemove defines the particle system to remove
  33784. * @returns the index where the particle system was in the particle system list
  33785. */
  33786. removeParticleSystem(toRemove: IParticleSystem): number;
  33787. /**
  33788. * Remove a animation for the list of scene's animations
  33789. * @param toRemove defines the animation to remove
  33790. * @returns the index where the animation was in the animation list
  33791. */
  33792. removeAnimation(toRemove: Animation): number;
  33793. /**
  33794. * Will stop the animation of the given target
  33795. * @param target - the target
  33796. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33797. * @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)
  33798. */
  33799. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33800. /**
  33801. * Removes the given animation group from this scene.
  33802. * @param toRemove The animation group to remove
  33803. * @returns The index of the removed animation group
  33804. */
  33805. removeAnimationGroup(toRemove: AnimationGroup): number;
  33806. /**
  33807. * Removes the given multi-material from this scene.
  33808. * @param toRemove The multi-material to remove
  33809. * @returns The index of the removed multi-material
  33810. */
  33811. removeMultiMaterial(toRemove: MultiMaterial): number;
  33812. /**
  33813. * Removes the given material from this scene.
  33814. * @param toRemove The material to remove
  33815. * @returns The index of the removed material
  33816. */
  33817. removeMaterial(toRemove: Material): number;
  33818. /**
  33819. * Removes the given action manager from this scene.
  33820. * @param toRemove The action manager to remove
  33821. * @returns The index of the removed action manager
  33822. */
  33823. removeActionManager(toRemove: AbstractActionManager): number;
  33824. /**
  33825. * Removes the given texture from this scene.
  33826. * @param toRemove The texture to remove
  33827. * @returns The index of the removed texture
  33828. */
  33829. removeTexture(toRemove: BaseTexture): number;
  33830. /**
  33831. * Adds the given light to this scene
  33832. * @param newLight The light to add
  33833. */
  33834. addLight(newLight: Light): void;
  33835. /**
  33836. * Sorts the list list based on light priorities
  33837. */
  33838. sortLightsByPriority(): void;
  33839. /**
  33840. * Adds the given camera to this scene
  33841. * @param newCamera The camera to add
  33842. */
  33843. addCamera(newCamera: Camera): void;
  33844. /**
  33845. * Adds the given skeleton to this scene
  33846. * @param newSkeleton The skeleton to add
  33847. */
  33848. addSkeleton(newSkeleton: Skeleton): void;
  33849. /**
  33850. * Adds the given particle system to this scene
  33851. * @param newParticleSystem The particle system to add
  33852. */
  33853. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33854. /**
  33855. * Adds the given animation to this scene
  33856. * @param newAnimation The animation to add
  33857. */
  33858. addAnimation(newAnimation: Animation): void;
  33859. /**
  33860. * Adds the given animation group to this scene.
  33861. * @param newAnimationGroup The animation group to add
  33862. */
  33863. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33864. /**
  33865. * Adds the given multi-material to this scene
  33866. * @param newMultiMaterial The multi-material to add
  33867. */
  33868. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33869. /**
  33870. * Adds the given material to this scene
  33871. * @param newMaterial The material to add
  33872. */
  33873. addMaterial(newMaterial: Material): void;
  33874. /**
  33875. * Adds the given morph target to this scene
  33876. * @param newMorphTargetManager The morph target to add
  33877. */
  33878. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33879. /**
  33880. * Adds the given geometry to this scene
  33881. * @param newGeometry The geometry to add
  33882. */
  33883. addGeometry(newGeometry: Geometry): void;
  33884. /**
  33885. * Adds the given action manager to this scene
  33886. * @param newActionManager The action manager to add
  33887. */
  33888. addActionManager(newActionManager: AbstractActionManager): void;
  33889. /**
  33890. * Adds the given texture to this scene.
  33891. * @param newTexture The texture to add
  33892. */
  33893. addTexture(newTexture: BaseTexture): void;
  33894. /**
  33895. * Switch active camera
  33896. * @param newCamera defines the new active camera
  33897. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33898. */
  33899. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33900. /**
  33901. * sets the active camera of the scene using its ID
  33902. * @param id defines the camera's ID
  33903. * @return the new active camera or null if none found.
  33904. */
  33905. setActiveCameraByID(id: string): Nullable<Camera>;
  33906. /**
  33907. * sets the active camera of the scene using its name
  33908. * @param name defines the camera's name
  33909. * @returns the new active camera or null if none found.
  33910. */
  33911. setActiveCameraByName(name: string): Nullable<Camera>;
  33912. /**
  33913. * get an animation group using its name
  33914. * @param name defines the material's name
  33915. * @return the animation group or null if none found.
  33916. */
  33917. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33918. /**
  33919. * Get a material using its unique id
  33920. * @param uniqueId defines the material's unique id
  33921. * @return the material or null if none found.
  33922. */
  33923. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33924. /**
  33925. * get a material using its id
  33926. * @param id defines the material's ID
  33927. * @return the material or null if none found.
  33928. */
  33929. getMaterialByID(id: string): Nullable<Material>;
  33930. /**
  33931. * Gets a the last added material using a given id
  33932. * @param id defines the material's ID
  33933. * @return the last material with the given id or null if none found.
  33934. */
  33935. getLastMaterialByID(id: string): Nullable<Material>;
  33936. /**
  33937. * Gets a material using its name
  33938. * @param name defines the material's name
  33939. * @return the material or null if none found.
  33940. */
  33941. getMaterialByName(name: string): Nullable<Material>;
  33942. /**
  33943. * Get a texture using its unique id
  33944. * @param uniqueId defines the texture's unique id
  33945. * @return the texture or null if none found.
  33946. */
  33947. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  33948. /**
  33949. * Gets a camera using its id
  33950. * @param id defines the id to look for
  33951. * @returns the camera or null if not found
  33952. */
  33953. getCameraByID(id: string): Nullable<Camera>;
  33954. /**
  33955. * Gets a camera using its unique id
  33956. * @param uniqueId defines the unique id to look for
  33957. * @returns the camera or null if not found
  33958. */
  33959. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33960. /**
  33961. * Gets a camera using its name
  33962. * @param name defines the camera's name
  33963. * @return the camera or null if none found.
  33964. */
  33965. getCameraByName(name: string): Nullable<Camera>;
  33966. /**
  33967. * Gets a bone using its id
  33968. * @param id defines the bone's id
  33969. * @return the bone or null if not found
  33970. */
  33971. getBoneByID(id: string): Nullable<Bone>;
  33972. /**
  33973. * Gets a bone using its id
  33974. * @param name defines the bone's name
  33975. * @return the bone or null if not found
  33976. */
  33977. getBoneByName(name: string): Nullable<Bone>;
  33978. /**
  33979. * Gets a light node using its name
  33980. * @param name defines the the light's name
  33981. * @return the light or null if none found.
  33982. */
  33983. getLightByName(name: string): Nullable<Light>;
  33984. /**
  33985. * Gets a light node using its id
  33986. * @param id defines the light's id
  33987. * @return the light or null if none found.
  33988. */
  33989. getLightByID(id: string): Nullable<Light>;
  33990. /**
  33991. * Gets a light node using its scene-generated unique ID
  33992. * @param uniqueId defines the light's unique id
  33993. * @return the light or null if none found.
  33994. */
  33995. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33996. /**
  33997. * Gets a particle system by id
  33998. * @param id defines the particle system id
  33999. * @return the corresponding system or null if none found
  34000. */
  34001. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34002. /**
  34003. * Gets a geometry using its ID
  34004. * @param id defines the geometry's id
  34005. * @return the geometry or null if none found.
  34006. */
  34007. getGeometryByID(id: string): Nullable<Geometry>;
  34008. private _getGeometryByUniqueID;
  34009. /**
  34010. * Add a new geometry to this scene
  34011. * @param geometry defines the geometry to be added to the scene.
  34012. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34013. * @return a boolean defining if the geometry was added or not
  34014. */
  34015. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34016. /**
  34017. * Removes an existing geometry
  34018. * @param geometry defines the geometry to be removed from the scene
  34019. * @return a boolean defining if the geometry was removed or not
  34020. */
  34021. removeGeometry(geometry: Geometry): boolean;
  34022. /**
  34023. * Gets the list of geometries attached to the scene
  34024. * @returns an array of Geometry
  34025. */
  34026. getGeometries(): Geometry[];
  34027. /**
  34028. * Gets the first added mesh found of a given ID
  34029. * @param id defines the id to search for
  34030. * @return the mesh found or null if not found at all
  34031. */
  34032. getMeshByID(id: string): Nullable<AbstractMesh>;
  34033. /**
  34034. * Gets a list of meshes using their id
  34035. * @param id defines the id to search for
  34036. * @returns a list of meshes
  34037. */
  34038. getMeshesByID(id: string): Array<AbstractMesh>;
  34039. /**
  34040. * Gets the first added transform node found of a given ID
  34041. * @param id defines the id to search for
  34042. * @return the found transform node or null if not found at all.
  34043. */
  34044. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34045. /**
  34046. * Gets a transform node with its auto-generated unique id
  34047. * @param uniqueId efines the unique id to search for
  34048. * @return the found transform node or null if not found at all.
  34049. */
  34050. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34051. /**
  34052. * Gets a list of transform nodes using their id
  34053. * @param id defines the id to search for
  34054. * @returns a list of transform nodes
  34055. */
  34056. getTransformNodesByID(id: string): Array<TransformNode>;
  34057. /**
  34058. * Gets a mesh with its auto-generated unique id
  34059. * @param uniqueId defines the unique id to search for
  34060. * @return the found mesh or null if not found at all.
  34061. */
  34062. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34063. /**
  34064. * Gets a the last added mesh using a given id
  34065. * @param id defines the id to search for
  34066. * @return the found mesh or null if not found at all.
  34067. */
  34068. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34069. /**
  34070. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34071. * @param id defines the id to search for
  34072. * @return the found node or null if not found at all
  34073. */
  34074. getLastEntryByID(id: string): Nullable<Node>;
  34075. /**
  34076. * Gets a node (Mesh, Camera, Light) using a given id
  34077. * @param id defines the id to search for
  34078. * @return the found node or null if not found at all
  34079. */
  34080. getNodeByID(id: string): Nullable<Node>;
  34081. /**
  34082. * Gets a node (Mesh, Camera, Light) using a given name
  34083. * @param name defines the name to search for
  34084. * @return the found node or null if not found at all.
  34085. */
  34086. getNodeByName(name: string): Nullable<Node>;
  34087. /**
  34088. * Gets a mesh using a given name
  34089. * @param name defines the name to search for
  34090. * @return the found mesh or null if not found at all.
  34091. */
  34092. getMeshByName(name: string): Nullable<AbstractMesh>;
  34093. /**
  34094. * Gets a transform node using a given name
  34095. * @param name defines the name to search for
  34096. * @return the found transform node or null if not found at all.
  34097. */
  34098. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34099. /**
  34100. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34101. * @param id defines the id to search for
  34102. * @return the found skeleton or null if not found at all.
  34103. */
  34104. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34105. /**
  34106. * Gets a skeleton using a given auto generated unique id
  34107. * @param uniqueId defines the unique id to search for
  34108. * @return the found skeleton or null if not found at all.
  34109. */
  34110. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34111. /**
  34112. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34113. * @param id defines the id to search for
  34114. * @return the found skeleton or null if not found at all.
  34115. */
  34116. getSkeletonById(id: string): Nullable<Skeleton>;
  34117. /**
  34118. * Gets a skeleton using a given name
  34119. * @param name defines the name to search for
  34120. * @return the found skeleton or null if not found at all.
  34121. */
  34122. getSkeletonByName(name: string): Nullable<Skeleton>;
  34123. /**
  34124. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34125. * @param id defines the id to search for
  34126. * @return the found morph target manager or null if not found at all.
  34127. */
  34128. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34129. /**
  34130. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34131. * @param id defines the id to search for
  34132. * @return the found morph target or null if not found at all.
  34133. */
  34134. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34135. /**
  34136. * Gets a boolean indicating if the given mesh is active
  34137. * @param mesh defines the mesh to look for
  34138. * @returns true if the mesh is in the active list
  34139. */
  34140. isActiveMesh(mesh: AbstractMesh): boolean;
  34141. /**
  34142. * Return a unique id as a string which can serve as an identifier for the scene
  34143. */
  34144. readonly uid: string;
  34145. /**
  34146. * Add an externaly attached data from its key.
  34147. * This method call will fail and return false, if such key already exists.
  34148. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34149. * @param key the unique key that identifies the data
  34150. * @param data the data object to associate to the key for this Engine instance
  34151. * @return true if no such key were already present and the data was added successfully, false otherwise
  34152. */
  34153. addExternalData<T>(key: string, data: T): boolean;
  34154. /**
  34155. * Get an externaly attached data from its key
  34156. * @param key the unique key that identifies the data
  34157. * @return the associated data, if present (can be null), or undefined if not present
  34158. */
  34159. getExternalData<T>(key: string): Nullable<T>;
  34160. /**
  34161. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34162. * @param key the unique key that identifies the data
  34163. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34164. * @return the associated data, can be null if the factory returned null.
  34165. */
  34166. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34167. /**
  34168. * Remove an externaly attached data from the Engine instance
  34169. * @param key the unique key that identifies the data
  34170. * @return true if the data was successfully removed, false if it doesn't exist
  34171. */
  34172. removeExternalData(key: string): boolean;
  34173. private _evaluateSubMesh;
  34174. /**
  34175. * Clear the processed materials smart array preventing retention point in material dispose.
  34176. */
  34177. freeProcessedMaterials(): void;
  34178. private _preventFreeActiveMeshesAndRenderingGroups;
  34179. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34180. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34181. * when disposing several meshes in a row or a hierarchy of meshes.
  34182. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34183. */
  34184. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34185. /**
  34186. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34187. */
  34188. freeActiveMeshes(): void;
  34189. /**
  34190. * Clear the info related to rendering groups preventing retention points during dispose.
  34191. */
  34192. freeRenderingGroups(): void;
  34193. /** @hidden */
  34194. _isInIntermediateRendering(): boolean;
  34195. /**
  34196. * Lambda returning the list of potentially active meshes.
  34197. */
  34198. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34199. /**
  34200. * Lambda returning the list of potentially active sub meshes.
  34201. */
  34202. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34203. /**
  34204. * Lambda returning the list of potentially intersecting sub meshes.
  34205. */
  34206. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34207. /**
  34208. * Lambda returning the list of potentially colliding sub meshes.
  34209. */
  34210. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34211. private _activeMeshesFrozen;
  34212. /**
  34213. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34214. * @returns the current scene
  34215. */
  34216. freezeActiveMeshes(): Scene;
  34217. /**
  34218. * Use this function to restart evaluating active meshes on every frame
  34219. * @returns the current scene
  34220. */
  34221. unfreezeActiveMeshes(): Scene;
  34222. private _evaluateActiveMeshes;
  34223. private _activeMesh;
  34224. /**
  34225. * Update the transform matrix to update from the current active camera
  34226. * @param force defines a boolean used to force the update even if cache is up to date
  34227. */
  34228. updateTransformMatrix(force?: boolean): void;
  34229. private _bindFrameBuffer;
  34230. /** @hidden */
  34231. _allowPostProcessClearColor: boolean;
  34232. /** @hidden */
  34233. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34234. private _processSubCameras;
  34235. private _checkIntersections;
  34236. /** @hidden */
  34237. _advancePhysicsEngineStep(step: number): void;
  34238. /**
  34239. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34240. */
  34241. getDeterministicFrameTime: () => number;
  34242. /** @hidden */
  34243. _animate(): void;
  34244. /** Execute all animations (for a frame) */
  34245. animate(): void;
  34246. /**
  34247. * Render the scene
  34248. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34249. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34250. */
  34251. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34252. /**
  34253. * Freeze all materials
  34254. * A frozen material will not be updatable but should be faster to render
  34255. */
  34256. freezeMaterials(): void;
  34257. /**
  34258. * Unfreeze all materials
  34259. * A frozen material will not be updatable but should be faster to render
  34260. */
  34261. unfreezeMaterials(): void;
  34262. /**
  34263. * Releases all held ressources
  34264. */
  34265. dispose(): void;
  34266. /**
  34267. * Gets if the scene is already disposed
  34268. */
  34269. readonly isDisposed: boolean;
  34270. /**
  34271. * Call this function to reduce memory footprint of the scene.
  34272. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34273. */
  34274. clearCachedVertexData(): void;
  34275. /**
  34276. * This function will remove the local cached buffer data from texture.
  34277. * It will save memory but will prevent the texture from being rebuilt
  34278. */
  34279. cleanCachedTextureBuffer(): void;
  34280. /**
  34281. * Get the world extend vectors with an optional filter
  34282. *
  34283. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34284. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34285. */
  34286. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34287. min: Vector3;
  34288. max: Vector3;
  34289. };
  34290. /**
  34291. * Creates a ray that can be used to pick in the scene
  34292. * @param x defines the x coordinate of the origin (on-screen)
  34293. * @param y defines the y coordinate of the origin (on-screen)
  34294. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34295. * @param camera defines the camera to use for the picking
  34296. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34297. * @returns a Ray
  34298. */
  34299. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34300. /**
  34301. * Creates a ray that can be used to pick in the scene
  34302. * @param x defines the x coordinate of the origin (on-screen)
  34303. * @param y defines the y coordinate of the origin (on-screen)
  34304. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34305. * @param result defines the ray where to store the picking ray
  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 the current scene
  34309. */
  34310. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  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 camera defines the camera to use for the picking
  34316. * @returns a Ray
  34317. */
  34318. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34319. /**
  34320. * Creates a ray that can be used to pick in the scene
  34321. * @param x defines the x coordinate of the origin (on-screen)
  34322. * @param y defines the y coordinate of the origin (on-screen)
  34323. * @param result defines the ray where to store the picking ray
  34324. * @param camera defines the camera to use for the picking
  34325. * @returns the current scene
  34326. */
  34327. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34328. /** Launch a ray to try to pick a mesh in the scene
  34329. * @param x position on screen
  34330. * @param y position on screen
  34331. * @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
  34332. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34333. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34334. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34335. * @returns a PickingInfo
  34336. */
  34337. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34338. /** Use the given ray to pick a mesh in the scene
  34339. * @param ray The ray to use to pick meshes
  34340. * @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
  34341. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34342. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34343. * @returns a PickingInfo
  34344. */
  34345. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34346. /**
  34347. * Launch a ray to try to pick a mesh in the scene
  34348. * @param x X position on screen
  34349. * @param y Y position on screen
  34350. * @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
  34351. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34352. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34353. * @returns an array of PickingInfo
  34354. */
  34355. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34356. /**
  34357. * Launch a ray to try to pick a mesh in the scene
  34358. * @param ray Ray to use
  34359. * @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
  34360. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34361. * @returns an array of PickingInfo
  34362. */
  34363. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34364. /**
  34365. * Force the value of meshUnderPointer
  34366. * @param mesh defines the mesh to use
  34367. */
  34368. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34369. /**
  34370. * Gets the mesh under the pointer
  34371. * @returns a Mesh or null if no mesh is under the pointer
  34372. */
  34373. getPointerOverMesh(): Nullable<AbstractMesh>;
  34374. /** @hidden */
  34375. _rebuildGeometries(): void;
  34376. /** @hidden */
  34377. _rebuildTextures(): void;
  34378. private _getByTags;
  34379. /**
  34380. * Get a list of meshes by tags
  34381. * @param tagsQuery defines the tags query to use
  34382. * @param forEach defines a predicate used to filter results
  34383. * @returns an array of Mesh
  34384. */
  34385. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34386. /**
  34387. * Get a list of cameras by tags
  34388. * @param tagsQuery defines the tags query to use
  34389. * @param forEach defines a predicate used to filter results
  34390. * @returns an array of Camera
  34391. */
  34392. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34393. /**
  34394. * Get a list of lights by tags
  34395. * @param tagsQuery defines the tags query to use
  34396. * @param forEach defines a predicate used to filter results
  34397. * @returns an array of Light
  34398. */
  34399. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34400. /**
  34401. * Get a list of materials by tags
  34402. * @param tagsQuery defines the tags query to use
  34403. * @param forEach defines a predicate used to filter results
  34404. * @returns an array of Material
  34405. */
  34406. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34407. /**
  34408. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34409. * This allowed control for front to back rendering or reversly depending of the special needs.
  34410. *
  34411. * @param renderingGroupId The rendering group id corresponding to its index
  34412. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34413. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34414. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34415. */
  34416. 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;
  34417. /**
  34418. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34419. *
  34420. * @param renderingGroupId The rendering group id corresponding to its index
  34421. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34422. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34423. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34424. */
  34425. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34426. /**
  34427. * Gets the current auto clear configuration for one rendering group of the rendering
  34428. * manager.
  34429. * @param index the rendering group index to get the information for
  34430. * @returns The auto clear setup for the requested rendering group
  34431. */
  34432. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34433. private _blockMaterialDirtyMechanism;
  34434. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34435. blockMaterialDirtyMechanism: boolean;
  34436. /**
  34437. * Will flag all materials as dirty to trigger new shader compilation
  34438. * @param flag defines the flag used to specify which material part must be marked as dirty
  34439. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34440. */
  34441. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34442. /** @hidden */
  34443. _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;
  34444. /** @hidden */
  34445. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34446. }
  34447. }
  34448. declare module BABYLON {
  34449. /**
  34450. * Set of assets to keep when moving a scene into an asset container.
  34451. */
  34452. export class KeepAssets extends AbstractScene {
  34453. }
  34454. /**
  34455. * Container with a set of assets that can be added or removed from a scene.
  34456. */
  34457. export class AssetContainer extends AbstractScene {
  34458. /**
  34459. * The scene the AssetContainer belongs to.
  34460. */
  34461. scene: Scene;
  34462. /**
  34463. * Instantiates an AssetContainer.
  34464. * @param scene The scene the AssetContainer belongs to.
  34465. */
  34466. constructor(scene: Scene);
  34467. /**
  34468. * Adds all the assets from the container to the scene.
  34469. */
  34470. addAllToScene(): void;
  34471. /**
  34472. * Removes all the assets in the container from the scene
  34473. */
  34474. removeAllFromScene(): void;
  34475. /**
  34476. * Disposes all the assets in the container
  34477. */
  34478. dispose(): void;
  34479. private _moveAssets;
  34480. /**
  34481. * Removes all the assets contained in the scene and adds them to the container.
  34482. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34483. */
  34484. moveAllFromScene(keepAssets?: KeepAssets): void;
  34485. /**
  34486. * 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.
  34487. * @returns the root mesh
  34488. */
  34489. createRootMesh(): Mesh;
  34490. }
  34491. }
  34492. declare module BABYLON {
  34493. /**
  34494. * Defines how the parser contract is defined.
  34495. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34496. */
  34497. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34498. /**
  34499. * Defines how the individual parser contract is defined.
  34500. * These parser can parse an individual asset
  34501. */
  34502. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34503. /**
  34504. * Base class of the scene acting as a container for the different elements composing a scene.
  34505. * This class is dynamically extended by the different components of the scene increasing
  34506. * flexibility and reducing coupling
  34507. */
  34508. export abstract class AbstractScene {
  34509. /**
  34510. * Stores the list of available parsers in the application.
  34511. */
  34512. private static _BabylonFileParsers;
  34513. /**
  34514. * Stores the list of available individual parsers in the application.
  34515. */
  34516. private static _IndividualBabylonFileParsers;
  34517. /**
  34518. * Adds a parser in the list of available ones
  34519. * @param name Defines the name of the parser
  34520. * @param parser Defines the parser to add
  34521. */
  34522. static AddParser(name: string, parser: BabylonFileParser): void;
  34523. /**
  34524. * Gets a general parser from the list of avaialble ones
  34525. * @param name Defines the name of the parser
  34526. * @returns the requested parser or null
  34527. */
  34528. static GetParser(name: string): Nullable<BabylonFileParser>;
  34529. /**
  34530. * Adds n individual parser in the list of available ones
  34531. * @param name Defines the name of the parser
  34532. * @param parser Defines the parser to add
  34533. */
  34534. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34535. /**
  34536. * Gets an individual parser from the list of avaialble ones
  34537. * @param name Defines the name of the parser
  34538. * @returns the requested parser or null
  34539. */
  34540. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34541. /**
  34542. * Parser json data and populate both a scene and its associated container object
  34543. * @param jsonData Defines the data to parse
  34544. * @param scene Defines the scene to parse the data for
  34545. * @param container Defines the container attached to the parsing sequence
  34546. * @param rootUrl Defines the root url of the data
  34547. */
  34548. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34549. /**
  34550. * Gets the list of root nodes (ie. nodes with no parent)
  34551. */
  34552. rootNodes: Node[];
  34553. /** All of the cameras added to this scene
  34554. * @see http://doc.babylonjs.com/babylon101/cameras
  34555. */
  34556. cameras: Camera[];
  34557. /**
  34558. * All of the lights added to this scene
  34559. * @see http://doc.babylonjs.com/babylon101/lights
  34560. */
  34561. lights: Light[];
  34562. /**
  34563. * All of the (abstract) meshes added to this scene
  34564. */
  34565. meshes: AbstractMesh[];
  34566. /**
  34567. * The list of skeletons added to the scene
  34568. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34569. */
  34570. skeletons: Skeleton[];
  34571. /**
  34572. * All of the particle systems added to this scene
  34573. * @see http://doc.babylonjs.com/babylon101/particles
  34574. */
  34575. particleSystems: IParticleSystem[];
  34576. /**
  34577. * Gets a list of Animations associated with the scene
  34578. */
  34579. animations: Animation[];
  34580. /**
  34581. * All of the animation groups added to this scene
  34582. * @see http://doc.babylonjs.com/how_to/group
  34583. */
  34584. animationGroups: AnimationGroup[];
  34585. /**
  34586. * All of the multi-materials added to this scene
  34587. * @see http://doc.babylonjs.com/how_to/multi_materials
  34588. */
  34589. multiMaterials: MultiMaterial[];
  34590. /**
  34591. * All of the materials added to this scene
  34592. * In the context of a Scene, it is not supposed to be modified manually.
  34593. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34594. * Note also that the order of the Material wihin the array is not significant and might change.
  34595. * @see http://doc.babylonjs.com/babylon101/materials
  34596. */
  34597. materials: Material[];
  34598. /**
  34599. * The list of morph target managers added to the scene
  34600. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34601. */
  34602. morphTargetManagers: MorphTargetManager[];
  34603. /**
  34604. * The list of geometries used in the scene.
  34605. */
  34606. geometries: Geometry[];
  34607. /**
  34608. * All of the tranform nodes added to this scene
  34609. * In the context of a Scene, it is not supposed to be modified manually.
  34610. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34611. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34612. * @see http://doc.babylonjs.com/how_to/transformnode
  34613. */
  34614. transformNodes: TransformNode[];
  34615. /**
  34616. * ActionManagers available on the scene.
  34617. */
  34618. actionManagers: AbstractActionManager[];
  34619. /**
  34620. * Textures to keep.
  34621. */
  34622. textures: BaseTexture[];
  34623. /**
  34624. * Environment texture for the scene
  34625. */
  34626. environmentTexture: Nullable<BaseTexture>;
  34627. }
  34628. }
  34629. declare module BABYLON {
  34630. /**
  34631. * Interface used to define options for Sound class
  34632. */
  34633. export interface ISoundOptions {
  34634. /**
  34635. * Does the sound autoplay once loaded.
  34636. */
  34637. autoplay?: boolean;
  34638. /**
  34639. * Does the sound loop after it finishes playing once.
  34640. */
  34641. loop?: boolean;
  34642. /**
  34643. * Sound's volume
  34644. */
  34645. volume?: number;
  34646. /**
  34647. * Is it a spatial sound?
  34648. */
  34649. spatialSound?: boolean;
  34650. /**
  34651. * Maximum distance to hear that sound
  34652. */
  34653. maxDistance?: number;
  34654. /**
  34655. * Uses user defined attenuation function
  34656. */
  34657. useCustomAttenuation?: boolean;
  34658. /**
  34659. * Define the roll off factor of spatial sounds.
  34660. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34661. */
  34662. rolloffFactor?: number;
  34663. /**
  34664. * Define the reference distance the sound should be heard perfectly.
  34665. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34666. */
  34667. refDistance?: number;
  34668. /**
  34669. * Define the distance attenuation model the sound will follow.
  34670. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34671. */
  34672. distanceModel?: string;
  34673. /**
  34674. * Defines the playback speed (1 by default)
  34675. */
  34676. playbackRate?: number;
  34677. /**
  34678. * Defines if the sound is from a streaming source
  34679. */
  34680. streaming?: boolean;
  34681. /**
  34682. * Defines an optional length (in seconds) inside the sound file
  34683. */
  34684. length?: number;
  34685. /**
  34686. * Defines an optional offset (in seconds) inside the sound file
  34687. */
  34688. offset?: number;
  34689. /**
  34690. * If true, URLs will not be required to state the audio file codec to use.
  34691. */
  34692. skipCodecCheck?: boolean;
  34693. }
  34694. /**
  34695. * Defines a sound that can be played in the application.
  34696. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34697. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34698. */
  34699. export class Sound {
  34700. /**
  34701. * The name of the sound in the scene.
  34702. */
  34703. name: string;
  34704. /**
  34705. * Does the sound autoplay once loaded.
  34706. */
  34707. autoplay: boolean;
  34708. /**
  34709. * Does the sound loop after it finishes playing once.
  34710. */
  34711. loop: boolean;
  34712. /**
  34713. * Does the sound use a custom attenuation curve to simulate the falloff
  34714. * happening when the source gets further away from the camera.
  34715. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34716. */
  34717. useCustomAttenuation: boolean;
  34718. /**
  34719. * The sound track id this sound belongs to.
  34720. */
  34721. soundTrackId: number;
  34722. /**
  34723. * Is this sound currently played.
  34724. */
  34725. isPlaying: boolean;
  34726. /**
  34727. * Is this sound currently paused.
  34728. */
  34729. isPaused: boolean;
  34730. /**
  34731. * Does this sound enables spatial sound.
  34732. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34733. */
  34734. spatialSound: boolean;
  34735. /**
  34736. * Define the reference distance the sound should be heard perfectly.
  34737. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34738. */
  34739. refDistance: number;
  34740. /**
  34741. * Define the roll off factor of spatial sounds.
  34742. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34743. */
  34744. rolloffFactor: number;
  34745. /**
  34746. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34747. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34748. */
  34749. maxDistance: number;
  34750. /**
  34751. * Define the distance attenuation model the sound will follow.
  34752. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34753. */
  34754. distanceModel: string;
  34755. /**
  34756. * @hidden
  34757. * Back Compat
  34758. **/
  34759. onended: () => any;
  34760. /**
  34761. * Observable event when the current playing sound finishes.
  34762. */
  34763. onEndedObservable: Observable<Sound>;
  34764. private _panningModel;
  34765. private _playbackRate;
  34766. private _streaming;
  34767. private _startTime;
  34768. private _startOffset;
  34769. private _position;
  34770. /** @hidden */
  34771. _positionInEmitterSpace: boolean;
  34772. private _localDirection;
  34773. private _volume;
  34774. private _isReadyToPlay;
  34775. private _isDirectional;
  34776. private _readyToPlayCallback;
  34777. private _audioBuffer;
  34778. private _soundSource;
  34779. private _streamingSource;
  34780. private _soundPanner;
  34781. private _soundGain;
  34782. private _inputAudioNode;
  34783. private _outputAudioNode;
  34784. private _coneInnerAngle;
  34785. private _coneOuterAngle;
  34786. private _coneOuterGain;
  34787. private _scene;
  34788. private _connectedTransformNode;
  34789. private _customAttenuationFunction;
  34790. private _registerFunc;
  34791. private _isOutputConnected;
  34792. private _htmlAudioElement;
  34793. private _urlType;
  34794. private _length?;
  34795. private _offset?;
  34796. /** @hidden */
  34797. static _SceneComponentInitialization: (scene: Scene) => void;
  34798. /**
  34799. * Create a sound and attach it to a scene
  34800. * @param name Name of your sound
  34801. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34802. * @param scene defines the scene the sound belongs to
  34803. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34804. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34805. */
  34806. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34807. /**
  34808. * Release the sound and its associated resources
  34809. */
  34810. dispose(): void;
  34811. /**
  34812. * Gets if the sounds is ready to be played or not.
  34813. * @returns true if ready, otherwise false
  34814. */
  34815. isReady(): boolean;
  34816. private _soundLoaded;
  34817. /**
  34818. * Sets the data of the sound from an audiobuffer
  34819. * @param audioBuffer The audioBuffer containing the data
  34820. */
  34821. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34822. /**
  34823. * Updates the current sounds options such as maxdistance, loop...
  34824. * @param options A JSON object containing values named as the object properties
  34825. */
  34826. updateOptions(options: ISoundOptions): void;
  34827. private _createSpatialParameters;
  34828. private _updateSpatialParameters;
  34829. /**
  34830. * Switch the panning model to HRTF:
  34831. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34832. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34833. */
  34834. switchPanningModelToHRTF(): void;
  34835. /**
  34836. * Switch the panning model to Equal Power:
  34837. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34838. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34839. */
  34840. switchPanningModelToEqualPower(): void;
  34841. private _switchPanningModel;
  34842. /**
  34843. * Connect this sound to a sound track audio node like gain...
  34844. * @param soundTrackAudioNode the sound track audio node to connect to
  34845. */
  34846. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34847. /**
  34848. * Transform this sound into a directional source
  34849. * @param coneInnerAngle Size of the inner cone in degree
  34850. * @param coneOuterAngle Size of the outer cone in degree
  34851. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34852. */
  34853. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34854. /**
  34855. * Gets or sets the inner angle for the directional cone.
  34856. */
  34857. /**
  34858. * Gets or sets the inner angle for the directional cone.
  34859. */
  34860. directionalConeInnerAngle: number;
  34861. /**
  34862. * Gets or sets the outer angle for the directional cone.
  34863. */
  34864. /**
  34865. * Gets or sets the outer angle for the directional cone.
  34866. */
  34867. directionalConeOuterAngle: number;
  34868. /**
  34869. * Sets the position of the emitter if spatial sound is enabled
  34870. * @param newPosition Defines the new posisiton
  34871. */
  34872. setPosition(newPosition: Vector3): void;
  34873. /**
  34874. * Sets the local direction of the emitter if spatial sound is enabled
  34875. * @param newLocalDirection Defines the new local direction
  34876. */
  34877. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34878. private _updateDirection;
  34879. /** @hidden */
  34880. updateDistanceFromListener(): void;
  34881. /**
  34882. * Sets a new custom attenuation function for the sound.
  34883. * @param callback Defines the function used for the attenuation
  34884. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34885. */
  34886. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34887. /**
  34888. * Play the sound
  34889. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34890. * @param offset (optional) Start the sound at a specific time in seconds
  34891. * @param length (optional) Sound duration (in seconds)
  34892. */
  34893. play(time?: number, offset?: number, length?: number): void;
  34894. private _onended;
  34895. /**
  34896. * Stop the sound
  34897. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34898. */
  34899. stop(time?: number): void;
  34900. /**
  34901. * Put the sound in pause
  34902. */
  34903. pause(): void;
  34904. /**
  34905. * Sets a dedicated volume for this sounds
  34906. * @param newVolume Define the new volume of the sound
  34907. * @param time Define time for gradual change to new volume
  34908. */
  34909. setVolume(newVolume: number, time?: number): void;
  34910. /**
  34911. * Set the sound play back rate
  34912. * @param newPlaybackRate Define the playback rate the sound should be played at
  34913. */
  34914. setPlaybackRate(newPlaybackRate: number): void;
  34915. /**
  34916. * Gets the volume of the sound.
  34917. * @returns the volume of the sound
  34918. */
  34919. getVolume(): number;
  34920. /**
  34921. * Attach the sound to a dedicated mesh
  34922. * @param transformNode The transform node to connect the sound with
  34923. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34924. */
  34925. attachToMesh(transformNode: TransformNode): void;
  34926. /**
  34927. * Detach the sound from the previously attached mesh
  34928. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34929. */
  34930. detachFromMesh(): void;
  34931. private _onRegisterAfterWorldMatrixUpdate;
  34932. /**
  34933. * Clone the current sound in the scene.
  34934. * @returns the new sound clone
  34935. */
  34936. clone(): Nullable<Sound>;
  34937. /**
  34938. * Gets the current underlying audio buffer containing the data
  34939. * @returns the audio buffer
  34940. */
  34941. getAudioBuffer(): Nullable<AudioBuffer>;
  34942. /**
  34943. * Serializes the Sound in a JSON representation
  34944. * @returns the JSON representation of the sound
  34945. */
  34946. serialize(): any;
  34947. /**
  34948. * Parse a JSON representation of a sound to innstantiate in a given scene
  34949. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34950. * @param scene Define the scene the new parsed sound should be created in
  34951. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34952. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34953. * @returns the newly parsed sound
  34954. */
  34955. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34956. }
  34957. }
  34958. declare module BABYLON {
  34959. /**
  34960. * This defines an action helpful to play a defined sound on a triggered action.
  34961. */
  34962. export class PlaySoundAction extends Action {
  34963. private _sound;
  34964. /**
  34965. * Instantiate the action
  34966. * @param triggerOptions defines the trigger options
  34967. * @param sound defines the sound to play
  34968. * @param condition defines the trigger related conditions
  34969. */
  34970. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34971. /** @hidden */
  34972. _prepare(): void;
  34973. /**
  34974. * Execute the action and play the sound.
  34975. */
  34976. execute(): void;
  34977. /**
  34978. * Serializes the actions and its related information.
  34979. * @param parent defines the object to serialize in
  34980. * @returns the serialized object
  34981. */
  34982. serialize(parent: any): any;
  34983. }
  34984. /**
  34985. * This defines an action helpful to stop a defined sound on a triggered action.
  34986. */
  34987. export class StopSoundAction extends Action {
  34988. private _sound;
  34989. /**
  34990. * Instantiate the action
  34991. * @param triggerOptions defines the trigger options
  34992. * @param sound defines the sound to stop
  34993. * @param condition defines the trigger related conditions
  34994. */
  34995. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34996. /** @hidden */
  34997. _prepare(): void;
  34998. /**
  34999. * Execute the action and stop the sound.
  35000. */
  35001. execute(): void;
  35002. /**
  35003. * Serializes the actions and its related information.
  35004. * @param parent defines the object to serialize in
  35005. * @returns the serialized object
  35006. */
  35007. serialize(parent: any): any;
  35008. }
  35009. }
  35010. declare module BABYLON {
  35011. /**
  35012. * This defines an action responsible to change the value of a property
  35013. * by interpolating between its current value and the newly set one once triggered.
  35014. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35015. */
  35016. export class InterpolateValueAction extends Action {
  35017. /**
  35018. * Defines the path of the property where the value should be interpolated
  35019. */
  35020. propertyPath: string;
  35021. /**
  35022. * Defines the target value at the end of the interpolation.
  35023. */
  35024. value: any;
  35025. /**
  35026. * Defines the time it will take for the property to interpolate to the value.
  35027. */
  35028. duration: number;
  35029. /**
  35030. * Defines if the other scene animations should be stopped when the action has been triggered
  35031. */
  35032. stopOtherAnimations?: boolean;
  35033. /**
  35034. * Defines a callback raised once the interpolation animation has been done.
  35035. */
  35036. onInterpolationDone?: () => void;
  35037. /**
  35038. * Observable triggered once the interpolation animation has been done.
  35039. */
  35040. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35041. private _target;
  35042. private _effectiveTarget;
  35043. private _property;
  35044. /**
  35045. * Instantiate the action
  35046. * @param triggerOptions defines the trigger options
  35047. * @param target defines the object containing the value to interpolate
  35048. * @param propertyPath defines the path to the property in the target object
  35049. * @param value defines the target value at the end of the interpolation
  35050. * @param duration deines the time it will take for the property to interpolate to the value.
  35051. * @param condition defines the trigger related conditions
  35052. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35053. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35054. */
  35055. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35056. /** @hidden */
  35057. _prepare(): void;
  35058. /**
  35059. * Execute the action starts the value interpolation.
  35060. */
  35061. execute(): void;
  35062. /**
  35063. * Serializes the actions and its related information.
  35064. * @param parent defines the object to serialize in
  35065. * @returns the serialized object
  35066. */
  35067. serialize(parent: any): any;
  35068. }
  35069. }
  35070. declare module BABYLON {
  35071. /**
  35072. * Options allowed during the creation of a sound track.
  35073. */
  35074. export interface ISoundTrackOptions {
  35075. /**
  35076. * The volume the sound track should take during creation
  35077. */
  35078. volume?: number;
  35079. /**
  35080. * Define if the sound track is the main sound track of the scene
  35081. */
  35082. mainTrack?: boolean;
  35083. }
  35084. /**
  35085. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35086. * It will be also used in a future release to apply effects on a specific track.
  35087. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35088. */
  35089. export class SoundTrack {
  35090. /**
  35091. * The unique identifier of the sound track in the scene.
  35092. */
  35093. id: number;
  35094. /**
  35095. * The list of sounds included in the sound track.
  35096. */
  35097. soundCollection: Array<Sound>;
  35098. private _outputAudioNode;
  35099. private _scene;
  35100. private _isMainTrack;
  35101. private _connectedAnalyser;
  35102. private _options;
  35103. private _isInitialized;
  35104. /**
  35105. * Creates a new sound track.
  35106. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35107. * @param scene Define the scene the sound track belongs to
  35108. * @param options
  35109. */
  35110. constructor(scene: Scene, options?: ISoundTrackOptions);
  35111. private _initializeSoundTrackAudioGraph;
  35112. /**
  35113. * Release the sound track and its associated resources
  35114. */
  35115. dispose(): void;
  35116. /**
  35117. * Adds a sound to this sound track
  35118. * @param sound define the cound to add
  35119. * @ignoreNaming
  35120. */
  35121. AddSound(sound: Sound): void;
  35122. /**
  35123. * Removes a sound to this sound track
  35124. * @param sound define the cound to remove
  35125. * @ignoreNaming
  35126. */
  35127. RemoveSound(sound: Sound): void;
  35128. /**
  35129. * Set a global volume for the full sound track.
  35130. * @param newVolume Define the new volume of the sound track
  35131. */
  35132. setVolume(newVolume: number): void;
  35133. /**
  35134. * Switch the panning model to HRTF:
  35135. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35136. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35137. */
  35138. switchPanningModelToHRTF(): void;
  35139. /**
  35140. * Switch the panning model to Equal Power:
  35141. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35142. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35143. */
  35144. switchPanningModelToEqualPower(): void;
  35145. /**
  35146. * Connect the sound track to an audio analyser allowing some amazing
  35147. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35148. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35149. * @param analyser The analyser to connect to the engine
  35150. */
  35151. connectToAnalyser(analyser: Analyser): void;
  35152. }
  35153. }
  35154. declare module BABYLON {
  35155. interface AbstractScene {
  35156. /**
  35157. * The list of sounds used in the scene.
  35158. */
  35159. sounds: Nullable<Array<Sound>>;
  35160. }
  35161. interface Scene {
  35162. /**
  35163. * @hidden
  35164. * Backing field
  35165. */
  35166. _mainSoundTrack: SoundTrack;
  35167. /**
  35168. * The main sound track played by the scene.
  35169. * It cotains your primary collection of sounds.
  35170. */
  35171. mainSoundTrack: SoundTrack;
  35172. /**
  35173. * The list of sound tracks added to the scene
  35174. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35175. */
  35176. soundTracks: Nullable<Array<SoundTrack>>;
  35177. /**
  35178. * Gets a sound using a given name
  35179. * @param name defines the name to search for
  35180. * @return the found sound or null if not found at all.
  35181. */
  35182. getSoundByName(name: string): Nullable<Sound>;
  35183. /**
  35184. * Gets or sets if audio support is enabled
  35185. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35186. */
  35187. audioEnabled: boolean;
  35188. /**
  35189. * Gets or sets if audio will be output to headphones
  35190. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35191. */
  35192. headphone: boolean;
  35193. }
  35194. /**
  35195. * Defines the sound scene component responsible to manage any sounds
  35196. * in a given scene.
  35197. */
  35198. export class AudioSceneComponent implements ISceneSerializableComponent {
  35199. /**
  35200. * The component name helpfull to identify the component in the list of scene components.
  35201. */
  35202. readonly name: string;
  35203. /**
  35204. * The scene the component belongs to.
  35205. */
  35206. scene: Scene;
  35207. private _audioEnabled;
  35208. /**
  35209. * Gets whether audio is enabled or not.
  35210. * Please use related enable/disable method to switch state.
  35211. */
  35212. readonly audioEnabled: boolean;
  35213. private _headphone;
  35214. /**
  35215. * Gets whether audio is outputing to headphone or not.
  35216. * Please use the according Switch methods to change output.
  35217. */
  35218. readonly headphone: boolean;
  35219. /**
  35220. * Creates a new instance of the component for the given scene
  35221. * @param scene Defines the scene to register the component in
  35222. */
  35223. constructor(scene: Scene);
  35224. /**
  35225. * Registers the component in a given scene
  35226. */
  35227. register(): void;
  35228. /**
  35229. * Rebuilds the elements related to this component in case of
  35230. * context lost for instance.
  35231. */
  35232. rebuild(): void;
  35233. /**
  35234. * Serializes the component data to the specified json object
  35235. * @param serializationObject The object to serialize to
  35236. */
  35237. serialize(serializationObject: any): void;
  35238. /**
  35239. * Adds all the elements from the container to the scene
  35240. * @param container the container holding the elements
  35241. */
  35242. addFromContainer(container: AbstractScene): void;
  35243. /**
  35244. * Removes all the elements in the container from the scene
  35245. * @param container contains the elements to remove
  35246. * @param dispose if the removed element should be disposed (default: false)
  35247. */
  35248. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35249. /**
  35250. * Disposes the component and the associated ressources.
  35251. */
  35252. dispose(): void;
  35253. /**
  35254. * Disables audio in the associated scene.
  35255. */
  35256. disableAudio(): void;
  35257. /**
  35258. * Enables audio in the associated scene.
  35259. */
  35260. enableAudio(): void;
  35261. /**
  35262. * Switch audio to headphone output.
  35263. */
  35264. switchAudioModeForHeadphones(): void;
  35265. /**
  35266. * Switch audio to normal speakers.
  35267. */
  35268. switchAudioModeForNormalSpeakers(): void;
  35269. private _afterRender;
  35270. }
  35271. }
  35272. declare module BABYLON {
  35273. /**
  35274. * Wraps one or more Sound objects and selects one with random weight for playback.
  35275. */
  35276. export class WeightedSound {
  35277. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35278. loop: boolean;
  35279. private _coneInnerAngle;
  35280. private _coneOuterAngle;
  35281. private _volume;
  35282. /** A Sound is currently playing. */
  35283. isPlaying: boolean;
  35284. /** A Sound is currently paused. */
  35285. isPaused: boolean;
  35286. private _sounds;
  35287. private _weights;
  35288. private _currentIndex?;
  35289. /**
  35290. * Creates a new WeightedSound from the list of sounds given.
  35291. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35292. * @param sounds Array of Sounds that will be selected from.
  35293. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35294. */
  35295. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35296. /**
  35297. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35298. */
  35299. /**
  35300. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35301. */
  35302. directionalConeInnerAngle: number;
  35303. /**
  35304. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35305. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35306. */
  35307. /**
  35308. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35309. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35310. */
  35311. directionalConeOuterAngle: number;
  35312. /**
  35313. * Playback volume.
  35314. */
  35315. /**
  35316. * Playback volume.
  35317. */
  35318. volume: number;
  35319. private _onended;
  35320. /**
  35321. * Suspend playback
  35322. */
  35323. pause(): void;
  35324. /**
  35325. * Stop playback
  35326. */
  35327. stop(): void;
  35328. /**
  35329. * Start playback.
  35330. * @param startOffset Position the clip head at a specific time in seconds.
  35331. */
  35332. play(startOffset?: number): void;
  35333. }
  35334. }
  35335. declare module BABYLON {
  35336. /**
  35337. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35338. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35339. */
  35340. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35341. /**
  35342. * Gets the name of the behavior.
  35343. */
  35344. readonly name: string;
  35345. /**
  35346. * The easing function used by animations
  35347. */
  35348. static EasingFunction: BackEase;
  35349. /**
  35350. * The easing mode used by animations
  35351. */
  35352. static EasingMode: number;
  35353. /**
  35354. * The duration of the animation, in milliseconds
  35355. */
  35356. transitionDuration: number;
  35357. /**
  35358. * Length of the distance animated by the transition when lower radius is reached
  35359. */
  35360. lowerRadiusTransitionRange: number;
  35361. /**
  35362. * Length of the distance animated by the transition when upper radius is reached
  35363. */
  35364. upperRadiusTransitionRange: number;
  35365. private _autoTransitionRange;
  35366. /**
  35367. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35368. */
  35369. /**
  35370. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35371. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35372. */
  35373. autoTransitionRange: boolean;
  35374. private _attachedCamera;
  35375. private _onAfterCheckInputsObserver;
  35376. private _onMeshTargetChangedObserver;
  35377. /**
  35378. * Initializes the behavior.
  35379. */
  35380. init(): void;
  35381. /**
  35382. * Attaches the behavior to its arc rotate camera.
  35383. * @param camera Defines the camera to attach the behavior to
  35384. */
  35385. attach(camera: ArcRotateCamera): void;
  35386. /**
  35387. * Detaches the behavior from its current arc rotate camera.
  35388. */
  35389. detach(): void;
  35390. private _radiusIsAnimating;
  35391. private _radiusBounceTransition;
  35392. private _animatables;
  35393. private _cachedWheelPrecision;
  35394. /**
  35395. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35396. * @param radiusLimit The limit to check against.
  35397. * @return Bool to indicate if at limit.
  35398. */
  35399. private _isRadiusAtLimit;
  35400. /**
  35401. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35402. * @param radiusDelta The delta by which to animate to. Can be negative.
  35403. */
  35404. private _applyBoundRadiusAnimation;
  35405. /**
  35406. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35407. */
  35408. protected _clearAnimationLocks(): void;
  35409. /**
  35410. * Stops and removes all animations that have been applied to the camera
  35411. */
  35412. stopAllAnimations(): void;
  35413. }
  35414. }
  35415. declare module BABYLON {
  35416. /**
  35417. * 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.
  35418. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35419. */
  35420. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35421. /**
  35422. * Gets the name of the behavior.
  35423. */
  35424. readonly name: string;
  35425. private _mode;
  35426. private _radiusScale;
  35427. private _positionScale;
  35428. private _defaultElevation;
  35429. private _elevationReturnTime;
  35430. private _elevationReturnWaitTime;
  35431. private _zoomStopsAnimation;
  35432. private _framingTime;
  35433. /**
  35434. * The easing function used by animations
  35435. */
  35436. static EasingFunction: ExponentialEase;
  35437. /**
  35438. * The easing mode used by animations
  35439. */
  35440. static EasingMode: number;
  35441. /**
  35442. * Sets the current mode used by the behavior
  35443. */
  35444. /**
  35445. * Gets current mode used by the behavior.
  35446. */
  35447. mode: number;
  35448. /**
  35449. * Sets the scale applied to the radius (1 by default)
  35450. */
  35451. /**
  35452. * Gets the scale applied to the radius
  35453. */
  35454. radiusScale: number;
  35455. /**
  35456. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35457. */
  35458. /**
  35459. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35460. */
  35461. positionScale: number;
  35462. /**
  35463. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35464. * behaviour is triggered, in radians.
  35465. */
  35466. /**
  35467. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35468. * behaviour is triggered, in radians.
  35469. */
  35470. defaultElevation: number;
  35471. /**
  35472. * Sets the time (in milliseconds) taken to return to the default beta position.
  35473. * Negative value indicates camera should not return to default.
  35474. */
  35475. /**
  35476. * Gets the time (in milliseconds) taken to return to the default beta position.
  35477. * Negative value indicates camera should not return to default.
  35478. */
  35479. elevationReturnTime: number;
  35480. /**
  35481. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35482. */
  35483. /**
  35484. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35485. */
  35486. elevationReturnWaitTime: number;
  35487. /**
  35488. * Sets the flag that indicates if user zooming should stop animation.
  35489. */
  35490. /**
  35491. * Gets the flag that indicates if user zooming should stop animation.
  35492. */
  35493. zoomStopsAnimation: boolean;
  35494. /**
  35495. * Sets the transition time when framing the mesh, in milliseconds
  35496. */
  35497. /**
  35498. * Gets the transition time when framing the mesh, in milliseconds
  35499. */
  35500. framingTime: number;
  35501. /**
  35502. * Define if the behavior should automatically change the configured
  35503. * camera limits and sensibilities.
  35504. */
  35505. autoCorrectCameraLimitsAndSensibility: boolean;
  35506. private _onPrePointerObservableObserver;
  35507. private _onAfterCheckInputsObserver;
  35508. private _onMeshTargetChangedObserver;
  35509. private _attachedCamera;
  35510. private _isPointerDown;
  35511. private _lastInteractionTime;
  35512. /**
  35513. * Initializes the behavior.
  35514. */
  35515. init(): void;
  35516. /**
  35517. * Attaches the behavior to its arc rotate camera.
  35518. * @param camera Defines the camera to attach the behavior to
  35519. */
  35520. attach(camera: ArcRotateCamera): void;
  35521. /**
  35522. * Detaches the behavior from its current arc rotate camera.
  35523. */
  35524. detach(): void;
  35525. private _animatables;
  35526. private _betaIsAnimating;
  35527. private _betaTransition;
  35528. private _radiusTransition;
  35529. private _vectorTransition;
  35530. /**
  35531. * Targets the given mesh and updates zoom level accordingly.
  35532. * @param mesh The mesh to target.
  35533. * @param radius Optional. If a cached radius position already exists, overrides default.
  35534. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35535. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35536. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35537. */
  35538. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35539. /**
  35540. * Targets the given mesh with its children and updates zoom level accordingly.
  35541. * @param mesh The mesh to target.
  35542. * @param radius Optional. If a cached radius position already exists, overrides default.
  35543. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35544. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35545. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35546. */
  35547. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35548. /**
  35549. * Targets the given meshes with their children and updates zoom level accordingly.
  35550. * @param meshes The mesh to target.
  35551. * @param radius Optional. If a cached radius position already exists, overrides default.
  35552. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35553. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35554. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35555. */
  35556. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35557. /**
  35558. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35559. * @param minimumWorld Determines the smaller position of the bounding box extend
  35560. * @param maximumWorld Determines the bigger position of the bounding box extend
  35561. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35562. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35563. */
  35564. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35565. /**
  35566. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35567. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35568. * frustum width.
  35569. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35570. * to fully enclose the mesh in the viewing frustum.
  35571. */
  35572. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35573. /**
  35574. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35575. * is automatically returned to its default position (expected to be above ground plane).
  35576. */
  35577. private _maintainCameraAboveGround;
  35578. /**
  35579. * Returns the frustum slope based on the canvas ratio and camera FOV
  35580. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35581. */
  35582. private _getFrustumSlope;
  35583. /**
  35584. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35585. */
  35586. private _clearAnimationLocks;
  35587. /**
  35588. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35589. */
  35590. private _applyUserInteraction;
  35591. /**
  35592. * Stops and removes all animations that have been applied to the camera
  35593. */
  35594. stopAllAnimations(): void;
  35595. /**
  35596. * Gets a value indicating if the user is moving the camera
  35597. */
  35598. readonly isUserIsMoving: boolean;
  35599. /**
  35600. * The camera can move all the way towards the mesh.
  35601. */
  35602. static IgnoreBoundsSizeMode: number;
  35603. /**
  35604. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35605. */
  35606. static FitFrustumSidesMode: number;
  35607. }
  35608. }
  35609. declare module BABYLON {
  35610. /**
  35611. * Base class for Camera Pointer Inputs.
  35612. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35613. * for example usage.
  35614. */
  35615. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35616. /**
  35617. * Defines the camera the input is attached to.
  35618. */
  35619. abstract camera: Camera;
  35620. /**
  35621. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35622. */
  35623. protected _altKey: boolean;
  35624. protected _ctrlKey: boolean;
  35625. protected _metaKey: boolean;
  35626. protected _shiftKey: boolean;
  35627. /**
  35628. * Which mouse buttons were pressed at time of last mouse event.
  35629. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35630. */
  35631. protected _buttonsPressed: number;
  35632. /**
  35633. * Defines the buttons associated with the input to handle camera move.
  35634. */
  35635. buttons: number[];
  35636. /**
  35637. * Attach the input controls to a specific dom element to get the input from.
  35638. * @param element Defines the element the controls should be listened from
  35639. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35640. */
  35641. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35642. /**
  35643. * Detach the current controls from the specified dom element.
  35644. * @param element Defines the element to stop listening the inputs from
  35645. */
  35646. detachControl(element: Nullable<HTMLElement>): void;
  35647. /**
  35648. * Gets the class name of the current input.
  35649. * @returns the class name
  35650. */
  35651. getClassName(): string;
  35652. /**
  35653. * Get the friendly name associated with the input class.
  35654. * @returns the input friendly name
  35655. */
  35656. getSimpleName(): string;
  35657. /**
  35658. * Called on pointer POINTERDOUBLETAP event.
  35659. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35660. */
  35661. protected onDoubleTap(type: string): void;
  35662. /**
  35663. * Called on pointer POINTERMOVE event if only a single touch is active.
  35664. * Override this method to provide functionality.
  35665. */
  35666. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35667. /**
  35668. * Called on pointer POINTERMOVE event if multiple touches are active.
  35669. * Override this method to provide functionality.
  35670. */
  35671. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35672. /**
  35673. * Called on JS contextmenu event.
  35674. * Override this method to provide functionality.
  35675. */
  35676. protected onContextMenu(evt: PointerEvent): void;
  35677. /**
  35678. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35679. * press.
  35680. * Override this method to provide functionality.
  35681. */
  35682. protected onButtonDown(evt: PointerEvent): void;
  35683. /**
  35684. * Called each time a new POINTERUP event occurs. Ie, for each button
  35685. * release.
  35686. * Override this method to provide functionality.
  35687. */
  35688. protected onButtonUp(evt: PointerEvent): void;
  35689. /**
  35690. * Called when window becomes inactive.
  35691. * Override this method to provide functionality.
  35692. */
  35693. protected onLostFocus(): void;
  35694. private _pointerInput;
  35695. private _observer;
  35696. private _onLostFocus;
  35697. private pointA;
  35698. private pointB;
  35699. }
  35700. }
  35701. declare module BABYLON {
  35702. /**
  35703. * Manage the pointers inputs to control an arc rotate camera.
  35704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35705. */
  35706. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35707. /**
  35708. * Defines the camera the input is attached to.
  35709. */
  35710. camera: ArcRotateCamera;
  35711. /**
  35712. * Gets the class name of the current input.
  35713. * @returns the class name
  35714. */
  35715. getClassName(): string;
  35716. /**
  35717. * Defines the buttons associated with the input to handle camera move.
  35718. */
  35719. buttons: number[];
  35720. /**
  35721. * Defines the pointer angular sensibility along the X axis or how fast is
  35722. * the camera rotating.
  35723. */
  35724. angularSensibilityX: number;
  35725. /**
  35726. * Defines the pointer angular sensibility along the Y axis or how fast is
  35727. * the camera rotating.
  35728. */
  35729. angularSensibilityY: number;
  35730. /**
  35731. * Defines the pointer pinch precision or how fast is the camera zooming.
  35732. */
  35733. pinchPrecision: number;
  35734. /**
  35735. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35736. * from 0.
  35737. * It defines the percentage of current camera.radius to use as delta when
  35738. * pinch zoom is used.
  35739. */
  35740. pinchDeltaPercentage: number;
  35741. /**
  35742. * Defines the pointer panning sensibility or how fast is the camera moving.
  35743. */
  35744. panningSensibility: number;
  35745. /**
  35746. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35747. */
  35748. multiTouchPanning: boolean;
  35749. /**
  35750. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35751. * zoom (pinch) through multitouch.
  35752. */
  35753. multiTouchPanAndZoom: boolean;
  35754. /**
  35755. * Revers pinch action direction.
  35756. */
  35757. pinchInwards: boolean;
  35758. private _isPanClick;
  35759. private _twoFingerActivityCount;
  35760. private _isPinching;
  35761. /**
  35762. * Called on pointer POINTERMOVE event if only a single touch is active.
  35763. */
  35764. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35765. /**
  35766. * Called on pointer POINTERDOUBLETAP event.
  35767. */
  35768. protected onDoubleTap(type: string): void;
  35769. /**
  35770. * Called on pointer POINTERMOVE event if multiple touches are active.
  35771. */
  35772. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35773. /**
  35774. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35775. * press.
  35776. */
  35777. protected onButtonDown(evt: PointerEvent): void;
  35778. /**
  35779. * Called each time a new POINTERUP event occurs. Ie, for each button
  35780. * release.
  35781. */
  35782. protected onButtonUp(evt: PointerEvent): void;
  35783. /**
  35784. * Called when window becomes inactive.
  35785. */
  35786. protected onLostFocus(): void;
  35787. }
  35788. }
  35789. declare module BABYLON {
  35790. /**
  35791. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35792. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35793. */
  35794. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35795. /**
  35796. * Defines the camera the input is attached to.
  35797. */
  35798. camera: ArcRotateCamera;
  35799. /**
  35800. * Defines the list of key codes associated with the up action (increase alpha)
  35801. */
  35802. keysUp: number[];
  35803. /**
  35804. * Defines the list of key codes associated with the down action (decrease alpha)
  35805. */
  35806. keysDown: number[];
  35807. /**
  35808. * Defines the list of key codes associated with the left action (increase beta)
  35809. */
  35810. keysLeft: number[];
  35811. /**
  35812. * Defines the list of key codes associated with the right action (decrease beta)
  35813. */
  35814. keysRight: number[];
  35815. /**
  35816. * Defines the list of key codes associated with the reset action.
  35817. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35818. */
  35819. keysReset: number[];
  35820. /**
  35821. * Defines the panning sensibility of the inputs.
  35822. * (How fast is the camera paning)
  35823. */
  35824. panningSensibility: number;
  35825. /**
  35826. * Defines the zooming sensibility of the inputs.
  35827. * (How fast is the camera zooming)
  35828. */
  35829. zoomingSensibility: number;
  35830. /**
  35831. * Defines wether maintaining the alt key down switch the movement mode from
  35832. * orientation to zoom.
  35833. */
  35834. useAltToZoom: boolean;
  35835. /**
  35836. * Rotation speed of the camera
  35837. */
  35838. angularSpeed: number;
  35839. private _keys;
  35840. private _ctrlPressed;
  35841. private _altPressed;
  35842. private _onCanvasBlurObserver;
  35843. private _onKeyboardObserver;
  35844. private _engine;
  35845. private _scene;
  35846. /**
  35847. * Attach the input controls to a specific dom element to get the input from.
  35848. * @param element Defines the element the controls should be listened from
  35849. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35850. */
  35851. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35852. /**
  35853. * Detach the current controls from the specified dom element.
  35854. * @param element Defines the element to stop listening the inputs from
  35855. */
  35856. detachControl(element: Nullable<HTMLElement>): void;
  35857. /**
  35858. * Update the current camera state depending on the inputs that have been used this frame.
  35859. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35860. */
  35861. checkInputs(): void;
  35862. /**
  35863. * Gets the class name of the current intput.
  35864. * @returns the class name
  35865. */
  35866. getClassName(): string;
  35867. /**
  35868. * Get the friendly name associated with the input class.
  35869. * @returns the input friendly name
  35870. */
  35871. getSimpleName(): string;
  35872. }
  35873. }
  35874. declare module BABYLON {
  35875. /**
  35876. * Manage the mouse wheel inputs to control an arc rotate camera.
  35877. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35878. */
  35879. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35880. /**
  35881. * Defines the camera the input is attached to.
  35882. */
  35883. camera: ArcRotateCamera;
  35884. /**
  35885. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35886. */
  35887. wheelPrecision: number;
  35888. /**
  35889. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35890. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35891. */
  35892. wheelDeltaPercentage: number;
  35893. private _wheel;
  35894. private _observer;
  35895. private computeDeltaFromMouseWheelLegacyEvent;
  35896. /**
  35897. * Attach the input controls to a specific dom element to get the input from.
  35898. * @param element Defines the element the controls should be listened from
  35899. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35900. */
  35901. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35902. /**
  35903. * Detach the current controls from the specified dom element.
  35904. * @param element Defines the element to stop listening the inputs from
  35905. */
  35906. detachControl(element: Nullable<HTMLElement>): void;
  35907. /**
  35908. * Gets the class name of the current intput.
  35909. * @returns the class name
  35910. */
  35911. getClassName(): string;
  35912. /**
  35913. * Get the friendly name associated with the input class.
  35914. * @returns the input friendly name
  35915. */
  35916. getSimpleName(): string;
  35917. }
  35918. }
  35919. declare module BABYLON {
  35920. /**
  35921. * Default Inputs manager for the ArcRotateCamera.
  35922. * It groups all the default supported inputs for ease of use.
  35923. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35924. */
  35925. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35926. /**
  35927. * Instantiates a new ArcRotateCameraInputsManager.
  35928. * @param camera Defines the camera the inputs belong to
  35929. */
  35930. constructor(camera: ArcRotateCamera);
  35931. /**
  35932. * Add mouse wheel input support to the input manager.
  35933. * @returns the current input manager
  35934. */
  35935. addMouseWheel(): ArcRotateCameraInputsManager;
  35936. /**
  35937. * Add pointers input support to the input manager.
  35938. * @returns the current input manager
  35939. */
  35940. addPointers(): ArcRotateCameraInputsManager;
  35941. /**
  35942. * Add keyboard input support to the input manager.
  35943. * @returns the current input manager
  35944. */
  35945. addKeyboard(): ArcRotateCameraInputsManager;
  35946. }
  35947. }
  35948. declare module BABYLON {
  35949. /**
  35950. * This represents an orbital type of camera.
  35951. *
  35952. * 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.
  35953. * 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.
  35954. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35955. */
  35956. export class ArcRotateCamera extends TargetCamera {
  35957. /**
  35958. * Defines the rotation angle of the camera along the longitudinal axis.
  35959. */
  35960. alpha: number;
  35961. /**
  35962. * Defines the rotation angle of the camera along the latitudinal axis.
  35963. */
  35964. beta: number;
  35965. /**
  35966. * Defines the radius of the camera from it s target point.
  35967. */
  35968. radius: number;
  35969. protected _target: Vector3;
  35970. protected _targetHost: Nullable<AbstractMesh>;
  35971. /**
  35972. * Defines the target point of the camera.
  35973. * The camera looks towards it form the radius distance.
  35974. */
  35975. target: Vector3;
  35976. /**
  35977. * Define the current local position of the camera in the scene
  35978. */
  35979. position: Vector3;
  35980. protected _upVector: Vector3;
  35981. protected _upToYMatrix: Matrix;
  35982. protected _YToUpMatrix: Matrix;
  35983. /**
  35984. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35985. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35986. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35987. */
  35988. upVector: Vector3;
  35989. /**
  35990. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35991. */
  35992. setMatUp(): void;
  35993. /**
  35994. * Current inertia value on the longitudinal axis.
  35995. * The bigger this number the longer it will take for the camera to stop.
  35996. */
  35997. inertialAlphaOffset: number;
  35998. /**
  35999. * Current inertia value on the latitudinal axis.
  36000. * The bigger this number the longer it will take for the camera to stop.
  36001. */
  36002. inertialBetaOffset: number;
  36003. /**
  36004. * Current inertia value on the radius axis.
  36005. * The bigger this number the longer it will take for the camera to stop.
  36006. */
  36007. inertialRadiusOffset: number;
  36008. /**
  36009. * Minimum allowed angle on the longitudinal axis.
  36010. * This can help limiting how the Camera is able to move in the scene.
  36011. */
  36012. lowerAlphaLimit: Nullable<number>;
  36013. /**
  36014. * Maximum allowed angle on the longitudinal axis.
  36015. * This can help limiting how the Camera is able to move in the scene.
  36016. */
  36017. upperAlphaLimit: Nullable<number>;
  36018. /**
  36019. * Minimum allowed angle on the latitudinal axis.
  36020. * This can help limiting how the Camera is able to move in the scene.
  36021. */
  36022. lowerBetaLimit: number;
  36023. /**
  36024. * Maximum allowed angle on the latitudinal axis.
  36025. * This can help limiting how the Camera is able to move in the scene.
  36026. */
  36027. upperBetaLimit: number;
  36028. /**
  36029. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36030. * This can help limiting how the Camera is able to move in the scene.
  36031. */
  36032. lowerRadiusLimit: Nullable<number>;
  36033. /**
  36034. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36035. * This can help limiting how the Camera is able to move in the scene.
  36036. */
  36037. upperRadiusLimit: Nullable<number>;
  36038. /**
  36039. * Defines the current inertia value used during panning of the camera along the X axis.
  36040. */
  36041. inertialPanningX: number;
  36042. /**
  36043. * Defines the current inertia value used during panning of the camera along the Y axis.
  36044. */
  36045. inertialPanningY: number;
  36046. /**
  36047. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36048. * Basically if your fingers moves away from more than this distance you will be considered
  36049. * in pinch mode.
  36050. */
  36051. pinchToPanMaxDistance: number;
  36052. /**
  36053. * Defines the maximum distance the camera can pan.
  36054. * This could help keeping the cammera always in your scene.
  36055. */
  36056. panningDistanceLimit: Nullable<number>;
  36057. /**
  36058. * Defines the target of the camera before paning.
  36059. */
  36060. panningOriginTarget: Vector3;
  36061. /**
  36062. * Defines the value of the inertia used during panning.
  36063. * 0 would mean stop inertia and one would mean no decelleration at all.
  36064. */
  36065. panningInertia: number;
  36066. /**
  36067. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36068. */
  36069. angularSensibilityX: number;
  36070. /**
  36071. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36072. */
  36073. angularSensibilityY: number;
  36074. /**
  36075. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36076. */
  36077. pinchPrecision: number;
  36078. /**
  36079. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36080. * It will be used instead of pinchDeltaPrecision if different from 0.
  36081. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36082. */
  36083. pinchDeltaPercentage: number;
  36084. /**
  36085. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36086. */
  36087. panningSensibility: number;
  36088. /**
  36089. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36090. */
  36091. keysUp: number[];
  36092. /**
  36093. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36094. */
  36095. keysDown: number[];
  36096. /**
  36097. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36098. */
  36099. keysLeft: number[];
  36100. /**
  36101. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36102. */
  36103. keysRight: number[];
  36104. /**
  36105. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36106. */
  36107. wheelPrecision: number;
  36108. /**
  36109. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36110. * It will be used instead of pinchDeltaPrecision if different from 0.
  36111. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36112. */
  36113. wheelDeltaPercentage: number;
  36114. /**
  36115. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36116. */
  36117. zoomOnFactor: number;
  36118. /**
  36119. * Defines a screen offset for the camera position.
  36120. */
  36121. targetScreenOffset: Vector2;
  36122. /**
  36123. * Allows the camera to be completely reversed.
  36124. * If false the camera can not arrive upside down.
  36125. */
  36126. allowUpsideDown: boolean;
  36127. /**
  36128. * Define if double tap/click is used to restore the previously saved state of the camera.
  36129. */
  36130. useInputToRestoreState: boolean;
  36131. /** @hidden */
  36132. _viewMatrix: Matrix;
  36133. /** @hidden */
  36134. _useCtrlForPanning: boolean;
  36135. /** @hidden */
  36136. _panningMouseButton: number;
  36137. /**
  36138. * Defines the input associated to the camera.
  36139. */
  36140. inputs: ArcRotateCameraInputsManager;
  36141. /** @hidden */
  36142. _reset: () => void;
  36143. /**
  36144. * Defines the allowed panning axis.
  36145. */
  36146. panningAxis: Vector3;
  36147. protected _localDirection: Vector3;
  36148. protected _transformedDirection: Vector3;
  36149. private _bouncingBehavior;
  36150. /**
  36151. * Gets the bouncing behavior of the camera if it has been enabled.
  36152. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36153. */
  36154. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36155. /**
  36156. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36157. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36158. */
  36159. useBouncingBehavior: boolean;
  36160. private _framingBehavior;
  36161. /**
  36162. * Gets the framing behavior of the camera if it has been enabled.
  36163. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36164. */
  36165. readonly framingBehavior: Nullable<FramingBehavior>;
  36166. /**
  36167. * Defines if the framing behavior of the camera is enabled on the camera.
  36168. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36169. */
  36170. useFramingBehavior: boolean;
  36171. private _autoRotationBehavior;
  36172. /**
  36173. * Gets the auto rotation behavior of the camera if it has been enabled.
  36174. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36175. */
  36176. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36177. /**
  36178. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36179. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36180. */
  36181. useAutoRotationBehavior: boolean;
  36182. /**
  36183. * Observable triggered when the mesh target has been changed on the camera.
  36184. */
  36185. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36186. /**
  36187. * Event raised when the camera is colliding with a mesh.
  36188. */
  36189. onCollide: (collidedMesh: AbstractMesh) => void;
  36190. /**
  36191. * Defines whether the camera should check collision with the objects oh the scene.
  36192. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36193. */
  36194. checkCollisions: boolean;
  36195. /**
  36196. * Defines the collision radius of the camera.
  36197. * This simulates a sphere around the camera.
  36198. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36199. */
  36200. collisionRadius: Vector3;
  36201. protected _collider: Collider;
  36202. protected _previousPosition: Vector3;
  36203. protected _collisionVelocity: Vector3;
  36204. protected _newPosition: Vector3;
  36205. protected _previousAlpha: number;
  36206. protected _previousBeta: number;
  36207. protected _previousRadius: number;
  36208. protected _collisionTriggered: boolean;
  36209. protected _targetBoundingCenter: Nullable<Vector3>;
  36210. private _computationVector;
  36211. /**
  36212. * Instantiates a new ArcRotateCamera in a given scene
  36213. * @param name Defines the name of the camera
  36214. * @param alpha Defines the camera rotation along the logitudinal axis
  36215. * @param beta Defines the camera rotation along the latitudinal axis
  36216. * @param radius Defines the camera distance from its target
  36217. * @param target Defines the camera target
  36218. * @param scene Defines the scene the camera belongs to
  36219. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36220. */
  36221. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36222. /** @hidden */
  36223. _initCache(): void;
  36224. /** @hidden */
  36225. _updateCache(ignoreParentClass?: boolean): void;
  36226. protected _getTargetPosition(): Vector3;
  36227. private _storedAlpha;
  36228. private _storedBeta;
  36229. private _storedRadius;
  36230. private _storedTarget;
  36231. /**
  36232. * Stores the current state of the camera (alpha, beta, radius and target)
  36233. * @returns the camera itself
  36234. */
  36235. storeState(): Camera;
  36236. /**
  36237. * @hidden
  36238. * Restored camera state. You must call storeState() first
  36239. */
  36240. _restoreStateValues(): boolean;
  36241. /** @hidden */
  36242. _isSynchronizedViewMatrix(): boolean;
  36243. /**
  36244. * Attached controls to the current camera.
  36245. * @param element Defines the element the controls should be listened from
  36246. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36247. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36248. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36249. */
  36250. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36251. /**
  36252. * Detach the current controls from the camera.
  36253. * The camera will stop reacting to inputs.
  36254. * @param element Defines the element to stop listening the inputs from
  36255. */
  36256. detachControl(element: HTMLElement): void;
  36257. /** @hidden */
  36258. _checkInputs(): void;
  36259. protected _checkLimits(): void;
  36260. /**
  36261. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36262. */
  36263. rebuildAnglesAndRadius(): void;
  36264. /**
  36265. * Use a position to define the current camera related information like aplha, beta and radius
  36266. * @param position Defines the position to set the camera at
  36267. */
  36268. setPosition(position: Vector3): void;
  36269. /**
  36270. * Defines the target the camera should look at.
  36271. * This will automatically adapt alpha beta and radius to fit within the new target.
  36272. * @param target Defines the new target as a Vector or a mesh
  36273. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36274. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36275. */
  36276. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36277. /** @hidden */
  36278. _getViewMatrix(): Matrix;
  36279. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36280. /**
  36281. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36282. * @param meshes Defines the mesh to zoom on
  36283. * @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)
  36284. */
  36285. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36286. /**
  36287. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36288. * The target will be changed but the radius
  36289. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36290. * @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)
  36291. */
  36292. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36293. min: Vector3;
  36294. max: Vector3;
  36295. distance: number;
  36296. }, doNotUpdateMaxZ?: boolean): void;
  36297. /**
  36298. * @override
  36299. * Override Camera.createRigCamera
  36300. */
  36301. createRigCamera(name: string, cameraIndex: number): Camera;
  36302. /**
  36303. * @hidden
  36304. * @override
  36305. * Override Camera._updateRigCameras
  36306. */
  36307. _updateRigCameras(): void;
  36308. /**
  36309. * Destroy the camera and release the current resources hold by it.
  36310. */
  36311. dispose(): void;
  36312. /**
  36313. * Gets the current object class name.
  36314. * @return the class name
  36315. */
  36316. getClassName(): string;
  36317. }
  36318. }
  36319. declare module BABYLON {
  36320. /**
  36321. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36322. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36323. */
  36324. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36325. /**
  36326. * Gets the name of the behavior.
  36327. */
  36328. readonly name: string;
  36329. private _zoomStopsAnimation;
  36330. private _idleRotationSpeed;
  36331. private _idleRotationWaitTime;
  36332. private _idleRotationSpinupTime;
  36333. /**
  36334. * Sets the flag that indicates if user zooming should stop animation.
  36335. */
  36336. /**
  36337. * Gets the flag that indicates if user zooming should stop animation.
  36338. */
  36339. zoomStopsAnimation: boolean;
  36340. /**
  36341. * Sets the default speed at which the camera rotates around the model.
  36342. */
  36343. /**
  36344. * Gets the default speed at which the camera rotates around the model.
  36345. */
  36346. idleRotationSpeed: number;
  36347. /**
  36348. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36349. */
  36350. /**
  36351. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36352. */
  36353. idleRotationWaitTime: number;
  36354. /**
  36355. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36356. */
  36357. /**
  36358. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36359. */
  36360. idleRotationSpinupTime: number;
  36361. /**
  36362. * Gets a value indicating if the camera is currently rotating because of this behavior
  36363. */
  36364. readonly rotationInProgress: boolean;
  36365. private _onPrePointerObservableObserver;
  36366. private _onAfterCheckInputsObserver;
  36367. private _attachedCamera;
  36368. private _isPointerDown;
  36369. private _lastFrameTime;
  36370. private _lastInteractionTime;
  36371. private _cameraRotationSpeed;
  36372. /**
  36373. * Initializes the behavior.
  36374. */
  36375. init(): void;
  36376. /**
  36377. * Attaches the behavior to its arc rotate camera.
  36378. * @param camera Defines the camera to attach the behavior to
  36379. */
  36380. attach(camera: ArcRotateCamera): void;
  36381. /**
  36382. * Detaches the behavior from its current arc rotate camera.
  36383. */
  36384. detach(): void;
  36385. /**
  36386. * Returns true if user is scrolling.
  36387. * @return true if user is scrolling.
  36388. */
  36389. private _userIsZooming;
  36390. private _lastFrameRadius;
  36391. private _shouldAnimationStopForInteraction;
  36392. /**
  36393. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36394. */
  36395. private _applyUserInteraction;
  36396. private _userIsMoving;
  36397. }
  36398. }
  36399. declare module BABYLON {
  36400. /**
  36401. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36402. */
  36403. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36404. private ui;
  36405. /**
  36406. * The name of the behavior
  36407. */
  36408. name: string;
  36409. /**
  36410. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36411. */
  36412. distanceAwayFromFace: number;
  36413. /**
  36414. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36415. */
  36416. distanceAwayFromBottomOfFace: number;
  36417. private _faceVectors;
  36418. private _target;
  36419. private _scene;
  36420. private _onRenderObserver;
  36421. private _tmpMatrix;
  36422. private _tmpVector;
  36423. /**
  36424. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36425. * @param ui The transform node that should be attched to the mesh
  36426. */
  36427. constructor(ui: TransformNode);
  36428. /**
  36429. * Initializes the behavior
  36430. */
  36431. init(): void;
  36432. private _closestFace;
  36433. private _zeroVector;
  36434. private _lookAtTmpMatrix;
  36435. private _lookAtToRef;
  36436. /**
  36437. * Attaches the AttachToBoxBehavior to the passed in mesh
  36438. * @param target The mesh that the specified node will be attached to
  36439. */
  36440. attach(target: Mesh): void;
  36441. /**
  36442. * Detaches the behavior from the mesh
  36443. */
  36444. detach(): void;
  36445. }
  36446. }
  36447. declare module BABYLON {
  36448. /**
  36449. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36450. */
  36451. export class FadeInOutBehavior implements Behavior<Mesh> {
  36452. /**
  36453. * Time in milliseconds to delay before fading in (Default: 0)
  36454. */
  36455. delay: number;
  36456. /**
  36457. * Time in milliseconds for the mesh to fade in (Default: 300)
  36458. */
  36459. fadeInTime: number;
  36460. private _millisecondsPerFrame;
  36461. private _hovered;
  36462. private _hoverValue;
  36463. private _ownerNode;
  36464. /**
  36465. * Instatiates the FadeInOutBehavior
  36466. */
  36467. constructor();
  36468. /**
  36469. * The name of the behavior
  36470. */
  36471. readonly name: string;
  36472. /**
  36473. * Initializes the behavior
  36474. */
  36475. init(): void;
  36476. /**
  36477. * Attaches the fade behavior on the passed in mesh
  36478. * @param ownerNode The mesh that will be faded in/out once attached
  36479. */
  36480. attach(ownerNode: Mesh): void;
  36481. /**
  36482. * Detaches the behavior from the mesh
  36483. */
  36484. detach(): void;
  36485. /**
  36486. * Triggers the mesh to begin fading in or out
  36487. * @param value if the object should fade in or out (true to fade in)
  36488. */
  36489. fadeIn(value: boolean): void;
  36490. private _update;
  36491. private _setAllVisibility;
  36492. }
  36493. }
  36494. declare module BABYLON {
  36495. /**
  36496. * Class containing a set of static utilities functions for managing Pivots
  36497. * @hidden
  36498. */
  36499. export class PivotTools {
  36500. private static _PivotCached;
  36501. private static _OldPivotPoint;
  36502. private static _PivotTranslation;
  36503. private static _PivotTmpVector;
  36504. /** @hidden */
  36505. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36506. /** @hidden */
  36507. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36508. }
  36509. }
  36510. declare module BABYLON {
  36511. /**
  36512. * Class containing static functions to help procedurally build meshes
  36513. */
  36514. export class PlaneBuilder {
  36515. /**
  36516. * Creates a plane mesh
  36517. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36518. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36519. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36520. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36521. * * 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
  36522. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36523. * @param name defines the name of the mesh
  36524. * @param options defines the options used to create the mesh
  36525. * @param scene defines the hosting scene
  36526. * @returns the plane mesh
  36527. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36528. */
  36529. static CreatePlane(name: string, options: {
  36530. size?: number;
  36531. width?: number;
  36532. height?: number;
  36533. sideOrientation?: number;
  36534. frontUVs?: Vector4;
  36535. backUVs?: Vector4;
  36536. updatable?: boolean;
  36537. sourcePlane?: Plane;
  36538. }, scene?: Nullable<Scene>): Mesh;
  36539. }
  36540. }
  36541. declare module BABYLON {
  36542. /**
  36543. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36544. */
  36545. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36546. private static _AnyMouseID;
  36547. /**
  36548. * Abstract mesh the behavior is set on
  36549. */
  36550. attachedNode: AbstractMesh;
  36551. private _dragPlane;
  36552. private _scene;
  36553. private _pointerObserver;
  36554. private _beforeRenderObserver;
  36555. private static _planeScene;
  36556. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36557. /**
  36558. * 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)
  36559. */
  36560. maxDragAngle: number;
  36561. /**
  36562. * @hidden
  36563. */
  36564. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36565. /**
  36566. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36567. */
  36568. currentDraggingPointerID: number;
  36569. /**
  36570. * The last position where the pointer hit the drag plane in world space
  36571. */
  36572. lastDragPosition: Vector3;
  36573. /**
  36574. * If the behavior is currently in a dragging state
  36575. */
  36576. dragging: boolean;
  36577. /**
  36578. * 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)
  36579. */
  36580. dragDeltaRatio: number;
  36581. /**
  36582. * If the drag plane orientation should be updated during the dragging (Default: true)
  36583. */
  36584. updateDragPlane: boolean;
  36585. private _debugMode;
  36586. private _moving;
  36587. /**
  36588. * Fires each time the attached mesh is dragged with the pointer
  36589. * * delta between last drag position and current drag position in world space
  36590. * * dragDistance along the drag axis
  36591. * * dragPlaneNormal normal of the current drag plane used during the drag
  36592. * * dragPlanePoint in world space where the drag intersects the drag plane
  36593. */
  36594. onDragObservable: Observable<{
  36595. delta: Vector3;
  36596. dragPlanePoint: Vector3;
  36597. dragPlaneNormal: Vector3;
  36598. dragDistance: number;
  36599. pointerId: number;
  36600. }>;
  36601. /**
  36602. * Fires each time a drag begins (eg. mouse down on mesh)
  36603. */
  36604. onDragStartObservable: Observable<{
  36605. dragPlanePoint: Vector3;
  36606. pointerId: number;
  36607. }>;
  36608. /**
  36609. * Fires each time a drag ends (eg. mouse release after drag)
  36610. */
  36611. onDragEndObservable: Observable<{
  36612. dragPlanePoint: Vector3;
  36613. pointerId: number;
  36614. }>;
  36615. /**
  36616. * If the attached mesh should be moved when dragged
  36617. */
  36618. moveAttached: boolean;
  36619. /**
  36620. * If the drag behavior will react to drag events (Default: true)
  36621. */
  36622. enabled: boolean;
  36623. /**
  36624. * If pointer events should start and release the drag (Default: true)
  36625. */
  36626. startAndReleaseDragOnPointerEvents: boolean;
  36627. /**
  36628. * If camera controls should be detached during the drag
  36629. */
  36630. detachCameraControls: boolean;
  36631. /**
  36632. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36633. */
  36634. useObjectOrienationForDragging: boolean;
  36635. private _options;
  36636. /**
  36637. * Creates a pointer drag behavior that can be attached to a mesh
  36638. * @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)
  36639. */
  36640. constructor(options?: {
  36641. dragAxis?: Vector3;
  36642. dragPlaneNormal?: Vector3;
  36643. });
  36644. /**
  36645. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36646. */
  36647. validateDrag: (targetPosition: Vector3) => boolean;
  36648. /**
  36649. * The name of the behavior
  36650. */
  36651. readonly name: string;
  36652. /**
  36653. * Initializes the behavior
  36654. */
  36655. init(): void;
  36656. private _tmpVector;
  36657. private _alternatePickedPoint;
  36658. private _worldDragAxis;
  36659. private _targetPosition;
  36660. private _attachedElement;
  36661. /**
  36662. * Attaches the drag behavior the passed in mesh
  36663. * @param ownerNode The mesh that will be dragged around once attached
  36664. */
  36665. attach(ownerNode: AbstractMesh): void;
  36666. /**
  36667. * Force relase the drag action by code.
  36668. */
  36669. releaseDrag(): void;
  36670. private _startDragRay;
  36671. private _lastPointerRay;
  36672. /**
  36673. * Simulates the start of a pointer drag event on the behavior
  36674. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36675. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36676. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36677. */
  36678. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36679. private _startDrag;
  36680. private _dragDelta;
  36681. private _moveDrag;
  36682. private _pickWithRayOnDragPlane;
  36683. private _pointA;
  36684. private _pointB;
  36685. private _pointC;
  36686. private _lineA;
  36687. private _lineB;
  36688. private _localAxis;
  36689. private _lookAt;
  36690. private _updateDragPlanePosition;
  36691. /**
  36692. * Detaches the behavior from the mesh
  36693. */
  36694. detach(): void;
  36695. }
  36696. }
  36697. declare module BABYLON {
  36698. /**
  36699. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36700. */
  36701. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36702. private _dragBehaviorA;
  36703. private _dragBehaviorB;
  36704. private _startDistance;
  36705. private _initialScale;
  36706. private _targetScale;
  36707. private _ownerNode;
  36708. private _sceneRenderObserver;
  36709. /**
  36710. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36711. */
  36712. constructor();
  36713. /**
  36714. * The name of the behavior
  36715. */
  36716. readonly name: string;
  36717. /**
  36718. * Initializes the behavior
  36719. */
  36720. init(): void;
  36721. private _getCurrentDistance;
  36722. /**
  36723. * Attaches the scale behavior the passed in mesh
  36724. * @param ownerNode The mesh that will be scaled around once attached
  36725. */
  36726. attach(ownerNode: Mesh): void;
  36727. /**
  36728. * Detaches the behavior from the mesh
  36729. */
  36730. detach(): void;
  36731. }
  36732. }
  36733. declare module BABYLON {
  36734. /**
  36735. * 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
  36736. */
  36737. export class SixDofDragBehavior implements Behavior<Mesh> {
  36738. private static _virtualScene;
  36739. private _ownerNode;
  36740. private _sceneRenderObserver;
  36741. private _scene;
  36742. private _targetPosition;
  36743. private _virtualOriginMesh;
  36744. private _virtualDragMesh;
  36745. private _pointerObserver;
  36746. private _moving;
  36747. private _startingOrientation;
  36748. /**
  36749. * 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)
  36750. */
  36751. private zDragFactor;
  36752. /**
  36753. * If the object should rotate to face the drag origin
  36754. */
  36755. rotateDraggedObject: boolean;
  36756. /**
  36757. * If the behavior is currently in a dragging state
  36758. */
  36759. dragging: boolean;
  36760. /**
  36761. * 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)
  36762. */
  36763. dragDeltaRatio: number;
  36764. /**
  36765. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36766. */
  36767. currentDraggingPointerID: number;
  36768. /**
  36769. * If camera controls should be detached during the drag
  36770. */
  36771. detachCameraControls: boolean;
  36772. /**
  36773. * Fires each time a drag starts
  36774. */
  36775. onDragStartObservable: Observable<{}>;
  36776. /**
  36777. * Fires each time a drag ends (eg. mouse release after drag)
  36778. */
  36779. onDragEndObservable: Observable<{}>;
  36780. /**
  36781. * 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
  36782. */
  36783. constructor();
  36784. /**
  36785. * The name of the behavior
  36786. */
  36787. readonly name: string;
  36788. /**
  36789. * Initializes the behavior
  36790. */
  36791. init(): void;
  36792. /**
  36793. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36794. */
  36795. private readonly _pointerCamera;
  36796. /**
  36797. * Attaches the scale behavior the passed in mesh
  36798. * @param ownerNode The mesh that will be scaled around once attached
  36799. */
  36800. attach(ownerNode: Mesh): void;
  36801. /**
  36802. * Detaches the behavior from the mesh
  36803. */
  36804. detach(): void;
  36805. }
  36806. }
  36807. declare module BABYLON {
  36808. /**
  36809. * Class used to apply inverse kinematics to bones
  36810. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36811. */
  36812. export class BoneIKController {
  36813. private static _tmpVecs;
  36814. private static _tmpQuat;
  36815. private static _tmpMats;
  36816. /**
  36817. * Gets or sets the target mesh
  36818. */
  36819. targetMesh: AbstractMesh;
  36820. /** Gets or sets the mesh used as pole */
  36821. poleTargetMesh: AbstractMesh;
  36822. /**
  36823. * Gets or sets the bone used as pole
  36824. */
  36825. poleTargetBone: Nullable<Bone>;
  36826. /**
  36827. * Gets or sets the target position
  36828. */
  36829. targetPosition: Vector3;
  36830. /**
  36831. * Gets or sets the pole target position
  36832. */
  36833. poleTargetPosition: Vector3;
  36834. /**
  36835. * Gets or sets the pole target local offset
  36836. */
  36837. poleTargetLocalOffset: Vector3;
  36838. /**
  36839. * Gets or sets the pole angle
  36840. */
  36841. poleAngle: number;
  36842. /**
  36843. * Gets or sets the mesh associated with the controller
  36844. */
  36845. mesh: AbstractMesh;
  36846. /**
  36847. * 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)
  36848. */
  36849. slerpAmount: number;
  36850. private _bone1Quat;
  36851. private _bone1Mat;
  36852. private _bone2Ang;
  36853. private _bone1;
  36854. private _bone2;
  36855. private _bone1Length;
  36856. private _bone2Length;
  36857. private _maxAngle;
  36858. private _maxReach;
  36859. private _rightHandedSystem;
  36860. private _bendAxis;
  36861. private _slerping;
  36862. private _adjustRoll;
  36863. /**
  36864. * Gets or sets maximum allowed angle
  36865. */
  36866. maxAngle: number;
  36867. /**
  36868. * Creates a new BoneIKController
  36869. * @param mesh defines the mesh to control
  36870. * @param bone defines the bone to control
  36871. * @param options defines options to set up the controller
  36872. */
  36873. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36874. targetMesh?: AbstractMesh;
  36875. poleTargetMesh?: AbstractMesh;
  36876. poleTargetBone?: Bone;
  36877. poleTargetLocalOffset?: Vector3;
  36878. poleAngle?: number;
  36879. bendAxis?: Vector3;
  36880. maxAngle?: number;
  36881. slerpAmount?: number;
  36882. });
  36883. private _setMaxAngle;
  36884. /**
  36885. * Force the controller to update the bones
  36886. */
  36887. update(): void;
  36888. }
  36889. }
  36890. declare module BABYLON {
  36891. /**
  36892. * Class used to make a bone look toward a point in space
  36893. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36894. */
  36895. export class BoneLookController {
  36896. private static _tmpVecs;
  36897. private static _tmpQuat;
  36898. private static _tmpMats;
  36899. /**
  36900. * The target Vector3 that the bone will look at
  36901. */
  36902. target: Vector3;
  36903. /**
  36904. * The mesh that the bone is attached to
  36905. */
  36906. mesh: AbstractMesh;
  36907. /**
  36908. * The bone that will be looking to the target
  36909. */
  36910. bone: Bone;
  36911. /**
  36912. * The up axis of the coordinate system that is used when the bone is rotated
  36913. */
  36914. upAxis: Vector3;
  36915. /**
  36916. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36917. */
  36918. upAxisSpace: Space;
  36919. /**
  36920. * Used to make an adjustment to the yaw of the bone
  36921. */
  36922. adjustYaw: number;
  36923. /**
  36924. * Used to make an adjustment to the pitch of the bone
  36925. */
  36926. adjustPitch: number;
  36927. /**
  36928. * Used to make an adjustment to the roll of the bone
  36929. */
  36930. adjustRoll: number;
  36931. /**
  36932. * 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)
  36933. */
  36934. slerpAmount: number;
  36935. private _minYaw;
  36936. private _maxYaw;
  36937. private _minPitch;
  36938. private _maxPitch;
  36939. private _minYawSin;
  36940. private _minYawCos;
  36941. private _maxYawSin;
  36942. private _maxYawCos;
  36943. private _midYawConstraint;
  36944. private _minPitchTan;
  36945. private _maxPitchTan;
  36946. private _boneQuat;
  36947. private _slerping;
  36948. private _transformYawPitch;
  36949. private _transformYawPitchInv;
  36950. private _firstFrameSkipped;
  36951. private _yawRange;
  36952. private _fowardAxis;
  36953. /**
  36954. * Gets or sets the minimum yaw angle that the bone can look to
  36955. */
  36956. minYaw: number;
  36957. /**
  36958. * Gets or sets the maximum yaw angle that the bone can look to
  36959. */
  36960. maxYaw: number;
  36961. /**
  36962. * Gets or sets the minimum pitch angle that the bone can look to
  36963. */
  36964. minPitch: number;
  36965. /**
  36966. * Gets or sets the maximum pitch angle that the bone can look to
  36967. */
  36968. maxPitch: number;
  36969. /**
  36970. * Create a BoneLookController
  36971. * @param mesh the mesh that the bone belongs to
  36972. * @param bone the bone that will be looking to the target
  36973. * @param target the target Vector3 to look at
  36974. * @param options optional settings:
  36975. * * maxYaw: the maximum angle the bone will yaw to
  36976. * * minYaw: the minimum angle the bone will yaw to
  36977. * * maxPitch: the maximum angle the bone will pitch to
  36978. * * minPitch: the minimum angle the bone will yaw to
  36979. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36980. * * upAxis: the up axis of the coordinate system
  36981. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36982. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36983. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36984. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36985. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36986. * * adjustRoll: used to make an adjustment to the roll of the bone
  36987. **/
  36988. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36989. maxYaw?: number;
  36990. minYaw?: number;
  36991. maxPitch?: number;
  36992. minPitch?: number;
  36993. slerpAmount?: number;
  36994. upAxis?: Vector3;
  36995. upAxisSpace?: Space;
  36996. yawAxis?: Vector3;
  36997. pitchAxis?: Vector3;
  36998. adjustYaw?: number;
  36999. adjustPitch?: number;
  37000. adjustRoll?: number;
  37001. });
  37002. /**
  37003. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37004. */
  37005. update(): void;
  37006. private _getAngleDiff;
  37007. private _getAngleBetween;
  37008. private _isAngleBetween;
  37009. }
  37010. }
  37011. declare module BABYLON {
  37012. /**
  37013. * Manage the gamepad inputs to control an arc rotate camera.
  37014. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37015. */
  37016. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37017. /**
  37018. * Defines the camera the input is attached to.
  37019. */
  37020. camera: ArcRotateCamera;
  37021. /**
  37022. * Defines the gamepad the input is gathering event from.
  37023. */
  37024. gamepad: Nullable<Gamepad>;
  37025. /**
  37026. * Defines the gamepad rotation sensiblity.
  37027. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37028. */
  37029. gamepadRotationSensibility: number;
  37030. /**
  37031. * Defines the gamepad move sensiblity.
  37032. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37033. */
  37034. gamepadMoveSensibility: number;
  37035. private _onGamepadConnectedObserver;
  37036. private _onGamepadDisconnectedObserver;
  37037. /**
  37038. * Attach the input controls to a specific dom element to get the input from.
  37039. * @param element Defines the element the controls should be listened from
  37040. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37041. */
  37042. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37043. /**
  37044. * Detach the current controls from the specified dom element.
  37045. * @param element Defines the element to stop listening the inputs from
  37046. */
  37047. detachControl(element: Nullable<HTMLElement>): void;
  37048. /**
  37049. * Update the current camera state depending on the inputs that have been used this frame.
  37050. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37051. */
  37052. checkInputs(): void;
  37053. /**
  37054. * Gets the class name of the current intput.
  37055. * @returns the class name
  37056. */
  37057. getClassName(): string;
  37058. /**
  37059. * Get the friendly name associated with the input class.
  37060. * @returns the input friendly name
  37061. */
  37062. getSimpleName(): string;
  37063. }
  37064. }
  37065. declare module BABYLON {
  37066. interface ArcRotateCameraInputsManager {
  37067. /**
  37068. * Add orientation input support to the input manager.
  37069. * @returns the current input manager
  37070. */
  37071. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37072. }
  37073. /**
  37074. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37075. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37076. */
  37077. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37078. /**
  37079. * Defines the camera the input is attached to.
  37080. */
  37081. camera: ArcRotateCamera;
  37082. /**
  37083. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37084. */
  37085. alphaCorrection: number;
  37086. /**
  37087. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37088. */
  37089. gammaCorrection: number;
  37090. private _alpha;
  37091. private _gamma;
  37092. private _dirty;
  37093. private _deviceOrientationHandler;
  37094. /**
  37095. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37096. */
  37097. constructor();
  37098. /**
  37099. * Attach the input controls to a specific dom element to get the input from.
  37100. * @param element Defines the element the controls should be listened from
  37101. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37102. */
  37103. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37104. /** @hidden */
  37105. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37106. /**
  37107. * Update the current camera state depending on the inputs that have been used this frame.
  37108. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37109. */
  37110. checkInputs(): void;
  37111. /**
  37112. * Detach the current controls from the specified dom element.
  37113. * @param element Defines the element to stop listening the inputs from
  37114. */
  37115. detachControl(element: Nullable<HTMLElement>): void;
  37116. /**
  37117. * Gets the class name of the current intput.
  37118. * @returns the class name
  37119. */
  37120. getClassName(): string;
  37121. /**
  37122. * Get the friendly name associated with the input class.
  37123. * @returns the input friendly name
  37124. */
  37125. getSimpleName(): string;
  37126. }
  37127. }
  37128. declare module BABYLON {
  37129. /**
  37130. * Listen to mouse events to control the camera.
  37131. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37132. */
  37133. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37134. /**
  37135. * Defines the camera the input is attached to.
  37136. */
  37137. camera: FlyCamera;
  37138. /**
  37139. * Defines if touch is enabled. (Default is true.)
  37140. */
  37141. touchEnabled: boolean;
  37142. /**
  37143. * Defines the buttons associated with the input to handle camera rotation.
  37144. */
  37145. buttons: number[];
  37146. /**
  37147. * Assign buttons for Yaw control.
  37148. */
  37149. buttonsYaw: number[];
  37150. /**
  37151. * Assign buttons for Pitch control.
  37152. */
  37153. buttonsPitch: number[];
  37154. /**
  37155. * Assign buttons for Roll control.
  37156. */
  37157. buttonsRoll: number[];
  37158. /**
  37159. * Detect if any button is being pressed while mouse is moved.
  37160. * -1 = Mouse locked.
  37161. * 0 = Left button.
  37162. * 1 = Middle Button.
  37163. * 2 = Right Button.
  37164. */
  37165. activeButton: number;
  37166. /**
  37167. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37168. * Higher values reduce its sensitivity.
  37169. */
  37170. angularSensibility: number;
  37171. private _mousemoveCallback;
  37172. private _observer;
  37173. private _rollObserver;
  37174. private previousPosition;
  37175. private noPreventDefault;
  37176. private element;
  37177. /**
  37178. * Listen to mouse events to control the camera.
  37179. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37180. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37181. */
  37182. constructor(touchEnabled?: boolean);
  37183. /**
  37184. * Attach the mouse control to the HTML DOM element.
  37185. * @param element Defines the element that listens to the input events.
  37186. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37187. */
  37188. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37189. /**
  37190. * Detach the current controls from the specified dom element.
  37191. * @param element Defines the element to stop listening the inputs from
  37192. */
  37193. detachControl(element: Nullable<HTMLElement>): void;
  37194. /**
  37195. * Gets the class name of the current input.
  37196. * @returns the class name.
  37197. */
  37198. getClassName(): string;
  37199. /**
  37200. * Get the friendly name associated with the input class.
  37201. * @returns the input's friendly name.
  37202. */
  37203. getSimpleName(): string;
  37204. private _pointerInput;
  37205. private _onMouseMove;
  37206. /**
  37207. * Rotate camera by mouse offset.
  37208. */
  37209. private rotateCamera;
  37210. }
  37211. }
  37212. declare module BABYLON {
  37213. /**
  37214. * Default Inputs manager for the FlyCamera.
  37215. * It groups all the default supported inputs for ease of use.
  37216. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37217. */
  37218. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37219. /**
  37220. * Instantiates a new FlyCameraInputsManager.
  37221. * @param camera Defines the camera the inputs belong to.
  37222. */
  37223. constructor(camera: FlyCamera);
  37224. /**
  37225. * Add keyboard input support to the input manager.
  37226. * @returns the new FlyCameraKeyboardMoveInput().
  37227. */
  37228. addKeyboard(): FlyCameraInputsManager;
  37229. /**
  37230. * Add mouse input support to the input manager.
  37231. * @param touchEnabled Enable touch screen support.
  37232. * @returns the new FlyCameraMouseInput().
  37233. */
  37234. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37235. }
  37236. }
  37237. declare module BABYLON {
  37238. /**
  37239. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37240. * such as in a 3D Space Shooter or a Flight Simulator.
  37241. */
  37242. export class FlyCamera extends TargetCamera {
  37243. /**
  37244. * Define the collision ellipsoid of the camera.
  37245. * This is helpful for simulating a camera body, like a player's body.
  37246. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37247. */
  37248. ellipsoid: Vector3;
  37249. /**
  37250. * Define an offset for the position of the ellipsoid around the camera.
  37251. * This can be helpful if the camera is attached away from the player's body center,
  37252. * such as at its head.
  37253. */
  37254. ellipsoidOffset: Vector3;
  37255. /**
  37256. * Enable or disable collisions of the camera with the rest of the scene objects.
  37257. */
  37258. checkCollisions: boolean;
  37259. /**
  37260. * Enable or disable gravity on the camera.
  37261. */
  37262. applyGravity: boolean;
  37263. /**
  37264. * Define the current direction the camera is moving to.
  37265. */
  37266. cameraDirection: Vector3;
  37267. /**
  37268. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37269. * This overrides and empties cameraRotation.
  37270. */
  37271. rotationQuaternion: Quaternion;
  37272. /**
  37273. * Track Roll to maintain the wanted Rolling when looking around.
  37274. */
  37275. _trackRoll: number;
  37276. /**
  37277. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37278. */
  37279. rollCorrect: number;
  37280. /**
  37281. * Mimic a banked turn, Rolling the camera when Yawing.
  37282. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37283. */
  37284. bankedTurn: boolean;
  37285. /**
  37286. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37287. */
  37288. bankedTurnLimit: number;
  37289. /**
  37290. * Value of 0 disables the banked Roll.
  37291. * Value of 1 is equal to the Yaw angle in radians.
  37292. */
  37293. bankedTurnMultiplier: number;
  37294. /**
  37295. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37296. */
  37297. inputs: FlyCameraInputsManager;
  37298. /**
  37299. * Gets the input sensibility for mouse input.
  37300. * Higher values reduce sensitivity.
  37301. */
  37302. /**
  37303. * Sets the input sensibility for a mouse input.
  37304. * Higher values reduce sensitivity.
  37305. */
  37306. angularSensibility: number;
  37307. /**
  37308. * Get the keys for camera movement forward.
  37309. */
  37310. /**
  37311. * Set the keys for camera movement forward.
  37312. */
  37313. keysForward: number[];
  37314. /**
  37315. * Get the keys for camera movement backward.
  37316. */
  37317. keysBackward: number[];
  37318. /**
  37319. * Get the keys for camera movement up.
  37320. */
  37321. /**
  37322. * Set the keys for camera movement up.
  37323. */
  37324. keysUp: number[];
  37325. /**
  37326. * Get the keys for camera movement down.
  37327. */
  37328. /**
  37329. * Set the keys for camera movement down.
  37330. */
  37331. keysDown: number[];
  37332. /**
  37333. * Get the keys for camera movement left.
  37334. */
  37335. /**
  37336. * Set the keys for camera movement left.
  37337. */
  37338. keysLeft: number[];
  37339. /**
  37340. * Set the keys for camera movement right.
  37341. */
  37342. /**
  37343. * Set the keys for camera movement right.
  37344. */
  37345. keysRight: number[];
  37346. /**
  37347. * Event raised when the camera collides with a mesh in the scene.
  37348. */
  37349. onCollide: (collidedMesh: AbstractMesh) => void;
  37350. private _collider;
  37351. private _needMoveForGravity;
  37352. private _oldPosition;
  37353. private _diffPosition;
  37354. private _newPosition;
  37355. /** @hidden */
  37356. _localDirection: Vector3;
  37357. /** @hidden */
  37358. _transformedDirection: Vector3;
  37359. /**
  37360. * Instantiates a FlyCamera.
  37361. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37362. * such as in a 3D Space Shooter or a Flight Simulator.
  37363. * @param name Define the name of the camera in the scene.
  37364. * @param position Define the starting position of the camera in the scene.
  37365. * @param scene Define the scene the camera belongs to.
  37366. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37367. */
  37368. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37369. /**
  37370. * Attach a control to the HTML DOM element.
  37371. * @param element Defines the element that listens to the input events.
  37372. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37373. */
  37374. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37375. /**
  37376. * Detach a control from the HTML DOM element.
  37377. * The camera will stop reacting to that input.
  37378. * @param element Defines the element that listens to the input events.
  37379. */
  37380. detachControl(element: HTMLElement): void;
  37381. private _collisionMask;
  37382. /**
  37383. * Get the mask that the camera ignores in collision events.
  37384. */
  37385. /**
  37386. * Set the mask that the camera ignores in collision events.
  37387. */
  37388. collisionMask: number;
  37389. /** @hidden */
  37390. _collideWithWorld(displacement: Vector3): void;
  37391. /** @hidden */
  37392. private _onCollisionPositionChange;
  37393. /** @hidden */
  37394. _checkInputs(): void;
  37395. /** @hidden */
  37396. _decideIfNeedsToMove(): boolean;
  37397. /** @hidden */
  37398. _updatePosition(): void;
  37399. /**
  37400. * Restore the Roll to its target value at the rate specified.
  37401. * @param rate - Higher means slower restoring.
  37402. * @hidden
  37403. */
  37404. restoreRoll(rate: number): void;
  37405. /**
  37406. * Destroy the camera and release the current resources held by it.
  37407. */
  37408. dispose(): void;
  37409. /**
  37410. * Get the current object class name.
  37411. * @returns the class name.
  37412. */
  37413. getClassName(): string;
  37414. }
  37415. }
  37416. declare module BABYLON {
  37417. /**
  37418. * Listen to keyboard events to control the camera.
  37419. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37420. */
  37421. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37422. /**
  37423. * Defines the camera the input is attached to.
  37424. */
  37425. camera: FlyCamera;
  37426. /**
  37427. * The list of keyboard keys used to control the forward move of the camera.
  37428. */
  37429. keysForward: number[];
  37430. /**
  37431. * The list of keyboard keys used to control the backward move of the camera.
  37432. */
  37433. keysBackward: number[];
  37434. /**
  37435. * The list of keyboard keys used to control the forward move of the camera.
  37436. */
  37437. keysUp: number[];
  37438. /**
  37439. * The list of keyboard keys used to control the backward move of the camera.
  37440. */
  37441. keysDown: number[];
  37442. /**
  37443. * The list of keyboard keys used to control the right strafe move of the camera.
  37444. */
  37445. keysRight: number[];
  37446. /**
  37447. * The list of keyboard keys used to control the left strafe move of the camera.
  37448. */
  37449. keysLeft: number[];
  37450. private _keys;
  37451. private _onCanvasBlurObserver;
  37452. private _onKeyboardObserver;
  37453. private _engine;
  37454. private _scene;
  37455. /**
  37456. * Attach the input controls to a specific dom element to get the input from.
  37457. * @param element Defines the element the controls should be listened from
  37458. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37459. */
  37460. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37461. /**
  37462. * Detach the current controls from the specified dom element.
  37463. * @param element Defines the element to stop listening the inputs from
  37464. */
  37465. detachControl(element: Nullable<HTMLElement>): void;
  37466. /**
  37467. * Gets the class name of the current intput.
  37468. * @returns the class name
  37469. */
  37470. getClassName(): string;
  37471. /** @hidden */
  37472. _onLostFocus(e: FocusEvent): void;
  37473. /**
  37474. * Get the friendly name associated with the input class.
  37475. * @returns the input friendly name
  37476. */
  37477. getSimpleName(): string;
  37478. /**
  37479. * Update the current camera state depending on the inputs that have been used this frame.
  37480. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37481. */
  37482. checkInputs(): void;
  37483. }
  37484. }
  37485. declare module BABYLON {
  37486. /**
  37487. * Manage the mouse wheel inputs to control a follow camera.
  37488. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37489. */
  37490. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37491. /**
  37492. * Defines the camera the input is attached to.
  37493. */
  37494. camera: FollowCamera;
  37495. /**
  37496. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37497. */
  37498. axisControlRadius: boolean;
  37499. /**
  37500. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37501. */
  37502. axisControlHeight: boolean;
  37503. /**
  37504. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37505. */
  37506. axisControlRotation: boolean;
  37507. /**
  37508. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37509. * relation to mouseWheel events.
  37510. */
  37511. wheelPrecision: number;
  37512. /**
  37513. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37514. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37515. */
  37516. wheelDeltaPercentage: number;
  37517. private _wheel;
  37518. private _observer;
  37519. /**
  37520. * Attach the input controls to a specific dom element to get the input from.
  37521. * @param element Defines the element the controls should be listened from
  37522. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37523. */
  37524. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37525. /**
  37526. * Detach the current controls from the specified dom element.
  37527. * @param element Defines the element to stop listening the inputs from
  37528. */
  37529. detachControl(element: Nullable<HTMLElement>): void;
  37530. /**
  37531. * Gets the class name of the current intput.
  37532. * @returns the class name
  37533. */
  37534. getClassName(): string;
  37535. /**
  37536. * Get the friendly name associated with the input class.
  37537. * @returns the input friendly name
  37538. */
  37539. getSimpleName(): string;
  37540. }
  37541. }
  37542. declare module BABYLON {
  37543. /**
  37544. * Manage the pointers inputs to control an follow camera.
  37545. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37546. */
  37547. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37548. /**
  37549. * Defines the camera the input is attached to.
  37550. */
  37551. camera: FollowCamera;
  37552. /**
  37553. * Gets the class name of the current input.
  37554. * @returns the class name
  37555. */
  37556. getClassName(): string;
  37557. /**
  37558. * Defines the pointer angular sensibility along the X axis or how fast is
  37559. * the camera rotating.
  37560. * A negative number will reverse the axis direction.
  37561. */
  37562. angularSensibilityX: number;
  37563. /**
  37564. * Defines the pointer angular sensibility along the Y axis or how fast is
  37565. * the camera rotating.
  37566. * A negative number will reverse the axis direction.
  37567. */
  37568. angularSensibilityY: number;
  37569. /**
  37570. * Defines the pointer pinch precision or how fast is the camera zooming.
  37571. * A negative number will reverse the axis direction.
  37572. */
  37573. pinchPrecision: number;
  37574. /**
  37575. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37576. * from 0.
  37577. * It defines the percentage of current camera.radius to use as delta when
  37578. * pinch zoom is used.
  37579. */
  37580. pinchDeltaPercentage: number;
  37581. /**
  37582. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37583. */
  37584. axisXControlRadius: boolean;
  37585. /**
  37586. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37587. */
  37588. axisXControlHeight: boolean;
  37589. /**
  37590. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37591. */
  37592. axisXControlRotation: boolean;
  37593. /**
  37594. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37595. */
  37596. axisYControlRadius: boolean;
  37597. /**
  37598. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37599. */
  37600. axisYControlHeight: boolean;
  37601. /**
  37602. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37603. */
  37604. axisYControlRotation: boolean;
  37605. /**
  37606. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37607. */
  37608. axisPinchControlRadius: boolean;
  37609. /**
  37610. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37611. */
  37612. axisPinchControlHeight: boolean;
  37613. /**
  37614. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37615. */
  37616. axisPinchControlRotation: boolean;
  37617. /**
  37618. * Log error messages if basic misconfiguration has occurred.
  37619. */
  37620. warningEnable: boolean;
  37621. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37622. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37623. private _warningCounter;
  37624. private _warning;
  37625. }
  37626. }
  37627. declare module BABYLON {
  37628. /**
  37629. * Default Inputs manager for the FollowCamera.
  37630. * It groups all the default supported inputs for ease of use.
  37631. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37632. */
  37633. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37634. /**
  37635. * Instantiates a new FollowCameraInputsManager.
  37636. * @param camera Defines the camera the inputs belong to
  37637. */
  37638. constructor(camera: FollowCamera);
  37639. /**
  37640. * Add keyboard input support to the input manager.
  37641. * @returns the current input manager
  37642. */
  37643. addKeyboard(): FollowCameraInputsManager;
  37644. /**
  37645. * Add mouse wheel input support to the input manager.
  37646. * @returns the current input manager
  37647. */
  37648. addMouseWheel(): FollowCameraInputsManager;
  37649. /**
  37650. * Add pointers input support to the input manager.
  37651. * @returns the current input manager
  37652. */
  37653. addPointers(): FollowCameraInputsManager;
  37654. /**
  37655. * Add orientation input support to the input manager.
  37656. * @returns the current input manager
  37657. */
  37658. addVRDeviceOrientation(): FollowCameraInputsManager;
  37659. }
  37660. }
  37661. declare module BABYLON {
  37662. /**
  37663. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37664. * an arc rotate version arcFollowCamera are available.
  37665. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37666. */
  37667. export class FollowCamera extends TargetCamera {
  37668. /**
  37669. * Distance the follow camera should follow an object at
  37670. */
  37671. radius: number;
  37672. /**
  37673. * Minimum allowed distance of the camera to the axis of rotation
  37674. * (The camera can not get closer).
  37675. * This can help limiting how the Camera is able to move in the scene.
  37676. */
  37677. lowerRadiusLimit: Nullable<number>;
  37678. /**
  37679. * Maximum allowed distance of the camera to the axis of rotation
  37680. * (The camera can not get further).
  37681. * This can help limiting how the Camera is able to move in the scene.
  37682. */
  37683. upperRadiusLimit: Nullable<number>;
  37684. /**
  37685. * Define a rotation offset between the camera and the object it follows
  37686. */
  37687. rotationOffset: number;
  37688. /**
  37689. * Minimum allowed angle to camera position relative to target object.
  37690. * This can help limiting how the Camera is able to move in the scene.
  37691. */
  37692. lowerRotationOffsetLimit: Nullable<number>;
  37693. /**
  37694. * Maximum allowed angle to camera position relative to target object.
  37695. * This can help limiting how the Camera is able to move in the scene.
  37696. */
  37697. upperRotationOffsetLimit: Nullable<number>;
  37698. /**
  37699. * Define a height offset between the camera and the object it follows.
  37700. * It can help following an object from the top (like a car chaing a plane)
  37701. */
  37702. heightOffset: number;
  37703. /**
  37704. * Minimum allowed height of camera position relative to target object.
  37705. * This can help limiting how the Camera is able to move in the scene.
  37706. */
  37707. lowerHeightOffsetLimit: Nullable<number>;
  37708. /**
  37709. * Maximum allowed height of camera position relative to target object.
  37710. * This can help limiting how the Camera is able to move in the scene.
  37711. */
  37712. upperHeightOffsetLimit: Nullable<number>;
  37713. /**
  37714. * Define how fast the camera can accelerate to follow it s target.
  37715. */
  37716. cameraAcceleration: number;
  37717. /**
  37718. * Define the speed limit of the camera following an object.
  37719. */
  37720. maxCameraSpeed: number;
  37721. /**
  37722. * Define the target of the camera.
  37723. */
  37724. lockedTarget: Nullable<AbstractMesh>;
  37725. /**
  37726. * Defines the input associated with the camera.
  37727. */
  37728. inputs: FollowCameraInputsManager;
  37729. /**
  37730. * Instantiates the follow camera.
  37731. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37732. * @param name Define the name of the camera in the scene
  37733. * @param position Define the position of the camera
  37734. * @param scene Define the scene the camera belong to
  37735. * @param lockedTarget Define the target of the camera
  37736. */
  37737. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37738. private _follow;
  37739. /**
  37740. * Attached controls to the current camera.
  37741. * @param element Defines the element the controls should be listened from
  37742. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37743. */
  37744. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37745. /**
  37746. * Detach the current controls from the camera.
  37747. * The camera will stop reacting to inputs.
  37748. * @param element Defines the element to stop listening the inputs from
  37749. */
  37750. detachControl(element: HTMLElement): void;
  37751. /** @hidden */
  37752. _checkInputs(): void;
  37753. private _checkLimits;
  37754. /**
  37755. * Gets the camera class name.
  37756. * @returns the class name
  37757. */
  37758. getClassName(): string;
  37759. }
  37760. /**
  37761. * Arc Rotate version of the follow camera.
  37762. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37763. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37764. */
  37765. export class ArcFollowCamera extends TargetCamera {
  37766. /** The longitudinal angle of the camera */
  37767. alpha: number;
  37768. /** The latitudinal angle of the camera */
  37769. beta: number;
  37770. /** The radius of the camera from its target */
  37771. radius: number;
  37772. /** Define the camera target (the messh it should follow) */
  37773. target: Nullable<AbstractMesh>;
  37774. private _cartesianCoordinates;
  37775. /**
  37776. * Instantiates a new ArcFollowCamera
  37777. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37778. * @param name Define the name of the camera
  37779. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37780. * @param beta Define the rotation angle of the camera around the elevation axis
  37781. * @param radius Define the radius of the camera from its target point
  37782. * @param target Define the target of the camera
  37783. * @param scene Define the scene the camera belongs to
  37784. */
  37785. constructor(name: string,
  37786. /** The longitudinal angle of the camera */
  37787. alpha: number,
  37788. /** The latitudinal angle of the camera */
  37789. beta: number,
  37790. /** The radius of the camera from its target */
  37791. radius: number,
  37792. /** Define the camera target (the messh it should follow) */
  37793. target: Nullable<AbstractMesh>, scene: Scene);
  37794. private _follow;
  37795. /** @hidden */
  37796. _checkInputs(): void;
  37797. /**
  37798. * Returns the class name of the object.
  37799. * It is mostly used internally for serialization purposes.
  37800. */
  37801. getClassName(): string;
  37802. }
  37803. }
  37804. declare module BABYLON {
  37805. /**
  37806. * Manage the keyboard inputs to control the movement of a follow camera.
  37807. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37808. */
  37809. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37810. /**
  37811. * Defines the camera the input is attached to.
  37812. */
  37813. camera: FollowCamera;
  37814. /**
  37815. * Defines the list of key codes associated with the up action (increase heightOffset)
  37816. */
  37817. keysHeightOffsetIncr: number[];
  37818. /**
  37819. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37820. */
  37821. keysHeightOffsetDecr: number[];
  37822. /**
  37823. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37824. */
  37825. keysHeightOffsetModifierAlt: boolean;
  37826. /**
  37827. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37828. */
  37829. keysHeightOffsetModifierCtrl: boolean;
  37830. /**
  37831. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37832. */
  37833. keysHeightOffsetModifierShift: boolean;
  37834. /**
  37835. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37836. */
  37837. keysRotationOffsetIncr: number[];
  37838. /**
  37839. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37840. */
  37841. keysRotationOffsetDecr: number[];
  37842. /**
  37843. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37844. */
  37845. keysRotationOffsetModifierAlt: boolean;
  37846. /**
  37847. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37848. */
  37849. keysRotationOffsetModifierCtrl: boolean;
  37850. /**
  37851. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37852. */
  37853. keysRotationOffsetModifierShift: boolean;
  37854. /**
  37855. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37856. */
  37857. keysRadiusIncr: number[];
  37858. /**
  37859. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37860. */
  37861. keysRadiusDecr: number[];
  37862. /**
  37863. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37864. */
  37865. keysRadiusModifierAlt: boolean;
  37866. /**
  37867. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37868. */
  37869. keysRadiusModifierCtrl: boolean;
  37870. /**
  37871. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37872. */
  37873. keysRadiusModifierShift: boolean;
  37874. /**
  37875. * Defines the rate of change of heightOffset.
  37876. */
  37877. heightSensibility: number;
  37878. /**
  37879. * Defines the rate of change of rotationOffset.
  37880. */
  37881. rotationSensibility: number;
  37882. /**
  37883. * Defines the rate of change of radius.
  37884. */
  37885. radiusSensibility: number;
  37886. private _keys;
  37887. private _ctrlPressed;
  37888. private _altPressed;
  37889. private _shiftPressed;
  37890. private _onCanvasBlurObserver;
  37891. private _onKeyboardObserver;
  37892. private _engine;
  37893. private _scene;
  37894. /**
  37895. * Attach the input controls to a specific dom element to get the input from.
  37896. * @param element Defines the element the controls should be listened from
  37897. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37898. */
  37899. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37900. /**
  37901. * Detach the current controls from the specified dom element.
  37902. * @param element Defines the element to stop listening the inputs from
  37903. */
  37904. detachControl(element: Nullable<HTMLElement>): void;
  37905. /**
  37906. * Update the current camera state depending on the inputs that have been used this frame.
  37907. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37908. */
  37909. checkInputs(): void;
  37910. /**
  37911. * Gets the class name of the current input.
  37912. * @returns the class name
  37913. */
  37914. getClassName(): string;
  37915. /**
  37916. * Get the friendly name associated with the input class.
  37917. * @returns the input friendly name
  37918. */
  37919. getSimpleName(): string;
  37920. /**
  37921. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37922. * allow modification of the heightOffset value.
  37923. */
  37924. private _modifierHeightOffset;
  37925. /**
  37926. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37927. * allow modification of the rotationOffset value.
  37928. */
  37929. private _modifierRotationOffset;
  37930. /**
  37931. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37932. * allow modification of the radius value.
  37933. */
  37934. private _modifierRadius;
  37935. }
  37936. }
  37937. declare module BABYLON {
  37938. interface FreeCameraInputsManager {
  37939. /**
  37940. * @hidden
  37941. */
  37942. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37943. /**
  37944. * Add orientation input support to the input manager.
  37945. * @returns the current input manager
  37946. */
  37947. addDeviceOrientation(): FreeCameraInputsManager;
  37948. }
  37949. /**
  37950. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37951. * Screen rotation is taken into account.
  37952. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37953. */
  37954. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37955. private _camera;
  37956. private _screenOrientationAngle;
  37957. private _constantTranform;
  37958. private _screenQuaternion;
  37959. private _alpha;
  37960. private _beta;
  37961. private _gamma;
  37962. /**
  37963. * Can be used to detect if a device orientation sensor is availible on a device
  37964. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  37965. * @returns a promise that will resolve on orientation change
  37966. */
  37967. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  37968. /**
  37969. * @hidden
  37970. */
  37971. _onDeviceOrientationChangedObservable: Observable<void>;
  37972. /**
  37973. * Instantiates a new input
  37974. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37975. */
  37976. constructor();
  37977. /**
  37978. * Define the camera controlled by the input.
  37979. */
  37980. camera: FreeCamera;
  37981. /**
  37982. * Attach the input controls to a specific dom element to get the input from.
  37983. * @param element Defines the element the controls should be listened from
  37984. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37985. */
  37986. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37987. private _orientationChanged;
  37988. private _deviceOrientation;
  37989. /**
  37990. * Detach the current controls from the specified dom element.
  37991. * @param element Defines the element to stop listening the inputs from
  37992. */
  37993. detachControl(element: Nullable<HTMLElement>): void;
  37994. /**
  37995. * Update the current camera state depending on the inputs that have been used this frame.
  37996. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37997. */
  37998. checkInputs(): void;
  37999. /**
  38000. * Gets the class name of the current intput.
  38001. * @returns the class name
  38002. */
  38003. getClassName(): string;
  38004. /**
  38005. * Get the friendly name associated with the input class.
  38006. * @returns the input friendly name
  38007. */
  38008. getSimpleName(): string;
  38009. }
  38010. }
  38011. declare module BABYLON {
  38012. /**
  38013. * Manage the gamepad inputs to control a free camera.
  38014. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38015. */
  38016. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38017. /**
  38018. * Define the camera the input is attached to.
  38019. */
  38020. camera: FreeCamera;
  38021. /**
  38022. * Define the Gamepad controlling the input
  38023. */
  38024. gamepad: Nullable<Gamepad>;
  38025. /**
  38026. * Defines the gamepad rotation sensiblity.
  38027. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38028. */
  38029. gamepadAngularSensibility: number;
  38030. /**
  38031. * Defines the gamepad move sensiblity.
  38032. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38033. */
  38034. gamepadMoveSensibility: number;
  38035. private _onGamepadConnectedObserver;
  38036. private _onGamepadDisconnectedObserver;
  38037. private _cameraTransform;
  38038. private _deltaTransform;
  38039. private _vector3;
  38040. private _vector2;
  38041. /**
  38042. * Attach the input controls to a specific dom element to get the input from.
  38043. * @param element Defines the element the controls should be listened from
  38044. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38045. */
  38046. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38047. /**
  38048. * Detach the current controls from the specified dom element.
  38049. * @param element Defines the element to stop listening the inputs from
  38050. */
  38051. detachControl(element: Nullable<HTMLElement>): void;
  38052. /**
  38053. * Update the current camera state depending on the inputs that have been used this frame.
  38054. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38055. */
  38056. checkInputs(): void;
  38057. /**
  38058. * Gets the class name of the current intput.
  38059. * @returns the class name
  38060. */
  38061. getClassName(): string;
  38062. /**
  38063. * Get the friendly name associated with the input class.
  38064. * @returns the input friendly name
  38065. */
  38066. getSimpleName(): string;
  38067. }
  38068. }
  38069. declare module BABYLON {
  38070. /**
  38071. * Defines the potential axis of a Joystick
  38072. */
  38073. export enum JoystickAxis {
  38074. /** X axis */
  38075. X = 0,
  38076. /** Y axis */
  38077. Y = 1,
  38078. /** Z axis */
  38079. Z = 2
  38080. }
  38081. /**
  38082. * Class used to define virtual joystick (used in touch mode)
  38083. */
  38084. export class VirtualJoystick {
  38085. /**
  38086. * Gets or sets a boolean indicating that left and right values must be inverted
  38087. */
  38088. reverseLeftRight: boolean;
  38089. /**
  38090. * Gets or sets a boolean indicating that up and down values must be inverted
  38091. */
  38092. reverseUpDown: boolean;
  38093. /**
  38094. * Gets the offset value for the position (ie. the change of the position value)
  38095. */
  38096. deltaPosition: Vector3;
  38097. /**
  38098. * Gets a boolean indicating if the virtual joystick was pressed
  38099. */
  38100. pressed: boolean;
  38101. /**
  38102. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38103. */
  38104. static Canvas: Nullable<HTMLCanvasElement>;
  38105. private static _globalJoystickIndex;
  38106. private static vjCanvasContext;
  38107. private static vjCanvasWidth;
  38108. private static vjCanvasHeight;
  38109. private static halfWidth;
  38110. private _action;
  38111. private _axisTargetedByLeftAndRight;
  38112. private _axisTargetedByUpAndDown;
  38113. private _joystickSensibility;
  38114. private _inversedSensibility;
  38115. private _joystickPointerID;
  38116. private _joystickColor;
  38117. private _joystickPointerPos;
  38118. private _joystickPreviousPointerPos;
  38119. private _joystickPointerStartPos;
  38120. private _deltaJoystickVector;
  38121. private _leftJoystick;
  38122. private _touches;
  38123. private _onPointerDownHandlerRef;
  38124. private _onPointerMoveHandlerRef;
  38125. private _onPointerUpHandlerRef;
  38126. private _onResize;
  38127. /**
  38128. * Creates a new virtual joystick
  38129. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38130. */
  38131. constructor(leftJoystick?: boolean);
  38132. /**
  38133. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38134. * @param newJoystickSensibility defines the new sensibility
  38135. */
  38136. setJoystickSensibility(newJoystickSensibility: number): void;
  38137. private _onPointerDown;
  38138. private _onPointerMove;
  38139. private _onPointerUp;
  38140. /**
  38141. * Change the color of the virtual joystick
  38142. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38143. */
  38144. setJoystickColor(newColor: string): void;
  38145. /**
  38146. * Defines a callback to call when the joystick is touched
  38147. * @param action defines the callback
  38148. */
  38149. setActionOnTouch(action: () => any): void;
  38150. /**
  38151. * Defines which axis you'd like to control for left & right
  38152. * @param axis defines the axis to use
  38153. */
  38154. setAxisForLeftRight(axis: JoystickAxis): void;
  38155. /**
  38156. * Defines which axis you'd like to control for up & down
  38157. * @param axis defines the axis to use
  38158. */
  38159. setAxisForUpDown(axis: JoystickAxis): void;
  38160. private _drawVirtualJoystick;
  38161. /**
  38162. * Release internal HTML canvas
  38163. */
  38164. releaseCanvas(): void;
  38165. }
  38166. }
  38167. declare module BABYLON {
  38168. interface FreeCameraInputsManager {
  38169. /**
  38170. * Add virtual joystick input support to the input manager.
  38171. * @returns the current input manager
  38172. */
  38173. addVirtualJoystick(): FreeCameraInputsManager;
  38174. }
  38175. /**
  38176. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38177. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38178. */
  38179. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38180. /**
  38181. * Defines the camera the input is attached to.
  38182. */
  38183. camera: FreeCamera;
  38184. private _leftjoystick;
  38185. private _rightjoystick;
  38186. /**
  38187. * Gets the left stick of the virtual joystick.
  38188. * @returns The virtual Joystick
  38189. */
  38190. getLeftJoystick(): VirtualJoystick;
  38191. /**
  38192. * Gets the right stick of the virtual joystick.
  38193. * @returns The virtual Joystick
  38194. */
  38195. getRightJoystick(): VirtualJoystick;
  38196. /**
  38197. * Update the current camera state depending on the inputs that have been used this frame.
  38198. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38199. */
  38200. checkInputs(): void;
  38201. /**
  38202. * Attach the input controls to a specific dom element to get the input from.
  38203. * @param element Defines the element the controls should be listened from
  38204. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38205. */
  38206. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38207. /**
  38208. * Detach the current controls from the specified dom element.
  38209. * @param element Defines the element to stop listening the inputs from
  38210. */
  38211. detachControl(element: Nullable<HTMLElement>): void;
  38212. /**
  38213. * Gets the class name of the current intput.
  38214. * @returns the class name
  38215. */
  38216. getClassName(): string;
  38217. /**
  38218. * Get the friendly name associated with the input class.
  38219. * @returns the input friendly name
  38220. */
  38221. getSimpleName(): string;
  38222. }
  38223. }
  38224. declare module BABYLON {
  38225. /**
  38226. * This represents a FPS type of camera controlled by touch.
  38227. * This is like a universal camera minus the Gamepad controls.
  38228. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38229. */
  38230. export class TouchCamera extends FreeCamera {
  38231. /**
  38232. * Defines the touch sensibility for rotation.
  38233. * The higher the faster.
  38234. */
  38235. touchAngularSensibility: number;
  38236. /**
  38237. * Defines the touch sensibility for move.
  38238. * The higher the faster.
  38239. */
  38240. touchMoveSensibility: number;
  38241. /**
  38242. * Instantiates a new touch camera.
  38243. * This represents a FPS type of camera controlled by touch.
  38244. * This is like a universal camera minus the Gamepad controls.
  38245. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38246. * @param name Define the name of the camera in the scene
  38247. * @param position Define the start position of the camera in the scene
  38248. * @param scene Define the scene the camera belongs to
  38249. */
  38250. constructor(name: string, position: Vector3, scene: Scene);
  38251. /**
  38252. * Gets the current object class name.
  38253. * @return the class name
  38254. */
  38255. getClassName(): string;
  38256. /** @hidden */
  38257. _setupInputs(): void;
  38258. }
  38259. }
  38260. declare module BABYLON {
  38261. /**
  38262. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38263. * being tilted forward or back and left or right.
  38264. */
  38265. export class DeviceOrientationCamera extends FreeCamera {
  38266. private _initialQuaternion;
  38267. private _quaternionCache;
  38268. private _tmpDragQuaternion;
  38269. private _disablePointerInputWhenUsingDeviceOrientation;
  38270. /**
  38271. * Creates a new device orientation camera
  38272. * @param name The name of the camera
  38273. * @param position The start position camera
  38274. * @param scene The scene the camera belongs to
  38275. */
  38276. constructor(name: string, position: Vector3, scene: Scene);
  38277. /**
  38278. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38279. */
  38280. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38281. private _dragFactor;
  38282. /**
  38283. * Enabled turning on the y axis when the orientation sensor is active
  38284. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38285. */
  38286. enableHorizontalDragging(dragFactor?: number): void;
  38287. /**
  38288. * Gets the current instance class name ("DeviceOrientationCamera").
  38289. * This helps avoiding instanceof at run time.
  38290. * @returns the class name
  38291. */
  38292. getClassName(): string;
  38293. /**
  38294. * @hidden
  38295. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38296. */
  38297. _checkInputs(): void;
  38298. /**
  38299. * Reset the camera to its default orientation on the specified axis only.
  38300. * @param axis The axis to reset
  38301. */
  38302. resetToCurrentRotation(axis?: Axis): void;
  38303. }
  38304. }
  38305. declare module BABYLON {
  38306. /**
  38307. * Defines supported buttons for XBox360 compatible gamepads
  38308. */
  38309. export enum Xbox360Button {
  38310. /** A */
  38311. A = 0,
  38312. /** B */
  38313. B = 1,
  38314. /** X */
  38315. X = 2,
  38316. /** Y */
  38317. Y = 3,
  38318. /** Start */
  38319. Start = 4,
  38320. /** Back */
  38321. Back = 5,
  38322. /** Left button */
  38323. LB = 6,
  38324. /** Right button */
  38325. RB = 7,
  38326. /** Left stick */
  38327. LeftStick = 8,
  38328. /** Right stick */
  38329. RightStick = 9
  38330. }
  38331. /** Defines values for XBox360 DPad */
  38332. export enum Xbox360Dpad {
  38333. /** Up */
  38334. Up = 0,
  38335. /** Down */
  38336. Down = 1,
  38337. /** Left */
  38338. Left = 2,
  38339. /** Right */
  38340. Right = 3
  38341. }
  38342. /**
  38343. * Defines a XBox360 gamepad
  38344. */
  38345. export class Xbox360Pad extends Gamepad {
  38346. private _leftTrigger;
  38347. private _rightTrigger;
  38348. private _onlefttriggerchanged;
  38349. private _onrighttriggerchanged;
  38350. private _onbuttondown;
  38351. private _onbuttonup;
  38352. private _ondpaddown;
  38353. private _ondpadup;
  38354. /** Observable raised when a button is pressed */
  38355. onButtonDownObservable: Observable<Xbox360Button>;
  38356. /** Observable raised when a button is released */
  38357. onButtonUpObservable: Observable<Xbox360Button>;
  38358. /** Observable raised when a pad is pressed */
  38359. onPadDownObservable: Observable<Xbox360Dpad>;
  38360. /** Observable raised when a pad is released */
  38361. onPadUpObservable: Observable<Xbox360Dpad>;
  38362. private _buttonA;
  38363. private _buttonB;
  38364. private _buttonX;
  38365. private _buttonY;
  38366. private _buttonBack;
  38367. private _buttonStart;
  38368. private _buttonLB;
  38369. private _buttonRB;
  38370. private _buttonLeftStick;
  38371. private _buttonRightStick;
  38372. private _dPadUp;
  38373. private _dPadDown;
  38374. private _dPadLeft;
  38375. private _dPadRight;
  38376. private _isXboxOnePad;
  38377. /**
  38378. * Creates a new XBox360 gamepad object
  38379. * @param id defines the id of this gamepad
  38380. * @param index defines its index
  38381. * @param gamepad defines the internal HTML gamepad object
  38382. * @param xboxOne defines if it is a XBox One gamepad
  38383. */
  38384. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38385. /**
  38386. * Defines the callback to call when left trigger is pressed
  38387. * @param callback defines the callback to use
  38388. */
  38389. onlefttriggerchanged(callback: (value: number) => void): void;
  38390. /**
  38391. * Defines the callback to call when right trigger is pressed
  38392. * @param callback defines the callback to use
  38393. */
  38394. onrighttriggerchanged(callback: (value: number) => void): void;
  38395. /**
  38396. * Gets the left trigger value
  38397. */
  38398. /**
  38399. * Sets the left trigger value
  38400. */
  38401. leftTrigger: number;
  38402. /**
  38403. * Gets the right trigger value
  38404. */
  38405. /**
  38406. * Sets the right trigger value
  38407. */
  38408. rightTrigger: number;
  38409. /**
  38410. * Defines the callback to call when a button is pressed
  38411. * @param callback defines the callback to use
  38412. */
  38413. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38414. /**
  38415. * Defines the callback to call when a button is released
  38416. * @param callback defines the callback to use
  38417. */
  38418. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38419. /**
  38420. * Defines the callback to call when a pad is pressed
  38421. * @param callback defines the callback to use
  38422. */
  38423. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38424. /**
  38425. * Defines the callback to call when a pad is released
  38426. * @param callback defines the callback to use
  38427. */
  38428. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38429. private _setButtonValue;
  38430. private _setDPadValue;
  38431. /**
  38432. * Gets the value of the `A` button
  38433. */
  38434. /**
  38435. * Sets the value of the `A` button
  38436. */
  38437. buttonA: number;
  38438. /**
  38439. * Gets the value of the `B` button
  38440. */
  38441. /**
  38442. * Sets the value of the `B` button
  38443. */
  38444. buttonB: number;
  38445. /**
  38446. * Gets the value of the `X` button
  38447. */
  38448. /**
  38449. * Sets the value of the `X` button
  38450. */
  38451. buttonX: number;
  38452. /**
  38453. * Gets the value of the `Y` button
  38454. */
  38455. /**
  38456. * Sets the value of the `Y` button
  38457. */
  38458. buttonY: number;
  38459. /**
  38460. * Gets the value of the `Start` button
  38461. */
  38462. /**
  38463. * Sets the value of the `Start` button
  38464. */
  38465. buttonStart: number;
  38466. /**
  38467. * Gets the value of the `Back` button
  38468. */
  38469. /**
  38470. * Sets the value of the `Back` button
  38471. */
  38472. buttonBack: number;
  38473. /**
  38474. * Gets the value of the `Left` button
  38475. */
  38476. /**
  38477. * Sets the value of the `Left` button
  38478. */
  38479. buttonLB: number;
  38480. /**
  38481. * Gets the value of the `Right` button
  38482. */
  38483. /**
  38484. * Sets the value of the `Right` button
  38485. */
  38486. buttonRB: number;
  38487. /**
  38488. * Gets the value of the Left joystick
  38489. */
  38490. /**
  38491. * Sets the value of the Left joystick
  38492. */
  38493. buttonLeftStick: number;
  38494. /**
  38495. * Gets the value of the Right joystick
  38496. */
  38497. /**
  38498. * Sets the value of the Right joystick
  38499. */
  38500. buttonRightStick: number;
  38501. /**
  38502. * Gets the value of D-pad up
  38503. */
  38504. /**
  38505. * Sets the value of D-pad up
  38506. */
  38507. dPadUp: number;
  38508. /**
  38509. * Gets the value of D-pad down
  38510. */
  38511. /**
  38512. * Sets the value of D-pad down
  38513. */
  38514. dPadDown: number;
  38515. /**
  38516. * Gets the value of D-pad left
  38517. */
  38518. /**
  38519. * Sets the value of D-pad left
  38520. */
  38521. dPadLeft: number;
  38522. /**
  38523. * Gets the value of D-pad right
  38524. */
  38525. /**
  38526. * Sets the value of D-pad right
  38527. */
  38528. dPadRight: number;
  38529. /**
  38530. * Force the gamepad to synchronize with device values
  38531. */
  38532. update(): void;
  38533. /**
  38534. * Disposes the gamepad
  38535. */
  38536. dispose(): void;
  38537. }
  38538. }
  38539. declare module BABYLON {
  38540. /**
  38541. * Defines supported buttons for DualShock compatible gamepads
  38542. */
  38543. export enum DualShockButton {
  38544. /** Cross */
  38545. Cross = 0,
  38546. /** Circle */
  38547. Circle = 1,
  38548. /** Square */
  38549. Square = 2,
  38550. /** Triangle */
  38551. Triangle = 3,
  38552. /** Options */
  38553. Options = 4,
  38554. /** Share */
  38555. Share = 5,
  38556. /** L1 */
  38557. L1 = 6,
  38558. /** R1 */
  38559. R1 = 7,
  38560. /** Left stick */
  38561. LeftStick = 8,
  38562. /** Right stick */
  38563. RightStick = 9
  38564. }
  38565. /** Defines values for DualShock DPad */
  38566. export enum DualShockDpad {
  38567. /** Up */
  38568. Up = 0,
  38569. /** Down */
  38570. Down = 1,
  38571. /** Left */
  38572. Left = 2,
  38573. /** Right */
  38574. Right = 3
  38575. }
  38576. /**
  38577. * Defines a DualShock gamepad
  38578. */
  38579. export class DualShockPad extends Gamepad {
  38580. private _leftTrigger;
  38581. private _rightTrigger;
  38582. private _onlefttriggerchanged;
  38583. private _onrighttriggerchanged;
  38584. private _onbuttondown;
  38585. private _onbuttonup;
  38586. private _ondpaddown;
  38587. private _ondpadup;
  38588. /** Observable raised when a button is pressed */
  38589. onButtonDownObservable: Observable<DualShockButton>;
  38590. /** Observable raised when a button is released */
  38591. onButtonUpObservable: Observable<DualShockButton>;
  38592. /** Observable raised when a pad is pressed */
  38593. onPadDownObservable: Observable<DualShockDpad>;
  38594. /** Observable raised when a pad is released */
  38595. onPadUpObservable: Observable<DualShockDpad>;
  38596. private _buttonCross;
  38597. private _buttonCircle;
  38598. private _buttonSquare;
  38599. private _buttonTriangle;
  38600. private _buttonShare;
  38601. private _buttonOptions;
  38602. private _buttonL1;
  38603. private _buttonR1;
  38604. private _buttonLeftStick;
  38605. private _buttonRightStick;
  38606. private _dPadUp;
  38607. private _dPadDown;
  38608. private _dPadLeft;
  38609. private _dPadRight;
  38610. /**
  38611. * Creates a new DualShock gamepad object
  38612. * @param id defines the id of this gamepad
  38613. * @param index defines its index
  38614. * @param gamepad defines the internal HTML gamepad object
  38615. */
  38616. constructor(id: string, index: number, gamepad: any);
  38617. /**
  38618. * Defines the callback to call when left trigger is pressed
  38619. * @param callback defines the callback to use
  38620. */
  38621. onlefttriggerchanged(callback: (value: number) => void): void;
  38622. /**
  38623. * Defines the callback to call when right trigger is pressed
  38624. * @param callback defines the callback to use
  38625. */
  38626. onrighttriggerchanged(callback: (value: number) => void): void;
  38627. /**
  38628. * Gets the left trigger value
  38629. */
  38630. /**
  38631. * Sets the left trigger value
  38632. */
  38633. leftTrigger: number;
  38634. /**
  38635. * Gets the right trigger value
  38636. */
  38637. /**
  38638. * Sets the right trigger value
  38639. */
  38640. rightTrigger: number;
  38641. /**
  38642. * Defines the callback to call when a button is pressed
  38643. * @param callback defines the callback to use
  38644. */
  38645. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  38646. /**
  38647. * Defines the callback to call when a button is released
  38648. * @param callback defines the callback to use
  38649. */
  38650. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  38651. /**
  38652. * Defines the callback to call when a pad is pressed
  38653. * @param callback defines the callback to use
  38654. */
  38655. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  38656. /**
  38657. * Defines the callback to call when a pad is released
  38658. * @param callback defines the callback to use
  38659. */
  38660. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  38661. private _setButtonValue;
  38662. private _setDPadValue;
  38663. /**
  38664. * Gets the value of the `Cross` button
  38665. */
  38666. /**
  38667. * Sets the value of the `Cross` button
  38668. */
  38669. buttonCross: number;
  38670. /**
  38671. * Gets the value of the `Circle` button
  38672. */
  38673. /**
  38674. * Sets the value of the `Circle` button
  38675. */
  38676. buttonCircle: number;
  38677. /**
  38678. * Gets the value of the `Square` button
  38679. */
  38680. /**
  38681. * Sets the value of the `Square` button
  38682. */
  38683. buttonSquare: number;
  38684. /**
  38685. * Gets the value of the `Triangle` button
  38686. */
  38687. /**
  38688. * Sets the value of the `Triangle` button
  38689. */
  38690. buttonTriangle: number;
  38691. /**
  38692. * Gets the value of the `Options` button
  38693. */
  38694. /**
  38695. * Sets the value of the `Options` button
  38696. */
  38697. buttonOptions: number;
  38698. /**
  38699. * Gets the value of the `Share` button
  38700. */
  38701. /**
  38702. * Sets the value of the `Share` button
  38703. */
  38704. buttonShare: number;
  38705. /**
  38706. * Gets the value of the `L1` button
  38707. */
  38708. /**
  38709. * Sets the value of the `L1` button
  38710. */
  38711. buttonL1: number;
  38712. /**
  38713. * Gets the value of the `R1` button
  38714. */
  38715. /**
  38716. * Sets the value of the `R1` button
  38717. */
  38718. buttonR1: number;
  38719. /**
  38720. * Gets the value of the Left joystick
  38721. */
  38722. /**
  38723. * Sets the value of the Left joystick
  38724. */
  38725. buttonLeftStick: number;
  38726. /**
  38727. * Gets the value of the Right joystick
  38728. */
  38729. /**
  38730. * Sets the value of the Right joystick
  38731. */
  38732. buttonRightStick: number;
  38733. /**
  38734. * Gets the value of D-pad up
  38735. */
  38736. /**
  38737. * Sets the value of D-pad up
  38738. */
  38739. dPadUp: number;
  38740. /**
  38741. * Gets the value of D-pad down
  38742. */
  38743. /**
  38744. * Sets the value of D-pad down
  38745. */
  38746. dPadDown: number;
  38747. /**
  38748. * Gets the value of D-pad left
  38749. */
  38750. /**
  38751. * Sets the value of D-pad left
  38752. */
  38753. dPadLeft: number;
  38754. /**
  38755. * Gets the value of D-pad right
  38756. */
  38757. /**
  38758. * Sets the value of D-pad right
  38759. */
  38760. dPadRight: number;
  38761. /**
  38762. * Force the gamepad to synchronize with device values
  38763. */
  38764. update(): void;
  38765. /**
  38766. * Disposes the gamepad
  38767. */
  38768. dispose(): void;
  38769. }
  38770. }
  38771. declare module BABYLON {
  38772. /**
  38773. * Manager for handling gamepads
  38774. */
  38775. export class GamepadManager {
  38776. private _scene?;
  38777. private _babylonGamepads;
  38778. private _oneGamepadConnected;
  38779. /** @hidden */
  38780. _isMonitoring: boolean;
  38781. private _gamepadEventSupported;
  38782. private _gamepadSupport;
  38783. /**
  38784. * observable to be triggered when the gamepad controller has been connected
  38785. */
  38786. onGamepadConnectedObservable: Observable<Gamepad>;
  38787. /**
  38788. * observable to be triggered when the gamepad controller has been disconnected
  38789. */
  38790. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38791. private _onGamepadConnectedEvent;
  38792. private _onGamepadDisconnectedEvent;
  38793. /**
  38794. * Initializes the gamepad manager
  38795. * @param _scene BabylonJS scene
  38796. */
  38797. constructor(_scene?: Scene | undefined);
  38798. /**
  38799. * The gamepads in the game pad manager
  38800. */
  38801. readonly gamepads: Gamepad[];
  38802. /**
  38803. * Get the gamepad controllers based on type
  38804. * @param type The type of gamepad controller
  38805. * @returns Nullable gamepad
  38806. */
  38807. getGamepadByType(type?: number): Nullable<Gamepad>;
  38808. /**
  38809. * Disposes the gamepad manager
  38810. */
  38811. dispose(): void;
  38812. private _addNewGamepad;
  38813. private _startMonitoringGamepads;
  38814. private _stopMonitoringGamepads;
  38815. /** @hidden */
  38816. _checkGamepadsStatus(): void;
  38817. private _updateGamepadObjects;
  38818. }
  38819. }
  38820. declare module BABYLON {
  38821. interface Scene {
  38822. /** @hidden */
  38823. _gamepadManager: Nullable<GamepadManager>;
  38824. /**
  38825. * Gets the gamepad manager associated with the scene
  38826. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38827. */
  38828. gamepadManager: GamepadManager;
  38829. }
  38830. /**
  38831. * Interface representing a free camera inputs manager
  38832. */
  38833. interface FreeCameraInputsManager {
  38834. /**
  38835. * Adds gamepad input support to the FreeCameraInputsManager.
  38836. * @returns the FreeCameraInputsManager
  38837. */
  38838. addGamepad(): FreeCameraInputsManager;
  38839. }
  38840. /**
  38841. * Interface representing an arc rotate camera inputs manager
  38842. */
  38843. interface ArcRotateCameraInputsManager {
  38844. /**
  38845. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38846. * @returns the camera inputs manager
  38847. */
  38848. addGamepad(): ArcRotateCameraInputsManager;
  38849. }
  38850. /**
  38851. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38852. */
  38853. export class GamepadSystemSceneComponent implements ISceneComponent {
  38854. /**
  38855. * The component name helpfull to identify the component in the list of scene components.
  38856. */
  38857. readonly name: string;
  38858. /**
  38859. * The scene the component belongs to.
  38860. */
  38861. scene: Scene;
  38862. /**
  38863. * Creates a new instance of the component for the given scene
  38864. * @param scene Defines the scene to register the component in
  38865. */
  38866. constructor(scene: Scene);
  38867. /**
  38868. * Registers the component in a given scene
  38869. */
  38870. register(): void;
  38871. /**
  38872. * Rebuilds the elements related to this component in case of
  38873. * context lost for instance.
  38874. */
  38875. rebuild(): void;
  38876. /**
  38877. * Disposes the component and the associated ressources
  38878. */
  38879. dispose(): void;
  38880. private _beforeCameraUpdate;
  38881. }
  38882. }
  38883. declare module BABYLON {
  38884. /**
  38885. * 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,
  38886. * which still works and will still be found in many Playgrounds.
  38887. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38888. */
  38889. export class UniversalCamera extends TouchCamera {
  38890. /**
  38891. * Defines the gamepad rotation sensiblity.
  38892. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38893. */
  38894. gamepadAngularSensibility: number;
  38895. /**
  38896. * Defines the gamepad move sensiblity.
  38897. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38898. */
  38899. gamepadMoveSensibility: number;
  38900. /**
  38901. * 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,
  38902. * which still works and will still be found in many Playgrounds.
  38903. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38904. * @param name Define the name of the camera in the scene
  38905. * @param position Define the start position of the camera in the scene
  38906. * @param scene Define the scene the camera belongs to
  38907. */
  38908. constructor(name: string, position: Vector3, scene: Scene);
  38909. /**
  38910. * Gets the current object class name.
  38911. * @return the class name
  38912. */
  38913. getClassName(): string;
  38914. }
  38915. }
  38916. declare module BABYLON {
  38917. /**
  38918. * This represents a FPS type of camera. This is only here for back compat purpose.
  38919. * Please use the UniversalCamera instead as both are identical.
  38920. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38921. */
  38922. export class GamepadCamera extends UniversalCamera {
  38923. /**
  38924. * Instantiates a new Gamepad Camera
  38925. * This represents a FPS type of camera. This is only here for back compat purpose.
  38926. * Please use the UniversalCamera instead as both are identical.
  38927. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38928. * @param name Define the name of the camera in the scene
  38929. * @param position Define the start position of the camera in the scene
  38930. * @param scene Define the scene the camera belongs to
  38931. */
  38932. constructor(name: string, position: Vector3, scene: Scene);
  38933. /**
  38934. * Gets the current object class name.
  38935. * @return the class name
  38936. */
  38937. getClassName(): string;
  38938. }
  38939. }
  38940. declare module BABYLON {
  38941. /** @hidden */
  38942. export var passPixelShader: {
  38943. name: string;
  38944. shader: string;
  38945. };
  38946. }
  38947. declare module BABYLON {
  38948. /** @hidden */
  38949. export var passCubePixelShader: {
  38950. name: string;
  38951. shader: string;
  38952. };
  38953. }
  38954. declare module BABYLON {
  38955. /**
  38956. * PassPostProcess which produces an output the same as it's input
  38957. */
  38958. export class PassPostProcess extends PostProcess {
  38959. /**
  38960. * Creates the PassPostProcess
  38961. * @param name The name of the effect.
  38962. * @param options The required width/height ratio to downsize to before computing the render pass.
  38963. * @param camera The camera to apply the render pass to.
  38964. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38965. * @param engine The engine which the post process will be applied. (default: current engine)
  38966. * @param reusable If the post process can be reused on the same frame. (default: false)
  38967. * @param textureType The type of texture to be used when performing the post processing.
  38968. * @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)
  38969. */
  38970. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38971. }
  38972. /**
  38973. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38974. */
  38975. export class PassCubePostProcess extends PostProcess {
  38976. private _face;
  38977. /**
  38978. * Gets or sets the cube face to display.
  38979. * * 0 is +X
  38980. * * 1 is -X
  38981. * * 2 is +Y
  38982. * * 3 is -Y
  38983. * * 4 is +Z
  38984. * * 5 is -Z
  38985. */
  38986. face: number;
  38987. /**
  38988. * Creates the PassCubePostProcess
  38989. * @param name The name of the effect.
  38990. * @param options The required width/height ratio to downsize to before computing the render pass.
  38991. * @param camera The camera to apply the render pass to.
  38992. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38993. * @param engine The engine which the post process will be applied. (default: current engine)
  38994. * @param reusable If the post process can be reused on the same frame. (default: false)
  38995. * @param textureType The type of texture to be used when performing the post processing.
  38996. * @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)
  38997. */
  38998. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38999. }
  39000. }
  39001. declare module BABYLON {
  39002. /** @hidden */
  39003. export var anaglyphPixelShader: {
  39004. name: string;
  39005. shader: string;
  39006. };
  39007. }
  39008. declare module BABYLON {
  39009. /**
  39010. * Postprocess used to generate anaglyphic rendering
  39011. */
  39012. export class AnaglyphPostProcess extends PostProcess {
  39013. private _passedProcess;
  39014. /**
  39015. * Creates a new AnaglyphPostProcess
  39016. * @param name defines postprocess name
  39017. * @param options defines creation options or target ratio scale
  39018. * @param rigCameras defines cameras using this postprocess
  39019. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39020. * @param engine defines hosting engine
  39021. * @param reusable defines if the postprocess will be reused multiple times per frame
  39022. */
  39023. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39024. }
  39025. }
  39026. declare module BABYLON {
  39027. /**
  39028. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39029. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39030. */
  39031. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39032. /**
  39033. * Creates a new AnaglyphArcRotateCamera
  39034. * @param name defines camera name
  39035. * @param alpha defines alpha angle (in radians)
  39036. * @param beta defines beta angle (in radians)
  39037. * @param radius defines radius
  39038. * @param target defines camera target
  39039. * @param interaxialDistance defines distance between each color axis
  39040. * @param scene defines the hosting scene
  39041. */
  39042. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39043. /**
  39044. * Gets camera class name
  39045. * @returns AnaglyphArcRotateCamera
  39046. */
  39047. getClassName(): string;
  39048. }
  39049. }
  39050. declare module BABYLON {
  39051. /**
  39052. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39053. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39054. */
  39055. export class AnaglyphFreeCamera extends FreeCamera {
  39056. /**
  39057. * Creates a new AnaglyphFreeCamera
  39058. * @param name defines camera name
  39059. * @param position defines initial position
  39060. * @param interaxialDistance defines distance between each color axis
  39061. * @param scene defines the hosting scene
  39062. */
  39063. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39064. /**
  39065. * Gets camera class name
  39066. * @returns AnaglyphFreeCamera
  39067. */
  39068. getClassName(): string;
  39069. }
  39070. }
  39071. declare module BABYLON {
  39072. /**
  39073. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39074. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39075. */
  39076. export class AnaglyphGamepadCamera extends GamepadCamera {
  39077. /**
  39078. * Creates a new AnaglyphGamepadCamera
  39079. * @param name defines camera name
  39080. * @param position defines initial position
  39081. * @param interaxialDistance defines distance between each color axis
  39082. * @param scene defines the hosting scene
  39083. */
  39084. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39085. /**
  39086. * Gets camera class name
  39087. * @returns AnaglyphGamepadCamera
  39088. */
  39089. getClassName(): string;
  39090. }
  39091. }
  39092. declare module BABYLON {
  39093. /**
  39094. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39095. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39096. */
  39097. export class AnaglyphUniversalCamera extends UniversalCamera {
  39098. /**
  39099. * Creates a new AnaglyphUniversalCamera
  39100. * @param name defines camera name
  39101. * @param position defines initial position
  39102. * @param interaxialDistance defines distance between each color axis
  39103. * @param scene defines the hosting scene
  39104. */
  39105. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39106. /**
  39107. * Gets camera class name
  39108. * @returns AnaglyphUniversalCamera
  39109. */
  39110. getClassName(): string;
  39111. }
  39112. }
  39113. declare module BABYLON {
  39114. /** @hidden */
  39115. export var stereoscopicInterlacePixelShader: {
  39116. name: string;
  39117. shader: string;
  39118. };
  39119. }
  39120. declare module BABYLON {
  39121. /**
  39122. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39123. */
  39124. export class StereoscopicInterlacePostProcess extends PostProcess {
  39125. private _stepSize;
  39126. private _passedProcess;
  39127. /**
  39128. * Initializes a StereoscopicInterlacePostProcess
  39129. * @param name The name of the effect.
  39130. * @param rigCameras The rig cameras to be appled to the post process
  39131. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39132. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39133. * @param engine The engine which the post process will be applied. (default: current engine)
  39134. * @param reusable If the post process can be reused on the same frame. (default: false)
  39135. */
  39136. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39137. }
  39138. }
  39139. declare module BABYLON {
  39140. /**
  39141. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39142. * @see http://doc.babylonjs.com/features/cameras
  39143. */
  39144. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39145. /**
  39146. * Creates a new StereoscopicArcRotateCamera
  39147. * @param name defines camera name
  39148. * @param alpha defines alpha angle (in radians)
  39149. * @param beta defines beta angle (in radians)
  39150. * @param radius defines radius
  39151. * @param target defines camera target
  39152. * @param interaxialDistance defines distance between each color axis
  39153. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39154. * @param scene defines the hosting scene
  39155. */
  39156. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39157. /**
  39158. * Gets camera class name
  39159. * @returns StereoscopicArcRotateCamera
  39160. */
  39161. getClassName(): string;
  39162. }
  39163. }
  39164. declare module BABYLON {
  39165. /**
  39166. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39167. * @see http://doc.babylonjs.com/features/cameras
  39168. */
  39169. export class StereoscopicFreeCamera extends FreeCamera {
  39170. /**
  39171. * Creates a new StereoscopicFreeCamera
  39172. * @param name defines camera name
  39173. * @param position defines initial position
  39174. * @param interaxialDistance defines distance between each color axis
  39175. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39176. * @param scene defines the hosting scene
  39177. */
  39178. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39179. /**
  39180. * Gets camera class name
  39181. * @returns StereoscopicFreeCamera
  39182. */
  39183. getClassName(): string;
  39184. }
  39185. }
  39186. declare module BABYLON {
  39187. /**
  39188. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39189. * @see http://doc.babylonjs.com/features/cameras
  39190. */
  39191. export class StereoscopicGamepadCamera extends GamepadCamera {
  39192. /**
  39193. * Creates a new StereoscopicGamepadCamera
  39194. * @param name defines camera name
  39195. * @param position defines initial position
  39196. * @param interaxialDistance defines distance between each color axis
  39197. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39198. * @param scene defines the hosting scene
  39199. */
  39200. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39201. /**
  39202. * Gets camera class name
  39203. * @returns StereoscopicGamepadCamera
  39204. */
  39205. getClassName(): string;
  39206. }
  39207. }
  39208. declare module BABYLON {
  39209. /**
  39210. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39211. * @see http://doc.babylonjs.com/features/cameras
  39212. */
  39213. export class StereoscopicUniversalCamera extends UniversalCamera {
  39214. /**
  39215. * Creates a new StereoscopicUniversalCamera
  39216. * @param name defines camera name
  39217. * @param position defines initial position
  39218. * @param interaxialDistance defines distance between each color axis
  39219. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39220. * @param scene defines the hosting scene
  39221. */
  39222. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39223. /**
  39224. * Gets camera class name
  39225. * @returns StereoscopicUniversalCamera
  39226. */
  39227. getClassName(): string;
  39228. }
  39229. }
  39230. declare module BABYLON {
  39231. /**
  39232. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39233. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39234. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39235. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39236. */
  39237. export class VirtualJoysticksCamera extends FreeCamera {
  39238. /**
  39239. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39240. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39241. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39242. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39243. * @param name Define the name of the camera in the scene
  39244. * @param position Define the start position of the camera in the scene
  39245. * @param scene Define the scene the camera belongs to
  39246. */
  39247. constructor(name: string, position: Vector3, scene: Scene);
  39248. /**
  39249. * Gets the current object class name.
  39250. * @return the class name
  39251. */
  39252. getClassName(): string;
  39253. }
  39254. }
  39255. declare module BABYLON {
  39256. /**
  39257. * This represents all the required metrics to create a VR camera.
  39258. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39259. */
  39260. export class VRCameraMetrics {
  39261. /**
  39262. * Define the horizontal resolution off the screen.
  39263. */
  39264. hResolution: number;
  39265. /**
  39266. * Define the vertical resolution off the screen.
  39267. */
  39268. vResolution: number;
  39269. /**
  39270. * Define the horizontal screen size.
  39271. */
  39272. hScreenSize: number;
  39273. /**
  39274. * Define the vertical screen size.
  39275. */
  39276. vScreenSize: number;
  39277. /**
  39278. * Define the vertical screen center position.
  39279. */
  39280. vScreenCenter: number;
  39281. /**
  39282. * Define the distance of the eyes to the screen.
  39283. */
  39284. eyeToScreenDistance: number;
  39285. /**
  39286. * Define the distance between both lenses
  39287. */
  39288. lensSeparationDistance: number;
  39289. /**
  39290. * Define the distance between both viewer's eyes.
  39291. */
  39292. interpupillaryDistance: number;
  39293. /**
  39294. * Define the distortion factor of the VR postprocess.
  39295. * Please, touch with care.
  39296. */
  39297. distortionK: number[];
  39298. /**
  39299. * Define the chromatic aberration correction factors for the VR post process.
  39300. */
  39301. chromaAbCorrection: number[];
  39302. /**
  39303. * Define the scale factor of the post process.
  39304. * The smaller the better but the slower.
  39305. */
  39306. postProcessScaleFactor: number;
  39307. /**
  39308. * Define an offset for the lens center.
  39309. */
  39310. lensCenterOffset: number;
  39311. /**
  39312. * Define if the current vr camera should compensate the distortion of the lense or not.
  39313. */
  39314. compensateDistortion: boolean;
  39315. /**
  39316. * Defines if multiview should be enabled when rendering (Default: false)
  39317. */
  39318. multiviewEnabled: boolean;
  39319. /**
  39320. * Gets the rendering aspect ratio based on the provided resolutions.
  39321. */
  39322. readonly aspectRatio: number;
  39323. /**
  39324. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39325. */
  39326. readonly aspectRatioFov: number;
  39327. /**
  39328. * @hidden
  39329. */
  39330. readonly leftHMatrix: Matrix;
  39331. /**
  39332. * @hidden
  39333. */
  39334. readonly rightHMatrix: Matrix;
  39335. /**
  39336. * @hidden
  39337. */
  39338. readonly leftPreViewMatrix: Matrix;
  39339. /**
  39340. * @hidden
  39341. */
  39342. readonly rightPreViewMatrix: Matrix;
  39343. /**
  39344. * Get the default VRMetrics based on the most generic setup.
  39345. * @returns the default vr metrics
  39346. */
  39347. static GetDefault(): VRCameraMetrics;
  39348. }
  39349. }
  39350. declare module BABYLON {
  39351. /** @hidden */
  39352. export var vrDistortionCorrectionPixelShader: {
  39353. name: string;
  39354. shader: string;
  39355. };
  39356. }
  39357. declare module BABYLON {
  39358. /**
  39359. * VRDistortionCorrectionPostProcess used for mobile VR
  39360. */
  39361. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39362. private _isRightEye;
  39363. private _distortionFactors;
  39364. private _postProcessScaleFactor;
  39365. private _lensCenterOffset;
  39366. private _scaleIn;
  39367. private _scaleFactor;
  39368. private _lensCenter;
  39369. /**
  39370. * Initializes the VRDistortionCorrectionPostProcess
  39371. * @param name The name of the effect.
  39372. * @param camera The camera to apply the render pass to.
  39373. * @param isRightEye If this is for the right eye distortion
  39374. * @param vrMetrics All the required metrics for the VR camera
  39375. */
  39376. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39377. }
  39378. }
  39379. declare module BABYLON {
  39380. /**
  39381. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39382. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39383. */
  39384. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39385. /**
  39386. * Creates a new VRDeviceOrientationArcRotateCamera
  39387. * @param name defines camera name
  39388. * @param alpha defines the camera rotation along the logitudinal axis
  39389. * @param beta defines the camera rotation along the latitudinal axis
  39390. * @param radius defines the camera distance from its target
  39391. * @param target defines the camera target
  39392. * @param scene defines the scene the camera belongs to
  39393. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39394. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39395. */
  39396. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39397. /**
  39398. * Gets camera class name
  39399. * @returns VRDeviceOrientationArcRotateCamera
  39400. */
  39401. getClassName(): string;
  39402. }
  39403. }
  39404. declare module BABYLON {
  39405. /**
  39406. * Camera used to simulate VR rendering (based on FreeCamera)
  39407. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39408. */
  39409. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39410. /**
  39411. * Creates a new VRDeviceOrientationFreeCamera
  39412. * @param name defines camera name
  39413. * @param position defines the start position of the camera
  39414. * @param scene defines the scene the camera belongs to
  39415. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39416. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39417. */
  39418. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39419. /**
  39420. * Gets camera class name
  39421. * @returns VRDeviceOrientationFreeCamera
  39422. */
  39423. getClassName(): string;
  39424. }
  39425. }
  39426. declare module BABYLON {
  39427. /**
  39428. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39429. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39430. */
  39431. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39432. /**
  39433. * Creates a new VRDeviceOrientationGamepadCamera
  39434. * @param name defines camera name
  39435. * @param position defines the start position of the camera
  39436. * @param scene defines the scene the camera belongs to
  39437. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39438. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39439. */
  39440. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39441. /**
  39442. * Gets camera class name
  39443. * @returns VRDeviceOrientationGamepadCamera
  39444. */
  39445. getClassName(): string;
  39446. }
  39447. }
  39448. declare module BABYLON {
  39449. /**
  39450. * Base class of materials working in push mode in babylon JS
  39451. * @hidden
  39452. */
  39453. export class PushMaterial extends Material {
  39454. protected _activeEffect: Effect;
  39455. protected _normalMatrix: Matrix;
  39456. /**
  39457. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39458. * This means that the material can keep using a previous shader while a new one is being compiled.
  39459. * This is mostly used when shader parallel compilation is supported (true by default)
  39460. */
  39461. allowShaderHotSwapping: boolean;
  39462. constructor(name: string, scene: Scene);
  39463. getEffect(): Effect;
  39464. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39465. /**
  39466. * Binds the given world matrix to the active effect
  39467. *
  39468. * @param world the matrix to bind
  39469. */
  39470. bindOnlyWorldMatrix(world: Matrix): void;
  39471. /**
  39472. * Binds the given normal matrix to the active effect
  39473. *
  39474. * @param normalMatrix the matrix to bind
  39475. */
  39476. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39477. bind(world: Matrix, mesh?: Mesh): void;
  39478. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39479. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39480. }
  39481. }
  39482. declare module BABYLON {
  39483. /**
  39484. * This groups all the flags used to control the materials channel.
  39485. */
  39486. export class MaterialFlags {
  39487. private static _DiffuseTextureEnabled;
  39488. /**
  39489. * Are diffuse textures enabled in the application.
  39490. */
  39491. static DiffuseTextureEnabled: boolean;
  39492. private static _AmbientTextureEnabled;
  39493. /**
  39494. * Are ambient textures enabled in the application.
  39495. */
  39496. static AmbientTextureEnabled: boolean;
  39497. private static _OpacityTextureEnabled;
  39498. /**
  39499. * Are opacity textures enabled in the application.
  39500. */
  39501. static OpacityTextureEnabled: boolean;
  39502. private static _ReflectionTextureEnabled;
  39503. /**
  39504. * Are reflection textures enabled in the application.
  39505. */
  39506. static ReflectionTextureEnabled: boolean;
  39507. private static _EmissiveTextureEnabled;
  39508. /**
  39509. * Are emissive textures enabled in the application.
  39510. */
  39511. static EmissiveTextureEnabled: boolean;
  39512. private static _SpecularTextureEnabled;
  39513. /**
  39514. * Are specular textures enabled in the application.
  39515. */
  39516. static SpecularTextureEnabled: boolean;
  39517. private static _BumpTextureEnabled;
  39518. /**
  39519. * Are bump textures enabled in the application.
  39520. */
  39521. static BumpTextureEnabled: boolean;
  39522. private static _LightmapTextureEnabled;
  39523. /**
  39524. * Are lightmap textures enabled in the application.
  39525. */
  39526. static LightmapTextureEnabled: boolean;
  39527. private static _RefractionTextureEnabled;
  39528. /**
  39529. * Are refraction textures enabled in the application.
  39530. */
  39531. static RefractionTextureEnabled: boolean;
  39532. private static _ColorGradingTextureEnabled;
  39533. /**
  39534. * Are color grading textures enabled in the application.
  39535. */
  39536. static ColorGradingTextureEnabled: boolean;
  39537. private static _FresnelEnabled;
  39538. /**
  39539. * Are fresnels enabled in the application.
  39540. */
  39541. static FresnelEnabled: boolean;
  39542. private static _ClearCoatTextureEnabled;
  39543. /**
  39544. * Are clear coat textures enabled in the application.
  39545. */
  39546. static ClearCoatTextureEnabled: boolean;
  39547. private static _ClearCoatBumpTextureEnabled;
  39548. /**
  39549. * Are clear coat bump textures enabled in the application.
  39550. */
  39551. static ClearCoatBumpTextureEnabled: boolean;
  39552. private static _ClearCoatTintTextureEnabled;
  39553. /**
  39554. * Are clear coat tint textures enabled in the application.
  39555. */
  39556. static ClearCoatTintTextureEnabled: boolean;
  39557. private static _SheenTextureEnabled;
  39558. /**
  39559. * Are sheen textures enabled in the application.
  39560. */
  39561. static SheenTextureEnabled: boolean;
  39562. private static _AnisotropicTextureEnabled;
  39563. /**
  39564. * Are anisotropic textures enabled in the application.
  39565. */
  39566. static AnisotropicTextureEnabled: boolean;
  39567. private static _ThicknessTextureEnabled;
  39568. /**
  39569. * Are thickness textures enabled in the application.
  39570. */
  39571. static ThicknessTextureEnabled: boolean;
  39572. }
  39573. }
  39574. declare module BABYLON {
  39575. /** @hidden */
  39576. export var defaultFragmentDeclaration: {
  39577. name: string;
  39578. shader: string;
  39579. };
  39580. }
  39581. declare module BABYLON {
  39582. /** @hidden */
  39583. export var defaultUboDeclaration: {
  39584. name: string;
  39585. shader: string;
  39586. };
  39587. }
  39588. declare module BABYLON {
  39589. /** @hidden */
  39590. export var lightFragmentDeclaration: {
  39591. name: string;
  39592. shader: string;
  39593. };
  39594. }
  39595. declare module BABYLON {
  39596. /** @hidden */
  39597. export var lightUboDeclaration: {
  39598. name: string;
  39599. shader: string;
  39600. };
  39601. }
  39602. declare module BABYLON {
  39603. /** @hidden */
  39604. export var lightsFragmentFunctions: {
  39605. name: string;
  39606. shader: string;
  39607. };
  39608. }
  39609. declare module BABYLON {
  39610. /** @hidden */
  39611. export var shadowsFragmentFunctions: {
  39612. name: string;
  39613. shader: string;
  39614. };
  39615. }
  39616. declare module BABYLON {
  39617. /** @hidden */
  39618. export var fresnelFunction: {
  39619. name: string;
  39620. shader: string;
  39621. };
  39622. }
  39623. declare module BABYLON {
  39624. /** @hidden */
  39625. export var reflectionFunction: {
  39626. name: string;
  39627. shader: string;
  39628. };
  39629. }
  39630. declare module BABYLON {
  39631. /** @hidden */
  39632. export var bumpFragmentFunctions: {
  39633. name: string;
  39634. shader: string;
  39635. };
  39636. }
  39637. declare module BABYLON {
  39638. /** @hidden */
  39639. export var logDepthDeclaration: {
  39640. name: string;
  39641. shader: string;
  39642. };
  39643. }
  39644. declare module BABYLON {
  39645. /** @hidden */
  39646. export var bumpFragment: {
  39647. name: string;
  39648. shader: string;
  39649. };
  39650. }
  39651. declare module BABYLON {
  39652. /** @hidden */
  39653. export var depthPrePass: {
  39654. name: string;
  39655. shader: string;
  39656. };
  39657. }
  39658. declare module BABYLON {
  39659. /** @hidden */
  39660. export var lightFragment: {
  39661. name: string;
  39662. shader: string;
  39663. };
  39664. }
  39665. declare module BABYLON {
  39666. /** @hidden */
  39667. export var logDepthFragment: {
  39668. name: string;
  39669. shader: string;
  39670. };
  39671. }
  39672. declare module BABYLON {
  39673. /** @hidden */
  39674. export var defaultPixelShader: {
  39675. name: string;
  39676. shader: string;
  39677. };
  39678. }
  39679. declare module BABYLON {
  39680. /** @hidden */
  39681. export var defaultVertexDeclaration: {
  39682. name: string;
  39683. shader: string;
  39684. };
  39685. }
  39686. declare module BABYLON {
  39687. /** @hidden */
  39688. export var bumpVertexDeclaration: {
  39689. name: string;
  39690. shader: string;
  39691. };
  39692. }
  39693. declare module BABYLON {
  39694. /** @hidden */
  39695. export var bumpVertex: {
  39696. name: string;
  39697. shader: string;
  39698. };
  39699. }
  39700. declare module BABYLON {
  39701. /** @hidden */
  39702. export var fogVertex: {
  39703. name: string;
  39704. shader: string;
  39705. };
  39706. }
  39707. declare module BABYLON {
  39708. /** @hidden */
  39709. export var shadowsVertex: {
  39710. name: string;
  39711. shader: string;
  39712. };
  39713. }
  39714. declare module BABYLON {
  39715. /** @hidden */
  39716. export var pointCloudVertex: {
  39717. name: string;
  39718. shader: string;
  39719. };
  39720. }
  39721. declare module BABYLON {
  39722. /** @hidden */
  39723. export var logDepthVertex: {
  39724. name: string;
  39725. shader: string;
  39726. };
  39727. }
  39728. declare module BABYLON {
  39729. /** @hidden */
  39730. export var defaultVertexShader: {
  39731. name: string;
  39732. shader: string;
  39733. };
  39734. }
  39735. declare module BABYLON {
  39736. /** @hidden */
  39737. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39738. MAINUV1: boolean;
  39739. MAINUV2: boolean;
  39740. DIFFUSE: boolean;
  39741. DIFFUSEDIRECTUV: number;
  39742. AMBIENT: boolean;
  39743. AMBIENTDIRECTUV: number;
  39744. OPACITY: boolean;
  39745. OPACITYDIRECTUV: number;
  39746. OPACITYRGB: boolean;
  39747. REFLECTION: boolean;
  39748. EMISSIVE: boolean;
  39749. EMISSIVEDIRECTUV: number;
  39750. SPECULAR: boolean;
  39751. SPECULARDIRECTUV: number;
  39752. BUMP: boolean;
  39753. BUMPDIRECTUV: number;
  39754. PARALLAX: boolean;
  39755. PARALLAXOCCLUSION: boolean;
  39756. SPECULAROVERALPHA: boolean;
  39757. CLIPPLANE: boolean;
  39758. CLIPPLANE2: boolean;
  39759. CLIPPLANE3: boolean;
  39760. CLIPPLANE4: boolean;
  39761. ALPHATEST: boolean;
  39762. DEPTHPREPASS: boolean;
  39763. ALPHAFROMDIFFUSE: boolean;
  39764. POINTSIZE: boolean;
  39765. FOG: boolean;
  39766. SPECULARTERM: boolean;
  39767. DIFFUSEFRESNEL: boolean;
  39768. OPACITYFRESNEL: boolean;
  39769. REFLECTIONFRESNEL: boolean;
  39770. REFRACTIONFRESNEL: boolean;
  39771. EMISSIVEFRESNEL: boolean;
  39772. FRESNEL: boolean;
  39773. NORMAL: boolean;
  39774. UV1: boolean;
  39775. UV2: boolean;
  39776. VERTEXCOLOR: boolean;
  39777. VERTEXALPHA: boolean;
  39778. NUM_BONE_INFLUENCERS: number;
  39779. BonesPerMesh: number;
  39780. BONETEXTURE: boolean;
  39781. INSTANCES: boolean;
  39782. GLOSSINESS: boolean;
  39783. ROUGHNESS: boolean;
  39784. EMISSIVEASILLUMINATION: boolean;
  39785. LINKEMISSIVEWITHDIFFUSE: boolean;
  39786. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39787. LIGHTMAP: boolean;
  39788. LIGHTMAPDIRECTUV: number;
  39789. OBJECTSPACE_NORMALMAP: boolean;
  39790. USELIGHTMAPASSHADOWMAP: boolean;
  39791. REFLECTIONMAP_3D: boolean;
  39792. REFLECTIONMAP_SPHERICAL: boolean;
  39793. REFLECTIONMAP_PLANAR: boolean;
  39794. REFLECTIONMAP_CUBIC: boolean;
  39795. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39796. REFLECTIONMAP_PROJECTION: boolean;
  39797. REFLECTIONMAP_SKYBOX: boolean;
  39798. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39799. REFLECTIONMAP_EXPLICIT: boolean;
  39800. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39801. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39802. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39803. INVERTCUBICMAP: boolean;
  39804. LOGARITHMICDEPTH: boolean;
  39805. REFRACTION: boolean;
  39806. REFRACTIONMAP_3D: boolean;
  39807. REFLECTIONOVERALPHA: boolean;
  39808. TWOSIDEDLIGHTING: boolean;
  39809. SHADOWFLOAT: boolean;
  39810. MORPHTARGETS: boolean;
  39811. MORPHTARGETS_NORMAL: boolean;
  39812. MORPHTARGETS_TANGENT: boolean;
  39813. MORPHTARGETS_UV: boolean;
  39814. NUM_MORPH_INFLUENCERS: number;
  39815. NONUNIFORMSCALING: boolean;
  39816. PREMULTIPLYALPHA: boolean;
  39817. IMAGEPROCESSING: boolean;
  39818. VIGNETTE: boolean;
  39819. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39820. VIGNETTEBLENDMODEOPAQUE: boolean;
  39821. TONEMAPPING: boolean;
  39822. TONEMAPPING_ACES: boolean;
  39823. CONTRAST: boolean;
  39824. COLORCURVES: boolean;
  39825. COLORGRADING: boolean;
  39826. COLORGRADING3D: boolean;
  39827. SAMPLER3DGREENDEPTH: boolean;
  39828. SAMPLER3DBGRMAP: boolean;
  39829. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39830. MULTIVIEW: boolean;
  39831. /**
  39832. * If the reflection texture on this material is in linear color space
  39833. * @hidden
  39834. */
  39835. IS_REFLECTION_LINEAR: boolean;
  39836. /**
  39837. * If the refraction texture on this material is in linear color space
  39838. * @hidden
  39839. */
  39840. IS_REFRACTION_LINEAR: boolean;
  39841. EXPOSURE: boolean;
  39842. constructor();
  39843. setReflectionMode(modeToEnable: string): void;
  39844. }
  39845. /**
  39846. * This is the default material used in Babylon. It is the best trade off between quality
  39847. * and performances.
  39848. * @see http://doc.babylonjs.com/babylon101/materials
  39849. */
  39850. export class StandardMaterial extends PushMaterial {
  39851. private _diffuseTexture;
  39852. /**
  39853. * The basic texture of the material as viewed under a light.
  39854. */
  39855. diffuseTexture: Nullable<BaseTexture>;
  39856. private _ambientTexture;
  39857. /**
  39858. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39859. */
  39860. ambientTexture: Nullable<BaseTexture>;
  39861. private _opacityTexture;
  39862. /**
  39863. * Define the transparency of the material from a texture.
  39864. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39865. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39866. */
  39867. opacityTexture: Nullable<BaseTexture>;
  39868. private _reflectionTexture;
  39869. /**
  39870. * Define the texture used to display the reflection.
  39871. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39872. */
  39873. reflectionTexture: Nullable<BaseTexture>;
  39874. private _emissiveTexture;
  39875. /**
  39876. * Define texture of the material as if self lit.
  39877. * This will be mixed in the final result even in the absence of light.
  39878. */
  39879. emissiveTexture: Nullable<BaseTexture>;
  39880. private _specularTexture;
  39881. /**
  39882. * Define how the color and intensity of the highlight given by the light in the material.
  39883. */
  39884. specularTexture: Nullable<BaseTexture>;
  39885. private _bumpTexture;
  39886. /**
  39887. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39888. * 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.
  39889. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39890. */
  39891. bumpTexture: Nullable<BaseTexture>;
  39892. private _lightmapTexture;
  39893. /**
  39894. * Complex lighting can be computationally expensive to compute at runtime.
  39895. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39896. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39897. */
  39898. lightmapTexture: Nullable<BaseTexture>;
  39899. private _refractionTexture;
  39900. /**
  39901. * Define the texture used to display the refraction.
  39902. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39903. */
  39904. refractionTexture: Nullable<BaseTexture>;
  39905. /**
  39906. * The color of the material lit by the environmental background lighting.
  39907. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39908. */
  39909. ambientColor: Color3;
  39910. /**
  39911. * The basic color of the material as viewed under a light.
  39912. */
  39913. diffuseColor: Color3;
  39914. /**
  39915. * Define how the color and intensity of the highlight given by the light in the material.
  39916. */
  39917. specularColor: Color3;
  39918. /**
  39919. * Define the color of the material as if self lit.
  39920. * This will be mixed in the final result even in the absence of light.
  39921. */
  39922. emissiveColor: Color3;
  39923. /**
  39924. * Defines how sharp are the highlights in the material.
  39925. * The bigger the value the sharper giving a more glossy feeling to the result.
  39926. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39927. */
  39928. specularPower: number;
  39929. private _useAlphaFromDiffuseTexture;
  39930. /**
  39931. * Does the transparency come from the diffuse texture alpha channel.
  39932. */
  39933. useAlphaFromDiffuseTexture: boolean;
  39934. private _useEmissiveAsIllumination;
  39935. /**
  39936. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39937. */
  39938. useEmissiveAsIllumination: boolean;
  39939. private _linkEmissiveWithDiffuse;
  39940. /**
  39941. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39942. * the emissive level when the final color is close to one.
  39943. */
  39944. linkEmissiveWithDiffuse: boolean;
  39945. private _useSpecularOverAlpha;
  39946. /**
  39947. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39948. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39949. */
  39950. useSpecularOverAlpha: boolean;
  39951. private _useReflectionOverAlpha;
  39952. /**
  39953. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39954. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39955. */
  39956. useReflectionOverAlpha: boolean;
  39957. private _disableLighting;
  39958. /**
  39959. * Does lights from the scene impacts this material.
  39960. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39961. */
  39962. disableLighting: boolean;
  39963. private _useObjectSpaceNormalMap;
  39964. /**
  39965. * Allows using an object space normal map (instead of tangent space).
  39966. */
  39967. useObjectSpaceNormalMap: boolean;
  39968. private _useParallax;
  39969. /**
  39970. * Is parallax enabled or not.
  39971. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39972. */
  39973. useParallax: boolean;
  39974. private _useParallaxOcclusion;
  39975. /**
  39976. * Is parallax occlusion enabled or not.
  39977. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39978. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39979. */
  39980. useParallaxOcclusion: boolean;
  39981. /**
  39982. * 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.
  39983. */
  39984. parallaxScaleBias: number;
  39985. private _roughness;
  39986. /**
  39987. * Helps to define how blurry the reflections should appears in the material.
  39988. */
  39989. roughness: number;
  39990. /**
  39991. * In case of refraction, define the value of the index of refraction.
  39992. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39993. */
  39994. indexOfRefraction: number;
  39995. /**
  39996. * Invert the refraction texture alongside the y axis.
  39997. * It can be useful with procedural textures or probe for instance.
  39998. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39999. */
  40000. invertRefractionY: boolean;
  40001. /**
  40002. * Defines the alpha limits in alpha test mode.
  40003. */
  40004. alphaCutOff: number;
  40005. private _useLightmapAsShadowmap;
  40006. /**
  40007. * In case of light mapping, define whether the map contains light or shadow informations.
  40008. */
  40009. useLightmapAsShadowmap: boolean;
  40010. private _diffuseFresnelParameters;
  40011. /**
  40012. * Define the diffuse fresnel parameters of the material.
  40013. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40014. */
  40015. diffuseFresnelParameters: FresnelParameters;
  40016. private _opacityFresnelParameters;
  40017. /**
  40018. * Define the opacity fresnel parameters of the material.
  40019. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40020. */
  40021. opacityFresnelParameters: FresnelParameters;
  40022. private _reflectionFresnelParameters;
  40023. /**
  40024. * Define the reflection fresnel parameters of the material.
  40025. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40026. */
  40027. reflectionFresnelParameters: FresnelParameters;
  40028. private _refractionFresnelParameters;
  40029. /**
  40030. * Define the refraction fresnel parameters of the material.
  40031. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40032. */
  40033. refractionFresnelParameters: FresnelParameters;
  40034. private _emissiveFresnelParameters;
  40035. /**
  40036. * Define the emissive fresnel parameters of the material.
  40037. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40038. */
  40039. emissiveFresnelParameters: FresnelParameters;
  40040. private _useReflectionFresnelFromSpecular;
  40041. /**
  40042. * If true automatically deducts the fresnels values from the material specularity.
  40043. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40044. */
  40045. useReflectionFresnelFromSpecular: boolean;
  40046. private _useGlossinessFromSpecularMapAlpha;
  40047. /**
  40048. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40049. */
  40050. useGlossinessFromSpecularMapAlpha: boolean;
  40051. private _maxSimultaneousLights;
  40052. /**
  40053. * Defines the maximum number of lights that can be used in the material
  40054. */
  40055. maxSimultaneousLights: number;
  40056. private _invertNormalMapX;
  40057. /**
  40058. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40059. */
  40060. invertNormalMapX: boolean;
  40061. private _invertNormalMapY;
  40062. /**
  40063. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40064. */
  40065. invertNormalMapY: boolean;
  40066. private _twoSidedLighting;
  40067. /**
  40068. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40069. */
  40070. twoSidedLighting: boolean;
  40071. /**
  40072. * Default configuration related to image processing available in the standard Material.
  40073. */
  40074. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40075. /**
  40076. * Gets the image processing configuration used either in this material.
  40077. */
  40078. /**
  40079. * Sets the Default image processing configuration used either in the this material.
  40080. *
  40081. * If sets to null, the scene one is in use.
  40082. */
  40083. imageProcessingConfiguration: ImageProcessingConfiguration;
  40084. /**
  40085. * Keep track of the image processing observer to allow dispose and replace.
  40086. */
  40087. private _imageProcessingObserver;
  40088. /**
  40089. * Attaches a new image processing configuration to the Standard Material.
  40090. * @param configuration
  40091. */
  40092. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40093. /**
  40094. * Gets wether the color curves effect is enabled.
  40095. */
  40096. /**
  40097. * Sets wether the color curves effect is enabled.
  40098. */
  40099. cameraColorCurvesEnabled: boolean;
  40100. /**
  40101. * Gets wether the color grading effect is enabled.
  40102. */
  40103. /**
  40104. * Gets wether the color grading effect is enabled.
  40105. */
  40106. cameraColorGradingEnabled: boolean;
  40107. /**
  40108. * Gets wether tonemapping is enabled or not.
  40109. */
  40110. /**
  40111. * Sets wether tonemapping is enabled or not
  40112. */
  40113. cameraToneMappingEnabled: boolean;
  40114. /**
  40115. * The camera exposure used on this material.
  40116. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40117. * This corresponds to a photographic exposure.
  40118. */
  40119. /**
  40120. * The camera exposure used on this material.
  40121. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40122. * This corresponds to a photographic exposure.
  40123. */
  40124. cameraExposure: number;
  40125. /**
  40126. * Gets The camera contrast used on this material.
  40127. */
  40128. /**
  40129. * Sets The camera contrast used on this material.
  40130. */
  40131. cameraContrast: number;
  40132. /**
  40133. * Gets the Color Grading 2D Lookup Texture.
  40134. */
  40135. /**
  40136. * Sets the Color Grading 2D Lookup Texture.
  40137. */
  40138. cameraColorGradingTexture: Nullable<BaseTexture>;
  40139. /**
  40140. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40141. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40142. * 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;
  40143. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40144. */
  40145. /**
  40146. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40147. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40148. * 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;
  40149. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40150. */
  40151. cameraColorCurves: Nullable<ColorCurves>;
  40152. /**
  40153. * Custom callback helping to override the default shader used in the material.
  40154. */
  40155. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40156. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40157. protected _worldViewProjectionMatrix: Matrix;
  40158. protected _globalAmbientColor: Color3;
  40159. protected _useLogarithmicDepth: boolean;
  40160. /**
  40161. * Instantiates a new standard material.
  40162. * This is the default material used in Babylon. It is the best trade off between quality
  40163. * and performances.
  40164. * @see http://doc.babylonjs.com/babylon101/materials
  40165. * @param name Define the name of the material in the scene
  40166. * @param scene Define the scene the material belong to
  40167. */
  40168. constructor(name: string, scene: Scene);
  40169. /**
  40170. * Gets a boolean indicating that current material needs to register RTT
  40171. */
  40172. readonly hasRenderTargetTextures: boolean;
  40173. /**
  40174. * Gets the current class name of the material e.g. "StandardMaterial"
  40175. * Mainly use in serialization.
  40176. * @returns the class name
  40177. */
  40178. getClassName(): string;
  40179. /**
  40180. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40181. * You can try switching to logarithmic depth.
  40182. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40183. */
  40184. useLogarithmicDepth: boolean;
  40185. /**
  40186. * Specifies if the material will require alpha blending
  40187. * @returns a boolean specifying if alpha blending is needed
  40188. */
  40189. needAlphaBlending(): boolean;
  40190. /**
  40191. * Specifies if this material should be rendered in alpha test mode
  40192. * @returns a boolean specifying if an alpha test is needed.
  40193. */
  40194. needAlphaTesting(): boolean;
  40195. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40196. /**
  40197. * Get the texture used for alpha test purpose.
  40198. * @returns the diffuse texture in case of the standard material.
  40199. */
  40200. getAlphaTestTexture(): Nullable<BaseTexture>;
  40201. /**
  40202. * Get if the submesh is ready to be used and all its information available.
  40203. * Child classes can use it to update shaders
  40204. * @param mesh defines the mesh to check
  40205. * @param subMesh defines which submesh to check
  40206. * @param useInstances specifies that instances should be used
  40207. * @returns a boolean indicating that the submesh is ready or not
  40208. */
  40209. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40210. /**
  40211. * Builds the material UBO layouts.
  40212. * Used internally during the effect preparation.
  40213. */
  40214. buildUniformLayout(): void;
  40215. /**
  40216. * Unbinds the material from the mesh
  40217. */
  40218. unbind(): void;
  40219. /**
  40220. * Binds the submesh to this material by preparing the effect and shader to draw
  40221. * @param world defines the world transformation matrix
  40222. * @param mesh defines the mesh containing the submesh
  40223. * @param subMesh defines the submesh to bind the material to
  40224. */
  40225. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40226. /**
  40227. * Get the list of animatables in the material.
  40228. * @returns the list of animatables object used in the material
  40229. */
  40230. getAnimatables(): IAnimatable[];
  40231. /**
  40232. * Gets the active textures from the material
  40233. * @returns an array of textures
  40234. */
  40235. getActiveTextures(): BaseTexture[];
  40236. /**
  40237. * Specifies if the material uses a texture
  40238. * @param texture defines the texture to check against the material
  40239. * @returns a boolean specifying if the material uses the texture
  40240. */
  40241. hasTexture(texture: BaseTexture): boolean;
  40242. /**
  40243. * Disposes the material
  40244. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40245. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40246. */
  40247. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40248. /**
  40249. * Makes a duplicate of the material, and gives it a new name
  40250. * @param name defines the new name for the duplicated material
  40251. * @returns the cloned material
  40252. */
  40253. clone(name: string): StandardMaterial;
  40254. /**
  40255. * Serializes this material in a JSON representation
  40256. * @returns the serialized material object
  40257. */
  40258. serialize(): any;
  40259. /**
  40260. * Creates a standard material from parsed material data
  40261. * @param source defines the JSON representation of the material
  40262. * @param scene defines the hosting scene
  40263. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40264. * @returns a new standard material
  40265. */
  40266. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40267. /**
  40268. * Are diffuse textures enabled in the application.
  40269. */
  40270. static DiffuseTextureEnabled: boolean;
  40271. /**
  40272. * Are ambient textures enabled in the application.
  40273. */
  40274. static AmbientTextureEnabled: boolean;
  40275. /**
  40276. * Are opacity textures enabled in the application.
  40277. */
  40278. static OpacityTextureEnabled: boolean;
  40279. /**
  40280. * Are reflection textures enabled in the application.
  40281. */
  40282. static ReflectionTextureEnabled: boolean;
  40283. /**
  40284. * Are emissive textures enabled in the application.
  40285. */
  40286. static EmissiveTextureEnabled: boolean;
  40287. /**
  40288. * Are specular textures enabled in the application.
  40289. */
  40290. static SpecularTextureEnabled: boolean;
  40291. /**
  40292. * Are bump textures enabled in the application.
  40293. */
  40294. static BumpTextureEnabled: boolean;
  40295. /**
  40296. * Are lightmap textures enabled in the application.
  40297. */
  40298. static LightmapTextureEnabled: boolean;
  40299. /**
  40300. * Are refraction textures enabled in the application.
  40301. */
  40302. static RefractionTextureEnabled: boolean;
  40303. /**
  40304. * Are color grading textures enabled in the application.
  40305. */
  40306. static ColorGradingTextureEnabled: boolean;
  40307. /**
  40308. * Are fresnels enabled in the application.
  40309. */
  40310. static FresnelEnabled: boolean;
  40311. }
  40312. }
  40313. declare module BABYLON {
  40314. /**
  40315. * A class extending Texture allowing drawing on a texture
  40316. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40317. */
  40318. export class DynamicTexture extends Texture {
  40319. private _generateMipMaps;
  40320. private _canvas;
  40321. private _context;
  40322. private _engine;
  40323. /**
  40324. * Creates a DynamicTexture
  40325. * @param name defines the name of the texture
  40326. * @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
  40327. * @param scene defines the scene where you want the texture
  40328. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40329. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40330. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40331. */
  40332. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40333. /**
  40334. * Get the current class name of the texture useful for serialization or dynamic coding.
  40335. * @returns "DynamicTexture"
  40336. */
  40337. getClassName(): string;
  40338. /**
  40339. * Gets the current state of canRescale
  40340. */
  40341. readonly canRescale: boolean;
  40342. private _recreate;
  40343. /**
  40344. * Scales the texture
  40345. * @param ratio the scale factor to apply to both width and height
  40346. */
  40347. scale(ratio: number): void;
  40348. /**
  40349. * Resizes the texture
  40350. * @param width the new width
  40351. * @param height the new height
  40352. */
  40353. scaleTo(width: number, height: number): void;
  40354. /**
  40355. * Gets the context of the canvas used by the texture
  40356. * @returns the canvas context of the dynamic texture
  40357. */
  40358. getContext(): CanvasRenderingContext2D;
  40359. /**
  40360. * Clears the texture
  40361. */
  40362. clear(): void;
  40363. /**
  40364. * Updates the texture
  40365. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40366. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40367. */
  40368. update(invertY?: boolean, premulAlpha?: boolean): void;
  40369. /**
  40370. * Draws text onto the texture
  40371. * @param text defines the text to be drawn
  40372. * @param x defines the placement of the text from the left
  40373. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40374. * @param font defines the font to be used with font-style, font-size, font-name
  40375. * @param color defines the color used for the text
  40376. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40377. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40378. * @param update defines whether texture is immediately update (default is true)
  40379. */
  40380. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40381. /**
  40382. * Clones the texture
  40383. * @returns the clone of the texture.
  40384. */
  40385. clone(): DynamicTexture;
  40386. /**
  40387. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40388. * @returns a serialized dynamic texture object
  40389. */
  40390. serialize(): any;
  40391. /** @hidden */
  40392. _rebuild(): void;
  40393. }
  40394. }
  40395. declare module BABYLON {
  40396. /** @hidden */
  40397. export var imageProcessingPixelShader: {
  40398. name: string;
  40399. shader: string;
  40400. };
  40401. }
  40402. declare module BABYLON {
  40403. /**
  40404. * ImageProcessingPostProcess
  40405. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40406. */
  40407. export class ImageProcessingPostProcess extends PostProcess {
  40408. /**
  40409. * Default configuration related to image processing available in the PBR Material.
  40410. */
  40411. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40412. /**
  40413. * Gets the image processing configuration used either in this material.
  40414. */
  40415. /**
  40416. * Sets the Default image processing configuration used either in the this material.
  40417. *
  40418. * If sets to null, the scene one is in use.
  40419. */
  40420. imageProcessingConfiguration: ImageProcessingConfiguration;
  40421. /**
  40422. * Keep track of the image processing observer to allow dispose and replace.
  40423. */
  40424. private _imageProcessingObserver;
  40425. /**
  40426. * Attaches a new image processing configuration to the PBR Material.
  40427. * @param configuration
  40428. */
  40429. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40430. /**
  40431. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40432. */
  40433. /**
  40434. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40435. */
  40436. colorCurves: Nullable<ColorCurves>;
  40437. /**
  40438. * Gets wether the color curves effect is enabled.
  40439. */
  40440. /**
  40441. * Sets wether the color curves effect is enabled.
  40442. */
  40443. colorCurvesEnabled: boolean;
  40444. /**
  40445. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40446. */
  40447. /**
  40448. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40449. */
  40450. colorGradingTexture: Nullable<BaseTexture>;
  40451. /**
  40452. * Gets wether the color grading effect is enabled.
  40453. */
  40454. /**
  40455. * Gets wether the color grading effect is enabled.
  40456. */
  40457. colorGradingEnabled: boolean;
  40458. /**
  40459. * Gets exposure used in the effect.
  40460. */
  40461. /**
  40462. * Sets exposure used in the effect.
  40463. */
  40464. exposure: number;
  40465. /**
  40466. * Gets wether tonemapping is enabled or not.
  40467. */
  40468. /**
  40469. * Sets wether tonemapping is enabled or not
  40470. */
  40471. toneMappingEnabled: boolean;
  40472. /**
  40473. * Gets the type of tone mapping effect.
  40474. */
  40475. /**
  40476. * Sets the type of tone mapping effect.
  40477. */
  40478. toneMappingType: number;
  40479. /**
  40480. * Gets contrast used in the effect.
  40481. */
  40482. /**
  40483. * Sets contrast used in the effect.
  40484. */
  40485. contrast: number;
  40486. /**
  40487. * Gets Vignette stretch size.
  40488. */
  40489. /**
  40490. * Sets Vignette stretch size.
  40491. */
  40492. vignetteStretch: number;
  40493. /**
  40494. * Gets Vignette centre X Offset.
  40495. */
  40496. /**
  40497. * Sets Vignette centre X Offset.
  40498. */
  40499. vignetteCentreX: number;
  40500. /**
  40501. * Gets Vignette centre Y Offset.
  40502. */
  40503. /**
  40504. * Sets Vignette centre Y Offset.
  40505. */
  40506. vignetteCentreY: number;
  40507. /**
  40508. * Gets Vignette weight or intensity of the vignette effect.
  40509. */
  40510. /**
  40511. * Sets Vignette weight or intensity of the vignette effect.
  40512. */
  40513. vignetteWeight: number;
  40514. /**
  40515. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40516. * if vignetteEnabled is set to true.
  40517. */
  40518. /**
  40519. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40520. * if vignetteEnabled is set to true.
  40521. */
  40522. vignetteColor: Color4;
  40523. /**
  40524. * Gets Camera field of view used by the Vignette effect.
  40525. */
  40526. /**
  40527. * Sets Camera field of view used by the Vignette effect.
  40528. */
  40529. vignetteCameraFov: number;
  40530. /**
  40531. * Gets the vignette blend mode allowing different kind of effect.
  40532. */
  40533. /**
  40534. * Sets the vignette blend mode allowing different kind of effect.
  40535. */
  40536. vignetteBlendMode: number;
  40537. /**
  40538. * Gets wether the vignette effect is enabled.
  40539. */
  40540. /**
  40541. * Sets wether the vignette effect is enabled.
  40542. */
  40543. vignetteEnabled: boolean;
  40544. private _fromLinearSpace;
  40545. /**
  40546. * Gets wether the input of the processing is in Gamma or Linear Space.
  40547. */
  40548. /**
  40549. * Sets wether the input of the processing is in Gamma or Linear Space.
  40550. */
  40551. fromLinearSpace: boolean;
  40552. /**
  40553. * Defines cache preventing GC.
  40554. */
  40555. private _defines;
  40556. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40557. /**
  40558. * "ImageProcessingPostProcess"
  40559. * @returns "ImageProcessingPostProcess"
  40560. */
  40561. getClassName(): string;
  40562. protected _updateParameters(): void;
  40563. dispose(camera?: Camera): void;
  40564. }
  40565. }
  40566. declare module BABYLON {
  40567. /**
  40568. * Class containing static functions to help procedurally build meshes
  40569. */
  40570. export class GroundBuilder {
  40571. /**
  40572. * Creates a ground mesh
  40573. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40574. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40576. * @param name defines the name of the mesh
  40577. * @param options defines the options used to create the mesh
  40578. * @param scene defines the hosting scene
  40579. * @returns the ground mesh
  40580. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40581. */
  40582. static CreateGround(name: string, options: {
  40583. width?: number;
  40584. height?: number;
  40585. subdivisions?: number;
  40586. subdivisionsX?: number;
  40587. subdivisionsY?: number;
  40588. updatable?: boolean;
  40589. }, scene: any): Mesh;
  40590. /**
  40591. * Creates a tiled ground mesh
  40592. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40593. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40594. * * 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
  40595. * * 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
  40596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40597. * @param name defines the name of the mesh
  40598. * @param options defines the options used to create the mesh
  40599. * @param scene defines the hosting scene
  40600. * @returns the tiled ground mesh
  40601. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40602. */
  40603. static CreateTiledGround(name: string, options: {
  40604. xmin: number;
  40605. zmin: number;
  40606. xmax: number;
  40607. zmax: number;
  40608. subdivisions?: {
  40609. w: number;
  40610. h: number;
  40611. };
  40612. precision?: {
  40613. w: number;
  40614. h: number;
  40615. };
  40616. updatable?: boolean;
  40617. }, scene?: Nullable<Scene>): Mesh;
  40618. /**
  40619. * Creates a ground mesh from a height map
  40620. * * The parameter `url` sets the URL of the height map image resource.
  40621. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40622. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40623. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40624. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40625. * * 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.
  40626. * * 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).
  40627. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40628. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40629. * @param name defines the name of the mesh
  40630. * @param url defines the url to the height map
  40631. * @param options defines the options used to create the mesh
  40632. * @param scene defines the hosting scene
  40633. * @returns the ground mesh
  40634. * @see https://doc.babylonjs.com/babylon101/height_map
  40635. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40636. */
  40637. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40638. width?: number;
  40639. height?: number;
  40640. subdivisions?: number;
  40641. minHeight?: number;
  40642. maxHeight?: number;
  40643. colorFilter?: Color3;
  40644. alphaFilter?: number;
  40645. updatable?: boolean;
  40646. onReady?: (mesh: GroundMesh) => void;
  40647. }, scene?: Nullable<Scene>): GroundMesh;
  40648. }
  40649. }
  40650. declare module BABYLON {
  40651. /**
  40652. * Class containing static functions to help procedurally build meshes
  40653. */
  40654. export class TorusBuilder {
  40655. /**
  40656. * Creates a torus mesh
  40657. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40658. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40659. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40660. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40661. * * 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
  40662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40663. * @param name defines the name of the mesh
  40664. * @param options defines the options used to create the mesh
  40665. * @param scene defines the hosting scene
  40666. * @returns the torus mesh
  40667. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40668. */
  40669. static CreateTorus(name: string, options: {
  40670. diameter?: number;
  40671. thickness?: number;
  40672. tessellation?: number;
  40673. updatable?: boolean;
  40674. sideOrientation?: number;
  40675. frontUVs?: Vector4;
  40676. backUVs?: Vector4;
  40677. }, scene: any): Mesh;
  40678. }
  40679. }
  40680. declare module BABYLON {
  40681. /**
  40682. * Class containing static functions to help procedurally build meshes
  40683. */
  40684. export class CylinderBuilder {
  40685. /**
  40686. * Creates a cylinder or a cone mesh
  40687. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40688. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40689. * * 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.
  40690. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40691. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40692. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40693. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40694. * * 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).
  40695. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40696. * * 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).
  40697. * * 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
  40698. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40699. * * 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
  40700. * * 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.
  40701. * * If `enclose` is false, a ring surface is one element.
  40702. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40703. * * 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
  40704. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40705. * * 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
  40706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40707. * @param name defines the name of the mesh
  40708. * @param options defines the options used to create the mesh
  40709. * @param scene defines the hosting scene
  40710. * @returns the cylinder mesh
  40711. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40712. */
  40713. static CreateCylinder(name: string, options: {
  40714. height?: number;
  40715. diameterTop?: number;
  40716. diameterBottom?: number;
  40717. diameter?: number;
  40718. tessellation?: number;
  40719. subdivisions?: number;
  40720. arc?: number;
  40721. faceColors?: Color4[];
  40722. faceUV?: Vector4[];
  40723. updatable?: boolean;
  40724. hasRings?: boolean;
  40725. enclose?: boolean;
  40726. cap?: number;
  40727. sideOrientation?: number;
  40728. frontUVs?: Vector4;
  40729. backUVs?: Vector4;
  40730. }, scene: any): Mesh;
  40731. }
  40732. }
  40733. declare module BABYLON {
  40734. /**
  40735. * Options to modify the vr teleportation behavior.
  40736. */
  40737. export interface VRTeleportationOptions {
  40738. /**
  40739. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40740. */
  40741. floorMeshName?: string;
  40742. /**
  40743. * A list of meshes to be used as the teleportation floor. (default: empty)
  40744. */
  40745. floorMeshes?: Mesh[];
  40746. }
  40747. /**
  40748. * Options to modify the vr experience helper's behavior.
  40749. */
  40750. export interface VRExperienceHelperOptions extends WebVROptions {
  40751. /**
  40752. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40753. */
  40754. createDeviceOrientationCamera?: boolean;
  40755. /**
  40756. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40757. */
  40758. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40759. /**
  40760. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40761. */
  40762. laserToggle?: boolean;
  40763. /**
  40764. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40765. */
  40766. floorMeshes?: Mesh[];
  40767. /**
  40768. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40769. */
  40770. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40771. }
  40772. /**
  40773. * Event containing information after VR has been entered
  40774. */
  40775. export class OnAfterEnteringVRObservableEvent {
  40776. /**
  40777. * If entering vr was successful
  40778. */
  40779. success: boolean;
  40780. }
  40781. /**
  40782. * Helps to quickly add VR support to an existing scene.
  40783. * See http://doc.babylonjs.com/how_to/webvr_helper
  40784. */
  40785. export class VRExperienceHelper {
  40786. /** Options to modify the vr experience helper's behavior. */
  40787. webVROptions: VRExperienceHelperOptions;
  40788. private _scene;
  40789. private _position;
  40790. private _btnVR;
  40791. private _btnVRDisplayed;
  40792. private _webVRsupported;
  40793. private _webVRready;
  40794. private _webVRrequesting;
  40795. private _webVRpresenting;
  40796. private _hasEnteredVR;
  40797. private _fullscreenVRpresenting;
  40798. private _canvas;
  40799. private _webVRCamera;
  40800. private _vrDeviceOrientationCamera;
  40801. private _deviceOrientationCamera;
  40802. private _existingCamera;
  40803. private _onKeyDown;
  40804. private _onVrDisplayPresentChange;
  40805. private _onVRDisplayChanged;
  40806. private _onVRRequestPresentStart;
  40807. private _onVRRequestPresentComplete;
  40808. /**
  40809. * 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)
  40810. */
  40811. enableGazeEvenWhenNoPointerLock: boolean;
  40812. /**
  40813. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  40814. */
  40815. exitVROnDoubleTap: boolean;
  40816. /**
  40817. * Observable raised right before entering VR.
  40818. */
  40819. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40820. /**
  40821. * Observable raised when entering VR has completed.
  40822. */
  40823. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40824. /**
  40825. * Observable raised when exiting VR.
  40826. */
  40827. onExitingVRObservable: Observable<VRExperienceHelper>;
  40828. /**
  40829. * Observable raised when controller mesh is loaded.
  40830. */
  40831. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40832. /** Return this.onEnteringVRObservable
  40833. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40834. */
  40835. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40836. /** Return this.onExitingVRObservable
  40837. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40838. */
  40839. readonly onExitingVR: Observable<VRExperienceHelper>;
  40840. /** Return this.onControllerMeshLoadedObservable
  40841. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40842. */
  40843. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40844. private _rayLength;
  40845. private _useCustomVRButton;
  40846. private _teleportationRequested;
  40847. private _teleportActive;
  40848. private _floorMeshName;
  40849. private _floorMeshesCollection;
  40850. private _rotationAllowed;
  40851. private _teleportBackwardsVector;
  40852. private _teleportationTarget;
  40853. private _isDefaultTeleportationTarget;
  40854. private _postProcessMove;
  40855. private _teleportationFillColor;
  40856. private _teleportationBorderColor;
  40857. private _rotationAngle;
  40858. private _haloCenter;
  40859. private _cameraGazer;
  40860. private _padSensibilityUp;
  40861. private _padSensibilityDown;
  40862. private _leftController;
  40863. private _rightController;
  40864. /**
  40865. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40866. */
  40867. onNewMeshSelected: Observable<AbstractMesh>;
  40868. /**
  40869. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40870. */
  40871. onNewMeshPicked: Observable<PickingInfo>;
  40872. private _circleEase;
  40873. /**
  40874. * Observable raised before camera teleportation
  40875. */
  40876. onBeforeCameraTeleport: Observable<Vector3>;
  40877. /**
  40878. * Observable raised after camera teleportation
  40879. */
  40880. onAfterCameraTeleport: Observable<Vector3>;
  40881. /**
  40882. * Observable raised when current selected mesh gets unselected
  40883. */
  40884. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40885. private _raySelectionPredicate;
  40886. /**
  40887. * To be optionaly changed by user to define custom ray selection
  40888. */
  40889. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40890. /**
  40891. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40892. */
  40893. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40894. /**
  40895. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40896. */
  40897. teleportationEnabled: boolean;
  40898. private _defaultHeight;
  40899. private _teleportationInitialized;
  40900. private _interactionsEnabled;
  40901. private _interactionsRequested;
  40902. private _displayGaze;
  40903. private _displayLaserPointer;
  40904. /**
  40905. * The mesh used to display where the user is going to teleport.
  40906. */
  40907. /**
  40908. * Sets the mesh to be used to display where the user is going to teleport.
  40909. */
  40910. teleportationTarget: Mesh;
  40911. /**
  40912. * 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
  40913. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40914. * See http://doc.babylonjs.com/resources/baking_transformations
  40915. */
  40916. gazeTrackerMesh: Mesh;
  40917. /**
  40918. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40919. */
  40920. updateGazeTrackerScale: boolean;
  40921. /**
  40922. * If the gaze trackers color should be updated when selecting meshes
  40923. */
  40924. updateGazeTrackerColor: boolean;
  40925. /**
  40926. * The gaze tracking mesh corresponding to the left controller
  40927. */
  40928. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40929. /**
  40930. * The gaze tracking mesh corresponding to the right controller
  40931. */
  40932. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40933. /**
  40934. * If the ray of the gaze should be displayed.
  40935. */
  40936. /**
  40937. * Sets if the ray of the gaze should be displayed.
  40938. */
  40939. displayGaze: boolean;
  40940. /**
  40941. * If the ray of the LaserPointer should be displayed.
  40942. */
  40943. /**
  40944. * Sets if the ray of the LaserPointer should be displayed.
  40945. */
  40946. displayLaserPointer: boolean;
  40947. /**
  40948. * The deviceOrientationCamera used as the camera when not in VR.
  40949. */
  40950. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40951. /**
  40952. * Based on the current WebVR support, returns the current VR camera used.
  40953. */
  40954. readonly currentVRCamera: Nullable<Camera>;
  40955. /**
  40956. * The webVRCamera which is used when in VR.
  40957. */
  40958. readonly webVRCamera: WebVRFreeCamera;
  40959. /**
  40960. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40961. */
  40962. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40963. /**
  40964. * The html button that is used to trigger entering into VR.
  40965. */
  40966. readonly vrButton: Nullable<HTMLButtonElement>;
  40967. private readonly _teleportationRequestInitiated;
  40968. /**
  40969. * Defines wether or not Pointer lock should be requested when switching to
  40970. * full screen.
  40971. */
  40972. requestPointerLockOnFullScreen: boolean;
  40973. /**
  40974. * Instantiates a VRExperienceHelper.
  40975. * Helps to quickly add VR support to an existing scene.
  40976. * @param scene The scene the VRExperienceHelper belongs to.
  40977. * @param webVROptions Options to modify the vr experience helper's behavior.
  40978. */
  40979. constructor(scene: Scene,
  40980. /** Options to modify the vr experience helper's behavior. */
  40981. webVROptions?: VRExperienceHelperOptions);
  40982. private _onDefaultMeshLoaded;
  40983. private _onResize;
  40984. private _onFullscreenChange;
  40985. /**
  40986. * Gets a value indicating if we are currently in VR mode.
  40987. */
  40988. readonly isInVRMode: boolean;
  40989. private onVrDisplayPresentChange;
  40990. private onVRDisplayChanged;
  40991. private moveButtonToBottomRight;
  40992. private displayVRButton;
  40993. private updateButtonVisibility;
  40994. private _cachedAngularSensibility;
  40995. /**
  40996. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40997. * Otherwise, will use the fullscreen API.
  40998. */
  40999. enterVR(): void;
  41000. /**
  41001. * Attempt to exit VR, or fullscreen.
  41002. */
  41003. exitVR(): void;
  41004. /**
  41005. * The position of the vr experience helper.
  41006. */
  41007. /**
  41008. * Sets the position of the vr experience helper.
  41009. */
  41010. position: Vector3;
  41011. /**
  41012. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41013. */
  41014. enableInteractions(): void;
  41015. private readonly _noControllerIsActive;
  41016. private beforeRender;
  41017. private _isTeleportationFloor;
  41018. /**
  41019. * Adds a floor mesh to be used for teleportation.
  41020. * @param floorMesh the mesh to be used for teleportation.
  41021. */
  41022. addFloorMesh(floorMesh: Mesh): void;
  41023. /**
  41024. * Removes a floor mesh from being used for teleportation.
  41025. * @param floorMesh the mesh to be removed.
  41026. */
  41027. removeFloorMesh(floorMesh: Mesh): void;
  41028. /**
  41029. * Enables interactions and teleportation using the VR controllers and gaze.
  41030. * @param vrTeleportationOptions options to modify teleportation behavior.
  41031. */
  41032. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41033. private _onNewGamepadConnected;
  41034. private _tryEnableInteractionOnController;
  41035. private _onNewGamepadDisconnected;
  41036. private _enableInteractionOnController;
  41037. private _checkTeleportWithRay;
  41038. private _checkRotate;
  41039. private _checkTeleportBackwards;
  41040. private _enableTeleportationOnController;
  41041. private _createTeleportationCircles;
  41042. private _displayTeleportationTarget;
  41043. private _hideTeleportationTarget;
  41044. private _rotateCamera;
  41045. private _moveTeleportationSelectorTo;
  41046. private _workingVector;
  41047. private _workingQuaternion;
  41048. private _workingMatrix;
  41049. /**
  41050. * Teleports the users feet to the desired location
  41051. * @param location The location where the user's feet should be placed
  41052. */
  41053. teleportCamera(location: Vector3): void;
  41054. private _convertNormalToDirectionOfRay;
  41055. private _castRayAndSelectObject;
  41056. private _notifySelectedMeshUnselected;
  41057. /**
  41058. * Sets the color of the laser ray from the vr controllers.
  41059. * @param color new color for the ray.
  41060. */
  41061. changeLaserColor(color: Color3): void;
  41062. /**
  41063. * Sets the color of the ray from the vr headsets gaze.
  41064. * @param color new color for the ray.
  41065. */
  41066. changeGazeColor(color: Color3): void;
  41067. /**
  41068. * Exits VR and disposes of the vr experience helper
  41069. */
  41070. dispose(): void;
  41071. /**
  41072. * Gets the name of the VRExperienceHelper class
  41073. * @returns "VRExperienceHelper"
  41074. */
  41075. getClassName(): string;
  41076. }
  41077. }
  41078. declare module BABYLON {
  41079. /**
  41080. * Manages an XRSession to work with Babylon's engine
  41081. * @see https://doc.babylonjs.com/how_to/webxr
  41082. */
  41083. export class WebXRSessionManager implements IDisposable {
  41084. private scene;
  41085. /**
  41086. * Fires every time a new xrFrame arrives which can be used to update the camera
  41087. */
  41088. onXRFrameObservable: Observable<any>;
  41089. /**
  41090. * Fires when the xr session is ended either by the device or manually done
  41091. */
  41092. onXRSessionEnded: Observable<any>;
  41093. /**
  41094. * Underlying xr session
  41095. */
  41096. session: XRSession;
  41097. /**
  41098. * Type of reference space used when creating the session
  41099. */
  41100. referenceSpace: XRReferenceSpace;
  41101. /** @hidden */
  41102. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41103. /**
  41104. * Current XR frame
  41105. */
  41106. currentFrame: Nullable<XRFrame>;
  41107. private _xrNavigator;
  41108. private baseLayer;
  41109. /**
  41110. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41111. * @param scene The scene which the session should be created for
  41112. */
  41113. constructor(scene: Scene);
  41114. /**
  41115. * Initializes the manager
  41116. * After initialization enterXR can be called to start an XR session
  41117. * @returns Promise which resolves after it is initialized
  41118. */
  41119. initializeAsync(): Promise<void>;
  41120. /**
  41121. * Initializes an xr session
  41122. * @param xrSessionMode mode to initialize
  41123. * @returns a promise which will resolve once the session has been initialized
  41124. */
  41125. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  41126. /**
  41127. * Sets the reference space on the xr session
  41128. * @param referenceSpace space to set
  41129. * @returns a promise that will resolve once the reference space has been set
  41130. */
  41131. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41132. /**
  41133. * Updates the render state of the session
  41134. * @param state state to set
  41135. * @returns a promise that resolves once the render state has been updated
  41136. */
  41137. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41138. /**
  41139. * Starts rendering to the xr layer
  41140. * @returns a promise that will resolve once rendering has started
  41141. */
  41142. startRenderingToXRAsync(): Promise<void>;
  41143. /**
  41144. * Stops the xrSession and restores the renderloop
  41145. * @returns Promise which resolves after it exits XR
  41146. */
  41147. exitXRAsync(): Promise<unknown>;
  41148. /**
  41149. * Checks if a session would be supported for the creation options specified
  41150. * @param sessionMode session mode to check if supported eg. immersive-vr
  41151. * @returns true if supported
  41152. */
  41153. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41154. /**
  41155. * @hidden
  41156. * Converts the render layer of xrSession to a render target
  41157. * @param session session to create render target for
  41158. * @param scene scene the new render target should be created for
  41159. */
  41160. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41161. /**
  41162. * Disposes of the session manager
  41163. */
  41164. dispose(): void;
  41165. }
  41166. }
  41167. declare module BABYLON {
  41168. /**
  41169. * WebXR Camera which holds the views for the xrSession
  41170. * @see https://doc.babylonjs.com/how_to/webxr
  41171. */
  41172. export class WebXRCamera extends FreeCamera {
  41173. private static _TmpMatrix;
  41174. /**
  41175. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41176. * @param name the name of the camera
  41177. * @param scene the scene to add the camera to
  41178. */
  41179. constructor(name: string, scene: Scene);
  41180. private _updateNumberOfRigCameras;
  41181. /** @hidden */
  41182. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41183. /**
  41184. * Updates the cameras position from the current pose information of the XR session
  41185. * @param xrSessionManager the session containing pose information
  41186. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41187. */
  41188. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41189. }
  41190. }
  41191. declare module BABYLON {
  41192. /**
  41193. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41194. */
  41195. export class WebXRManagedOutputCanvas implements IDisposable {
  41196. private helper;
  41197. private _canvas;
  41198. /**
  41199. * xrpresent context of the canvas which can be used to display/mirror xr content
  41200. */
  41201. canvasContext: WebGLRenderingContext;
  41202. /**
  41203. * xr layer for the canvas
  41204. */
  41205. xrLayer: Nullable<XRWebGLLayer>;
  41206. /**
  41207. * Initializes the xr layer for the session
  41208. * @param xrSession xr session
  41209. * @returns a promise that will resolve once the XR Layer has been created
  41210. */
  41211. initializeXRLayerAsync(xrSession: any): any;
  41212. /**
  41213. * Initializes the canvas to be added/removed upon entering/exiting xr
  41214. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41215. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41216. */
  41217. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41218. /**
  41219. * Disposes of the object
  41220. */
  41221. dispose(): void;
  41222. private _setManagedOutputCanvas;
  41223. private _addCanvas;
  41224. private _removeCanvas;
  41225. }
  41226. }
  41227. declare module BABYLON {
  41228. /**
  41229. * States of the webXR experience
  41230. */
  41231. export enum WebXRState {
  41232. /**
  41233. * Transitioning to being in XR mode
  41234. */
  41235. ENTERING_XR = 0,
  41236. /**
  41237. * Transitioning to non XR mode
  41238. */
  41239. EXITING_XR = 1,
  41240. /**
  41241. * In XR mode and presenting
  41242. */
  41243. IN_XR = 2,
  41244. /**
  41245. * Not entered XR mode
  41246. */
  41247. NOT_IN_XR = 3
  41248. }
  41249. /**
  41250. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41251. * @see https://doc.babylonjs.com/how_to/webxr
  41252. */
  41253. export class WebXRExperienceHelper implements IDisposable {
  41254. private scene;
  41255. /**
  41256. * 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
  41257. */
  41258. container: AbstractMesh;
  41259. /**
  41260. * Camera used to render xr content
  41261. */
  41262. camera: WebXRCamera;
  41263. /**
  41264. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41265. */
  41266. state: WebXRState;
  41267. private _setState;
  41268. private static _TmpVector;
  41269. /**
  41270. * Fires when the state of the experience helper has changed
  41271. */
  41272. onStateChangedObservable: Observable<WebXRState>;
  41273. /** Session manager used to keep track of xr session */
  41274. sessionManager: WebXRSessionManager;
  41275. private _nonVRCamera;
  41276. private _originalSceneAutoClear;
  41277. private _supported;
  41278. /**
  41279. * Creates the experience helper
  41280. * @param scene the scene to attach the experience helper to
  41281. * @returns a promise for the experience helper
  41282. */
  41283. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41284. /**
  41285. * Creates a WebXRExperienceHelper
  41286. * @param scene The scene the helper should be created in
  41287. */
  41288. private constructor();
  41289. /**
  41290. * Exits XR mode and returns the scene to its original state
  41291. * @returns promise that resolves after xr mode has exited
  41292. */
  41293. exitXRAsync(): Promise<unknown>;
  41294. /**
  41295. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41296. * @param sessionCreationOptions options for the XR session
  41297. * @param referenceSpaceType frame of reference of the XR session
  41298. * @param outputCanvas the output canvas that will be used to enter XR mode
  41299. * @returns promise that resolves after xr mode has entered
  41300. */
  41301. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  41302. /**
  41303. * Updates the global position of the camera by moving the camera's container
  41304. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41305. * @param position The desired global position of the camera
  41306. */
  41307. setPositionOfCameraUsingContainer(position: Vector3): void;
  41308. /**
  41309. * Rotates the xr camera by rotating the camera's container around the camera's position
  41310. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41311. * @param rotation the desired quaternion rotation to apply to the camera
  41312. */
  41313. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41314. /**
  41315. * Disposes of the experience helper
  41316. */
  41317. dispose(): void;
  41318. }
  41319. }
  41320. declare module BABYLON {
  41321. /**
  41322. * Button which can be used to enter a different mode of XR
  41323. */
  41324. export class WebXREnterExitUIButton {
  41325. /** button element */
  41326. element: HTMLElement;
  41327. /** XR initialization options for the button */
  41328. sessionMode: XRSessionMode;
  41329. /** Reference space type */
  41330. referenceSpaceType: XRReferenceSpaceType;
  41331. /**
  41332. * Creates a WebXREnterExitUIButton
  41333. * @param element button element
  41334. * @param sessionMode XR initialization session mode
  41335. * @param referenceSpaceType the type of reference space to be used
  41336. */
  41337. constructor(
  41338. /** button element */
  41339. element: HTMLElement,
  41340. /** XR initialization options for the button */
  41341. sessionMode: XRSessionMode,
  41342. /** Reference space type */
  41343. referenceSpaceType: XRReferenceSpaceType);
  41344. /**
  41345. * Overwritable function which can be used to update the button's visuals when the state changes
  41346. * @param activeButton the current active button in the UI
  41347. */
  41348. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41349. }
  41350. /**
  41351. * Options to create the webXR UI
  41352. */
  41353. export class WebXREnterExitUIOptions {
  41354. /**
  41355. * Context to enter xr with
  41356. */
  41357. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  41358. /**
  41359. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41360. */
  41361. customButtons?: Array<WebXREnterExitUIButton>;
  41362. }
  41363. /**
  41364. * UI to allow the user to enter/exit XR mode
  41365. */
  41366. export class WebXREnterExitUI implements IDisposable {
  41367. private scene;
  41368. private _overlay;
  41369. private _buttons;
  41370. private _activeButton;
  41371. /**
  41372. * Fired every time the active button is changed.
  41373. *
  41374. * When xr is entered via a button that launches xr that button will be the callback parameter
  41375. *
  41376. * When exiting xr the callback parameter will be null)
  41377. */
  41378. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41379. /**
  41380. * Creates UI to allow the user to enter/exit XR mode
  41381. * @param scene the scene to add the ui to
  41382. * @param helper the xr experience helper to enter/exit xr with
  41383. * @param options options to configure the UI
  41384. * @returns the created ui
  41385. */
  41386. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41387. private constructor();
  41388. private _updateButtons;
  41389. /**
  41390. * Disposes of the object
  41391. */
  41392. dispose(): void;
  41393. }
  41394. }
  41395. declare module BABYLON {
  41396. /**
  41397. * Represents an XR input
  41398. */
  41399. export class WebXRController {
  41400. private scene;
  41401. /** The underlying input source for the controller */
  41402. inputSource: XRInputSource;
  41403. private parentContainer;
  41404. /**
  41405. * 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
  41406. */
  41407. grip?: AbstractMesh;
  41408. /**
  41409. * Pointer which can be used to select objects or attach a visible laser to
  41410. */
  41411. pointer: AbstractMesh;
  41412. /**
  41413. * Event that fires when the controller is removed/disposed
  41414. */
  41415. onDisposeObservable: Observable<{}>;
  41416. private _tmpMatrix;
  41417. private _tmpQuaternion;
  41418. private _tmpVector;
  41419. /**
  41420. * Creates the controller
  41421. * @see https://doc.babylonjs.com/how_to/webxr
  41422. * @param scene the scene which the controller should be associated to
  41423. * @param inputSource the underlying input source for the controller
  41424. * @param parentContainer parent that the controller meshes should be children of
  41425. */
  41426. constructor(scene: Scene,
  41427. /** The underlying input source for the controller */
  41428. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41429. /**
  41430. * Updates the controller pose based on the given XRFrame
  41431. * @param xrFrame xr frame to update the pose with
  41432. * @param referenceSpace reference space to use
  41433. */
  41434. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41435. /**
  41436. * Gets a world space ray coming from the controller
  41437. * @param result the resulting ray
  41438. */
  41439. getWorldPointerRayToRef(result: Ray): void;
  41440. /**
  41441. * Disposes of the object
  41442. */
  41443. dispose(): void;
  41444. }
  41445. }
  41446. declare module BABYLON {
  41447. /**
  41448. * XR input used to track XR inputs such as controllers/rays
  41449. */
  41450. export class WebXRInput implements IDisposable {
  41451. /**
  41452. * Base experience the input listens to
  41453. */
  41454. baseExperience: WebXRExperienceHelper;
  41455. /**
  41456. * XR controllers being tracked
  41457. */
  41458. controllers: Array<WebXRController>;
  41459. private _frameObserver;
  41460. private _stateObserver;
  41461. /**
  41462. * Event when a controller has been connected/added
  41463. */
  41464. onControllerAddedObservable: Observable<WebXRController>;
  41465. /**
  41466. * Event when a controller has been removed/disconnected
  41467. */
  41468. onControllerRemovedObservable: Observable<WebXRController>;
  41469. /**
  41470. * Initializes the WebXRInput
  41471. * @param baseExperience experience helper which the input should be created for
  41472. */
  41473. constructor(
  41474. /**
  41475. * Base experience the input listens to
  41476. */
  41477. baseExperience: WebXRExperienceHelper);
  41478. private _onInputSourcesChange;
  41479. private _addAndRemoveControllers;
  41480. /**
  41481. * Disposes of the object
  41482. */
  41483. dispose(): void;
  41484. }
  41485. }
  41486. declare module BABYLON {
  41487. /**
  41488. * Enables teleportation
  41489. */
  41490. export class WebXRControllerTeleportation {
  41491. private _teleportationFillColor;
  41492. private _teleportationBorderColor;
  41493. private _tmpRay;
  41494. private _tmpVector;
  41495. /**
  41496. * Creates a WebXRControllerTeleportation
  41497. * @param input input manager to add teleportation to
  41498. * @param floorMeshes floormeshes which can be teleported to
  41499. */
  41500. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41501. }
  41502. }
  41503. declare module BABYLON {
  41504. /**
  41505. * Handles pointer input automatically for the pointer of XR controllers
  41506. */
  41507. export class WebXRControllerPointerSelection {
  41508. private static _idCounter;
  41509. private _tmpRay;
  41510. /**
  41511. * Creates a WebXRControllerPointerSelection
  41512. * @param input input manager to setup pointer selection
  41513. */
  41514. constructor(input: WebXRInput);
  41515. private _convertNormalToDirectionOfRay;
  41516. private _updatePointerDistance;
  41517. }
  41518. }
  41519. declare module BABYLON {
  41520. /**
  41521. * Class used to represent data loading progression
  41522. */
  41523. export class SceneLoaderProgressEvent {
  41524. /** defines if data length to load can be evaluated */
  41525. readonly lengthComputable: boolean;
  41526. /** defines the loaded data length */
  41527. readonly loaded: number;
  41528. /** defines the data length to load */
  41529. readonly total: number;
  41530. /**
  41531. * Create a new progress event
  41532. * @param lengthComputable defines if data length to load can be evaluated
  41533. * @param loaded defines the loaded data length
  41534. * @param total defines the data length to load
  41535. */
  41536. constructor(
  41537. /** defines if data length to load can be evaluated */
  41538. lengthComputable: boolean,
  41539. /** defines the loaded data length */
  41540. loaded: number,
  41541. /** defines the data length to load */
  41542. total: number);
  41543. /**
  41544. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41545. * @param event defines the source event
  41546. * @returns a new SceneLoaderProgressEvent
  41547. */
  41548. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41549. }
  41550. /**
  41551. * Interface used by SceneLoader plugins to define supported file extensions
  41552. */
  41553. export interface ISceneLoaderPluginExtensions {
  41554. /**
  41555. * Defines the list of supported extensions
  41556. */
  41557. [extension: string]: {
  41558. isBinary: boolean;
  41559. };
  41560. }
  41561. /**
  41562. * Interface used by SceneLoader plugin factory
  41563. */
  41564. export interface ISceneLoaderPluginFactory {
  41565. /**
  41566. * Defines the name of the factory
  41567. */
  41568. name: string;
  41569. /**
  41570. * Function called to create a new plugin
  41571. * @return the new plugin
  41572. */
  41573. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41574. /**
  41575. * Boolean indicating if the plugin can direct load specific data
  41576. */
  41577. canDirectLoad?: (data: string) => boolean;
  41578. }
  41579. /**
  41580. * Interface used to define a SceneLoader plugin
  41581. */
  41582. export interface ISceneLoaderPlugin {
  41583. /**
  41584. * The friendly name of this plugin.
  41585. */
  41586. name: string;
  41587. /**
  41588. * The file extensions supported by this plugin.
  41589. */
  41590. extensions: string | ISceneLoaderPluginExtensions;
  41591. /**
  41592. * Import meshes into a scene.
  41593. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41594. * @param scene The scene to import into
  41595. * @param data The data to import
  41596. * @param rootUrl The root url for scene and resources
  41597. * @param meshes The meshes array to import into
  41598. * @param particleSystems The particle systems array to import into
  41599. * @param skeletons The skeletons array to import into
  41600. * @param onError The callback when import fails
  41601. * @returns True if successful or false otherwise
  41602. */
  41603. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41604. /**
  41605. * Load into a scene.
  41606. * @param scene The scene to load into
  41607. * @param data The data to import
  41608. * @param rootUrl The root url for scene and resources
  41609. * @param onError The callback when import fails
  41610. * @returns true if successful or false otherwise
  41611. */
  41612. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41613. /**
  41614. * The callback that returns true if the data can be directly loaded.
  41615. */
  41616. canDirectLoad?: (data: string) => boolean;
  41617. /**
  41618. * The callback that allows custom handling of the root url based on the response url.
  41619. */
  41620. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41621. /**
  41622. * Load into an asset container.
  41623. * @param scene The scene to load into
  41624. * @param data The data to import
  41625. * @param rootUrl The root url for scene and resources
  41626. * @param onError The callback when import fails
  41627. * @returns The loaded asset container
  41628. */
  41629. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41630. }
  41631. /**
  41632. * Interface used to define an async SceneLoader plugin
  41633. */
  41634. export interface ISceneLoaderPluginAsync {
  41635. /**
  41636. * The friendly name of this plugin.
  41637. */
  41638. name: string;
  41639. /**
  41640. * The file extensions supported by this plugin.
  41641. */
  41642. extensions: string | ISceneLoaderPluginExtensions;
  41643. /**
  41644. * Import meshes into a scene.
  41645. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41646. * @param scene The scene to import into
  41647. * @param data The data to import
  41648. * @param rootUrl The root url for scene and resources
  41649. * @param onProgress The callback when the load progresses
  41650. * @param fileName Defines the name of the file to load
  41651. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41652. */
  41653. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41654. meshes: AbstractMesh[];
  41655. particleSystems: IParticleSystem[];
  41656. skeletons: Skeleton[];
  41657. animationGroups: AnimationGroup[];
  41658. }>;
  41659. /**
  41660. * Load into a scene.
  41661. * @param scene The scene to load into
  41662. * @param data The data to import
  41663. * @param rootUrl The root url for scene and resources
  41664. * @param onProgress The callback when the load progresses
  41665. * @param fileName Defines the name of the file to load
  41666. * @returns Nothing
  41667. */
  41668. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41669. /**
  41670. * The callback that returns true if the data can be directly loaded.
  41671. */
  41672. canDirectLoad?: (data: string) => boolean;
  41673. /**
  41674. * The callback that allows custom handling of the root url based on the response url.
  41675. */
  41676. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41677. /**
  41678. * Load into an asset container.
  41679. * @param scene The scene to load 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 asset container
  41685. */
  41686. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41687. }
  41688. /**
  41689. * Class used to load scene from various file formats using registered plugins
  41690. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41691. */
  41692. export class SceneLoader {
  41693. /**
  41694. * No logging while loading
  41695. */
  41696. static readonly NO_LOGGING: number;
  41697. /**
  41698. * Minimal logging while loading
  41699. */
  41700. static readonly MINIMAL_LOGGING: number;
  41701. /**
  41702. * Summary logging while loading
  41703. */
  41704. static readonly SUMMARY_LOGGING: number;
  41705. /**
  41706. * Detailled logging while loading
  41707. */
  41708. static readonly DETAILED_LOGGING: number;
  41709. /**
  41710. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41711. */
  41712. static ForceFullSceneLoadingForIncremental: boolean;
  41713. /**
  41714. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41715. */
  41716. static ShowLoadingScreen: boolean;
  41717. /**
  41718. * Defines the current logging level (while loading the scene)
  41719. * @ignorenaming
  41720. */
  41721. static loggingLevel: number;
  41722. /**
  41723. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41724. */
  41725. static CleanBoneMatrixWeights: boolean;
  41726. /**
  41727. * Event raised when a plugin is used to load a scene
  41728. */
  41729. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41730. private static _registeredPlugins;
  41731. private static _getDefaultPlugin;
  41732. private static _getPluginForExtension;
  41733. private static _getPluginForDirectLoad;
  41734. private static _getPluginForFilename;
  41735. private static _getDirectLoad;
  41736. private static _loadData;
  41737. private static _getFileInfo;
  41738. /**
  41739. * Gets a plugin that can load the given extension
  41740. * @param extension defines the extension to load
  41741. * @returns a plugin or null if none works
  41742. */
  41743. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41744. /**
  41745. * Gets a boolean indicating that the given extension can be loaded
  41746. * @param extension defines the extension to load
  41747. * @returns true if the extension is supported
  41748. */
  41749. static IsPluginForExtensionAvailable(extension: string): boolean;
  41750. /**
  41751. * Adds a new plugin to the list of registered plugins
  41752. * @param plugin defines the plugin to add
  41753. */
  41754. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41755. /**
  41756. * Import meshes into a scene
  41757. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41758. * @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)
  41759. * @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)
  41760. * @param scene the instance of BABYLON.Scene to append to
  41761. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41762. * @param onProgress a callback with a progress event for each file being loaded
  41763. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41764. * @param pluginExtension the extension used to determine the plugin
  41765. * @returns The loaded plugin
  41766. */
  41767. 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>;
  41768. /**
  41769. * Import meshes into a scene
  41770. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41771. * @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)
  41772. * @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)
  41773. * @param scene the instance of BABYLON.Scene to append to
  41774. * @param onProgress a callback with a progress event for each file being loaded
  41775. * @param pluginExtension the extension used to determine the plugin
  41776. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41777. */
  41778. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41779. meshes: AbstractMesh[];
  41780. particleSystems: IParticleSystem[];
  41781. skeletons: Skeleton[];
  41782. animationGroups: AnimationGroup[];
  41783. }>;
  41784. /**
  41785. * Load a scene
  41786. * @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)
  41787. * @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)
  41788. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41789. * @param onSuccess a callback with the scene when import succeeds
  41790. * @param onProgress a callback with a progress event for each file being loaded
  41791. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41792. * @param pluginExtension the extension used to determine the plugin
  41793. * @returns The loaded plugin
  41794. */
  41795. 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>;
  41796. /**
  41797. * Load a scene
  41798. * @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)
  41799. * @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)
  41800. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41801. * @param onProgress a callback with a progress event for each file being loaded
  41802. * @param pluginExtension the extension used to determine the plugin
  41803. * @returns The loaded scene
  41804. */
  41805. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41806. /**
  41807. * Append a scene
  41808. * @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)
  41809. * @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)
  41810. * @param scene is the instance of BABYLON.Scene to append to
  41811. * @param onSuccess a callback with the scene when import succeeds
  41812. * @param onProgress a callback with a progress event for each file being loaded
  41813. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41814. * @param pluginExtension the extension used to determine the plugin
  41815. * @returns The loaded plugin
  41816. */
  41817. 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>;
  41818. /**
  41819. * Append a scene
  41820. * @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)
  41821. * @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)
  41822. * @param scene is the instance of BABYLON.Scene to append to
  41823. * @param onProgress a callback with a progress event for each file being loaded
  41824. * @param pluginExtension the extension used to determine the plugin
  41825. * @returns The given scene
  41826. */
  41827. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41828. /**
  41829. * Load a scene into an asset container
  41830. * @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)
  41831. * @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)
  41832. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41833. * @param onSuccess a callback with the scene when import succeeds
  41834. * @param onProgress a callback with a progress event for each file being loaded
  41835. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41836. * @param pluginExtension the extension used to determine the plugin
  41837. * @returns The loaded plugin
  41838. */
  41839. 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>;
  41840. /**
  41841. * Load a scene into an asset container
  41842. * @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)
  41843. * @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)
  41844. * @param scene is the instance of Scene to append to
  41845. * @param onProgress a callback with a progress event for each file being loaded
  41846. * @param pluginExtension the extension used to determine the plugin
  41847. * @returns The loaded asset container
  41848. */
  41849. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41850. }
  41851. }
  41852. declare module BABYLON {
  41853. /**
  41854. * Generic Controller
  41855. */
  41856. export class GenericController extends WebVRController {
  41857. /**
  41858. * Base Url for the controller model.
  41859. */
  41860. static readonly MODEL_BASE_URL: string;
  41861. /**
  41862. * File name for the controller model.
  41863. */
  41864. static readonly MODEL_FILENAME: string;
  41865. /**
  41866. * Creates a new GenericController from a gamepad
  41867. * @param vrGamepad the gamepad that the controller should be created from
  41868. */
  41869. constructor(vrGamepad: any);
  41870. /**
  41871. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41872. * @param scene scene in which to add meshes
  41873. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41874. */
  41875. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41876. /**
  41877. * Called once for each button that changed state since the last frame
  41878. * @param buttonIdx Which button index changed
  41879. * @param state New state of the button
  41880. * @param changes Which properties on the state changed since last frame
  41881. */
  41882. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41883. }
  41884. }
  41885. declare module BABYLON {
  41886. /**
  41887. * Defines the WindowsMotionController object that the state of the windows motion controller
  41888. */
  41889. export class WindowsMotionController extends WebVRController {
  41890. /**
  41891. * The base url used to load the left and right controller models
  41892. */
  41893. static MODEL_BASE_URL: string;
  41894. /**
  41895. * The name of the left controller model file
  41896. */
  41897. static MODEL_LEFT_FILENAME: string;
  41898. /**
  41899. * The name of the right controller model file
  41900. */
  41901. static MODEL_RIGHT_FILENAME: string;
  41902. /**
  41903. * The controller name prefix for this controller type
  41904. */
  41905. static readonly GAMEPAD_ID_PREFIX: string;
  41906. /**
  41907. * The controller id pattern for this controller type
  41908. */
  41909. private static readonly GAMEPAD_ID_PATTERN;
  41910. private _loadedMeshInfo;
  41911. private readonly _mapping;
  41912. /**
  41913. * Fired when the trackpad on this controller is clicked
  41914. */
  41915. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41916. /**
  41917. * Fired when the trackpad on this controller is modified
  41918. */
  41919. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41920. /**
  41921. * The current x and y values of this controller's trackpad
  41922. */
  41923. trackpad: StickValues;
  41924. /**
  41925. * Creates a new WindowsMotionController from a gamepad
  41926. * @param vrGamepad the gamepad that the controller should be created from
  41927. */
  41928. constructor(vrGamepad: any);
  41929. /**
  41930. * Fired when the trigger on this controller is modified
  41931. */
  41932. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41933. /**
  41934. * Fired when the menu button on this controller is modified
  41935. */
  41936. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41937. /**
  41938. * Fired when the grip button on this controller is modified
  41939. */
  41940. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41941. /**
  41942. * Fired when the thumbstick button on this controller is modified
  41943. */
  41944. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41945. /**
  41946. * Fired when the touchpad button on this controller is modified
  41947. */
  41948. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41949. /**
  41950. * Fired when the touchpad values on this controller are modified
  41951. */
  41952. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41953. private _updateTrackpad;
  41954. /**
  41955. * Called once per frame by the engine.
  41956. */
  41957. update(): void;
  41958. /**
  41959. * Called once for each button that changed state since the last frame
  41960. * @param buttonIdx Which button index changed
  41961. * @param state New state of the button
  41962. * @param changes Which properties on the state changed since last frame
  41963. */
  41964. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41965. /**
  41966. * Moves the buttons on the controller mesh based on their current state
  41967. * @param buttonName the name of the button to move
  41968. * @param buttonValue the value of the button which determines the buttons new position
  41969. */
  41970. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41971. /**
  41972. * Moves the axis on the controller mesh based on its current state
  41973. * @param axis the index of the axis
  41974. * @param axisValue the value of the axis which determines the meshes new position
  41975. * @hidden
  41976. */
  41977. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41978. /**
  41979. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41980. * @param scene scene in which to add meshes
  41981. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41982. */
  41983. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41984. /**
  41985. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41986. * can be transformed by button presses and axes values, based on this._mapping.
  41987. *
  41988. * @param scene scene in which the meshes exist
  41989. * @param meshes list of meshes that make up the controller model to process
  41990. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41991. */
  41992. private processModel;
  41993. private createMeshInfo;
  41994. /**
  41995. * Gets the ray of the controller in the direction the controller is pointing
  41996. * @param length the length the resulting ray should be
  41997. * @returns a ray in the direction the controller is pointing
  41998. */
  41999. getForwardRay(length?: number): Ray;
  42000. /**
  42001. * Disposes of the controller
  42002. */
  42003. dispose(): void;
  42004. }
  42005. }
  42006. declare module BABYLON {
  42007. /**
  42008. * Oculus Touch Controller
  42009. */
  42010. export class OculusTouchController extends WebVRController {
  42011. /**
  42012. * Base Url for the controller model.
  42013. */
  42014. static MODEL_BASE_URL: string;
  42015. /**
  42016. * File name for the left controller model.
  42017. */
  42018. static MODEL_LEFT_FILENAME: string;
  42019. /**
  42020. * File name for the right controller model.
  42021. */
  42022. static MODEL_RIGHT_FILENAME: string;
  42023. /**
  42024. * Base Url for the Quest controller model.
  42025. */
  42026. static QUEST_MODEL_BASE_URL: string;
  42027. /**
  42028. * @hidden
  42029. * If the controllers are running on a device that needs the updated Quest controller models
  42030. */
  42031. static _IsQuest: boolean;
  42032. /**
  42033. * Fired when the secondary trigger on this controller is modified
  42034. */
  42035. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42036. /**
  42037. * Fired when the thumb rest on this controller is modified
  42038. */
  42039. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42040. /**
  42041. * Creates a new OculusTouchController from a gamepad
  42042. * @param vrGamepad the gamepad that the controller should be created from
  42043. */
  42044. constructor(vrGamepad: any);
  42045. /**
  42046. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42047. * @param scene scene in which to add meshes
  42048. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42049. */
  42050. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42051. /**
  42052. * Fired when the A button on this controller is modified
  42053. */
  42054. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42055. /**
  42056. * Fired when the B button on this controller is modified
  42057. */
  42058. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42059. /**
  42060. * Fired when the X button on this controller is modified
  42061. */
  42062. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42063. /**
  42064. * Fired when the Y button on this controller is modified
  42065. */
  42066. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42067. /**
  42068. * Called once for each button that changed state since the last frame
  42069. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42070. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42071. * 2) secondary trigger (same)
  42072. * 3) A (right) X (left), touch, pressed = value
  42073. * 4) B / Y
  42074. * 5) thumb rest
  42075. * @param buttonIdx Which button index changed
  42076. * @param state New state of the button
  42077. * @param changes Which properties on the state changed since last frame
  42078. */
  42079. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42080. }
  42081. }
  42082. declare module BABYLON {
  42083. /**
  42084. * Vive Controller
  42085. */
  42086. export class ViveController extends WebVRController {
  42087. /**
  42088. * Base Url for the controller model.
  42089. */
  42090. static MODEL_BASE_URL: string;
  42091. /**
  42092. * File name for the controller model.
  42093. */
  42094. static MODEL_FILENAME: string;
  42095. /**
  42096. * Creates a new ViveController from a gamepad
  42097. * @param vrGamepad the gamepad that the controller should be created from
  42098. */
  42099. constructor(vrGamepad: any);
  42100. /**
  42101. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42102. * @param scene scene in which to add meshes
  42103. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42104. */
  42105. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42106. /**
  42107. * Fired when the left button on this controller is modified
  42108. */
  42109. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42110. /**
  42111. * Fired when the right button on this controller is modified
  42112. */
  42113. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42114. /**
  42115. * Fired when the menu button on this controller is modified
  42116. */
  42117. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42118. /**
  42119. * Called once for each button that changed state since the last frame
  42120. * Vive mapping:
  42121. * 0: touchpad
  42122. * 1: trigger
  42123. * 2: left AND right buttons
  42124. * 3: menu button
  42125. * @param buttonIdx Which button index changed
  42126. * @param state New state of the button
  42127. * @param changes Which properties on the state changed since last frame
  42128. */
  42129. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42130. }
  42131. }
  42132. declare module BABYLON {
  42133. /**
  42134. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42135. */
  42136. export class WebXRControllerModelLoader {
  42137. /**
  42138. * Creates the WebXRControllerModelLoader
  42139. * @param input xr input that creates the controllers
  42140. */
  42141. constructor(input: WebXRInput);
  42142. }
  42143. }
  42144. declare module BABYLON {
  42145. /**
  42146. * Contains an array of blocks representing the octree
  42147. */
  42148. export interface IOctreeContainer<T> {
  42149. /**
  42150. * Blocks within the octree
  42151. */
  42152. blocks: Array<OctreeBlock<T>>;
  42153. }
  42154. /**
  42155. * Class used to store a cell in an octree
  42156. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42157. */
  42158. export class OctreeBlock<T> {
  42159. /**
  42160. * Gets the content of the current block
  42161. */
  42162. entries: T[];
  42163. /**
  42164. * Gets the list of block children
  42165. */
  42166. blocks: Array<OctreeBlock<T>>;
  42167. private _depth;
  42168. private _maxDepth;
  42169. private _capacity;
  42170. private _minPoint;
  42171. private _maxPoint;
  42172. private _boundingVectors;
  42173. private _creationFunc;
  42174. /**
  42175. * Creates a new block
  42176. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42177. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42178. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42179. * @param depth defines the current depth of this block in the octree
  42180. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42181. * @param creationFunc defines a callback to call when an element is added to the block
  42182. */
  42183. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42184. /**
  42185. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42186. */
  42187. readonly capacity: number;
  42188. /**
  42189. * Gets the minimum vector (in world space) of the block's bounding box
  42190. */
  42191. readonly minPoint: Vector3;
  42192. /**
  42193. * Gets the maximum vector (in world space) of the block's bounding box
  42194. */
  42195. readonly maxPoint: Vector3;
  42196. /**
  42197. * Add a new element to this block
  42198. * @param entry defines the element to add
  42199. */
  42200. addEntry(entry: T): void;
  42201. /**
  42202. * Remove an element from this block
  42203. * @param entry defines the element to remove
  42204. */
  42205. removeEntry(entry: T): void;
  42206. /**
  42207. * Add an array of elements to this block
  42208. * @param entries defines the array of elements to add
  42209. */
  42210. addEntries(entries: T[]): void;
  42211. /**
  42212. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42213. * @param frustumPlanes defines the frustum planes to test
  42214. * @param selection defines the array to store current content if selection is positive
  42215. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42216. */
  42217. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42218. /**
  42219. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42220. * @param sphereCenter defines the bounding sphere center
  42221. * @param sphereRadius defines the bounding sphere radius
  42222. * @param selection defines the array to store current content if selection is positive
  42223. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42224. */
  42225. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42226. /**
  42227. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42228. * @param ray defines the ray to test with
  42229. * @param selection defines the array to store current content if selection is positive
  42230. */
  42231. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42232. /**
  42233. * Subdivide the content into child blocks (this block will then be empty)
  42234. */
  42235. createInnerBlocks(): void;
  42236. /**
  42237. * @hidden
  42238. */
  42239. 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;
  42240. }
  42241. }
  42242. declare module BABYLON {
  42243. /**
  42244. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42245. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42246. */
  42247. export class Octree<T> {
  42248. /** 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.) */
  42249. maxDepth: number;
  42250. /**
  42251. * Blocks within the octree containing objects
  42252. */
  42253. blocks: Array<OctreeBlock<T>>;
  42254. /**
  42255. * Content stored in the octree
  42256. */
  42257. dynamicContent: T[];
  42258. private _maxBlockCapacity;
  42259. private _selectionContent;
  42260. private _creationFunc;
  42261. /**
  42262. * Creates a octree
  42263. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42264. * @param creationFunc function to be used to instatiate the octree
  42265. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42266. * @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.)
  42267. */
  42268. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42269. /** 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.) */
  42270. maxDepth?: number);
  42271. /**
  42272. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42273. * @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);
  42274. * @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);
  42275. * @param entries meshes to be added to the octree blocks
  42276. */
  42277. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42278. /**
  42279. * Adds a mesh to the octree
  42280. * @param entry Mesh to add to the octree
  42281. */
  42282. addMesh(entry: T): void;
  42283. /**
  42284. * Remove an element from the octree
  42285. * @param entry defines the element to remove
  42286. */
  42287. removeMesh(entry: T): void;
  42288. /**
  42289. * Selects an array of meshes within the frustum
  42290. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42291. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42292. * @returns array of meshes within the frustum
  42293. */
  42294. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42295. /**
  42296. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42297. * @param sphereCenter defines the bounding sphere center
  42298. * @param sphereRadius defines the bounding sphere radius
  42299. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42300. * @returns an array of objects that intersect the sphere
  42301. */
  42302. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42303. /**
  42304. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42305. * @param ray defines the ray to test with
  42306. * @returns array of intersected objects
  42307. */
  42308. intersectsRay(ray: Ray): SmartArray<T>;
  42309. /**
  42310. * Adds a mesh into the octree block if it intersects the block
  42311. */
  42312. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42313. /**
  42314. * Adds a submesh into the octree block if it intersects the block
  42315. */
  42316. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42317. }
  42318. }
  42319. declare module BABYLON {
  42320. interface Scene {
  42321. /**
  42322. * @hidden
  42323. * Backing Filed
  42324. */
  42325. _selectionOctree: Octree<AbstractMesh>;
  42326. /**
  42327. * Gets the octree used to boost mesh selection (picking)
  42328. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42329. */
  42330. selectionOctree: Octree<AbstractMesh>;
  42331. /**
  42332. * Creates or updates the octree used to boost selection (picking)
  42333. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42334. * @param maxCapacity defines the maximum capacity per leaf
  42335. * @param maxDepth defines the maximum depth of the octree
  42336. * @returns an octree of AbstractMesh
  42337. */
  42338. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42339. }
  42340. interface AbstractMesh {
  42341. /**
  42342. * @hidden
  42343. * Backing Field
  42344. */
  42345. _submeshesOctree: Octree<SubMesh>;
  42346. /**
  42347. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42348. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42349. * @param maxCapacity defines the maximum size of each block (64 by default)
  42350. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42351. * @returns the new octree
  42352. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42353. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42354. */
  42355. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42356. }
  42357. /**
  42358. * Defines the octree scene component responsible to manage any octrees
  42359. * in a given scene.
  42360. */
  42361. export class OctreeSceneComponent {
  42362. /**
  42363. * The component name help to identify the component in the list of scene components.
  42364. */
  42365. readonly name: string;
  42366. /**
  42367. * The scene the component belongs to.
  42368. */
  42369. scene: Scene;
  42370. /**
  42371. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42372. */
  42373. readonly checksIsEnabled: boolean;
  42374. /**
  42375. * Creates a new instance of the component for the given scene
  42376. * @param scene Defines the scene to register the component in
  42377. */
  42378. constructor(scene: Scene);
  42379. /**
  42380. * Registers the component in a given scene
  42381. */
  42382. register(): void;
  42383. /**
  42384. * Return the list of active meshes
  42385. * @returns the list of active meshes
  42386. */
  42387. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42388. /**
  42389. * Return the list of active sub meshes
  42390. * @param mesh The mesh to get the candidates sub meshes from
  42391. * @returns the list of active sub meshes
  42392. */
  42393. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42394. private _tempRay;
  42395. /**
  42396. * Return the list of sub meshes intersecting with a given local ray
  42397. * @param mesh defines the mesh to find the submesh for
  42398. * @param localRay defines the ray in local space
  42399. * @returns the list of intersecting sub meshes
  42400. */
  42401. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42402. /**
  42403. * Return the list of sub meshes colliding with a collider
  42404. * @param mesh defines the mesh to find the submesh for
  42405. * @param collider defines the collider to evaluate the collision against
  42406. * @returns the list of colliding sub meshes
  42407. */
  42408. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42409. /**
  42410. * Rebuilds the elements related to this component in case of
  42411. * context lost for instance.
  42412. */
  42413. rebuild(): void;
  42414. /**
  42415. * Disposes the component and the associated ressources.
  42416. */
  42417. dispose(): void;
  42418. }
  42419. }
  42420. declare module BABYLON {
  42421. /**
  42422. * Renders a layer on top of an existing scene
  42423. */
  42424. export class UtilityLayerRenderer implements IDisposable {
  42425. /** the original scene that will be rendered on top of */
  42426. originalScene: Scene;
  42427. private _pointerCaptures;
  42428. private _lastPointerEvents;
  42429. private static _DefaultUtilityLayer;
  42430. private static _DefaultKeepDepthUtilityLayer;
  42431. private _sharedGizmoLight;
  42432. private _renderCamera;
  42433. /**
  42434. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42435. * @returns the camera that is used when rendering the utility layer
  42436. */
  42437. getRenderCamera(): Nullable<Camera>;
  42438. /**
  42439. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42440. * @param cam the camera that should be used when rendering the utility layer
  42441. */
  42442. setRenderCamera(cam: Nullable<Camera>): void;
  42443. /**
  42444. * @hidden
  42445. * Light which used by gizmos to get light shading
  42446. */
  42447. _getSharedGizmoLight(): HemisphericLight;
  42448. /**
  42449. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42450. */
  42451. pickUtilitySceneFirst: boolean;
  42452. /**
  42453. * 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)
  42454. */
  42455. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42456. /**
  42457. * 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)
  42458. */
  42459. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42460. /**
  42461. * The scene that is rendered on top of the original scene
  42462. */
  42463. utilityLayerScene: Scene;
  42464. /**
  42465. * If the utility layer should automatically be rendered on top of existing scene
  42466. */
  42467. shouldRender: boolean;
  42468. /**
  42469. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42470. */
  42471. onlyCheckPointerDownEvents: boolean;
  42472. /**
  42473. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42474. */
  42475. processAllEvents: boolean;
  42476. /**
  42477. * Observable raised when the pointer move from the utility layer scene to the main scene
  42478. */
  42479. onPointerOutObservable: Observable<number>;
  42480. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42481. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42482. private _afterRenderObserver;
  42483. private _sceneDisposeObserver;
  42484. private _originalPointerObserver;
  42485. /**
  42486. * Instantiates a UtilityLayerRenderer
  42487. * @param originalScene the original scene that will be rendered on top of
  42488. * @param handleEvents boolean indicating if the utility layer should handle events
  42489. */
  42490. constructor(
  42491. /** the original scene that will be rendered on top of */
  42492. originalScene: Scene, handleEvents?: boolean);
  42493. private _notifyObservers;
  42494. /**
  42495. * Renders the utility layers scene on top of the original scene
  42496. */
  42497. render(): void;
  42498. /**
  42499. * Disposes of the renderer
  42500. */
  42501. dispose(): void;
  42502. private _updateCamera;
  42503. }
  42504. }
  42505. declare module BABYLON {
  42506. /**
  42507. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42508. */
  42509. export class Gizmo implements IDisposable {
  42510. /** The utility layer the gizmo will be added to */
  42511. gizmoLayer: UtilityLayerRenderer;
  42512. /**
  42513. * The root mesh of the gizmo
  42514. */
  42515. _rootMesh: Mesh;
  42516. private _attachedMesh;
  42517. /**
  42518. * Ratio for the scale of the gizmo (Default: 1)
  42519. */
  42520. scaleRatio: number;
  42521. /**
  42522. * If a custom mesh has been set (Default: false)
  42523. */
  42524. protected _customMeshSet: boolean;
  42525. /**
  42526. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42527. * * When set, interactions will be enabled
  42528. */
  42529. attachedMesh: Nullable<AbstractMesh>;
  42530. /**
  42531. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42532. * @param mesh The mesh to replace the default mesh of the gizmo
  42533. */
  42534. setCustomMesh(mesh: Mesh): void;
  42535. /**
  42536. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42537. */
  42538. updateGizmoRotationToMatchAttachedMesh: boolean;
  42539. /**
  42540. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42541. */
  42542. updateGizmoPositionToMatchAttachedMesh: boolean;
  42543. /**
  42544. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42545. */
  42546. updateScale: boolean;
  42547. protected _interactionsEnabled: boolean;
  42548. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42549. private _beforeRenderObserver;
  42550. private _tempVector;
  42551. /**
  42552. * Creates a gizmo
  42553. * @param gizmoLayer The utility layer the gizmo will be added to
  42554. */
  42555. constructor(
  42556. /** The utility layer the gizmo will be added to */
  42557. gizmoLayer?: UtilityLayerRenderer);
  42558. /**
  42559. * Updates the gizmo to match the attached mesh's position/rotation
  42560. */
  42561. protected _update(): void;
  42562. /**
  42563. * Disposes of the gizmo
  42564. */
  42565. dispose(): void;
  42566. }
  42567. }
  42568. declare module BABYLON {
  42569. /**
  42570. * Single plane drag gizmo
  42571. */
  42572. export class PlaneDragGizmo extends Gizmo {
  42573. /**
  42574. * Drag behavior responsible for the gizmos dragging interactions
  42575. */
  42576. dragBehavior: PointerDragBehavior;
  42577. private _pointerObserver;
  42578. /**
  42579. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42580. */
  42581. snapDistance: number;
  42582. /**
  42583. * Event that fires each time the gizmo snaps to a new location.
  42584. * * snapDistance is the the change in distance
  42585. */
  42586. onSnapObservable: Observable<{
  42587. snapDistance: number;
  42588. }>;
  42589. private _plane;
  42590. private _coloredMaterial;
  42591. private _hoverMaterial;
  42592. private _isEnabled;
  42593. private _parent;
  42594. /** @hidden */
  42595. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42596. /** @hidden */
  42597. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42598. /**
  42599. * Creates a PlaneDragGizmo
  42600. * @param gizmoLayer The utility layer the gizmo will be added to
  42601. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42602. * @param color The color of the gizmo
  42603. */
  42604. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42605. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42606. /**
  42607. * If the gizmo is enabled
  42608. */
  42609. isEnabled: boolean;
  42610. /**
  42611. * Disposes of the gizmo
  42612. */
  42613. dispose(): void;
  42614. }
  42615. }
  42616. declare module BABYLON {
  42617. /**
  42618. * Gizmo that enables dragging a mesh along 3 axis
  42619. */
  42620. export class PositionGizmo extends Gizmo {
  42621. /**
  42622. * Internal gizmo used for interactions on the x axis
  42623. */
  42624. xGizmo: AxisDragGizmo;
  42625. /**
  42626. * Internal gizmo used for interactions on the y axis
  42627. */
  42628. yGizmo: AxisDragGizmo;
  42629. /**
  42630. * Internal gizmo used for interactions on the z axis
  42631. */
  42632. zGizmo: AxisDragGizmo;
  42633. /**
  42634. * Internal gizmo used for interactions on the yz plane
  42635. */
  42636. xPlaneGizmo: PlaneDragGizmo;
  42637. /**
  42638. * Internal gizmo used for interactions on the xz plane
  42639. */
  42640. yPlaneGizmo: PlaneDragGizmo;
  42641. /**
  42642. * Internal gizmo used for interactions on the xy plane
  42643. */
  42644. zPlaneGizmo: PlaneDragGizmo;
  42645. /**
  42646. * private variables
  42647. */
  42648. private _meshAttached;
  42649. private _updateGizmoRotationToMatchAttachedMesh;
  42650. private _snapDistance;
  42651. private _scaleRatio;
  42652. /** Fires an event when any of it's sub gizmos are dragged */
  42653. onDragStartObservable: Observable<unknown>;
  42654. /** Fires an event when any of it's sub gizmos are released from dragging */
  42655. onDragEndObservable: Observable<unknown>;
  42656. /**
  42657. * If set to true, planar drag is enabled
  42658. */
  42659. private _planarGizmoEnabled;
  42660. attachedMesh: Nullable<AbstractMesh>;
  42661. /**
  42662. * Creates a PositionGizmo
  42663. * @param gizmoLayer The utility layer the gizmo will be added to
  42664. */
  42665. constructor(gizmoLayer?: UtilityLayerRenderer);
  42666. /**
  42667. * If the planar drag gizmo is enabled
  42668. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42669. */
  42670. planarGizmoEnabled: boolean;
  42671. updateGizmoRotationToMatchAttachedMesh: boolean;
  42672. /**
  42673. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42674. */
  42675. snapDistance: number;
  42676. /**
  42677. * Ratio for the scale of the gizmo (Default: 1)
  42678. */
  42679. scaleRatio: number;
  42680. /**
  42681. * Disposes of the gizmo
  42682. */
  42683. dispose(): void;
  42684. /**
  42685. * CustomMeshes are not supported by this gizmo
  42686. * @param mesh The mesh to replace the default mesh of the gizmo
  42687. */
  42688. setCustomMesh(mesh: Mesh): void;
  42689. }
  42690. }
  42691. declare module BABYLON {
  42692. /**
  42693. * Single axis drag gizmo
  42694. */
  42695. export class AxisDragGizmo extends Gizmo {
  42696. /**
  42697. * Drag behavior responsible for the gizmos dragging interactions
  42698. */
  42699. dragBehavior: PointerDragBehavior;
  42700. private _pointerObserver;
  42701. /**
  42702. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42703. */
  42704. snapDistance: number;
  42705. /**
  42706. * Event that fires each time the gizmo snaps to a new location.
  42707. * * snapDistance is the the change in distance
  42708. */
  42709. onSnapObservable: Observable<{
  42710. snapDistance: number;
  42711. }>;
  42712. private _isEnabled;
  42713. private _parent;
  42714. private _arrow;
  42715. private _coloredMaterial;
  42716. private _hoverMaterial;
  42717. /** @hidden */
  42718. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42719. /** @hidden */
  42720. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42721. /**
  42722. * Creates an AxisDragGizmo
  42723. * @param gizmoLayer The utility layer the gizmo will be added to
  42724. * @param dragAxis The axis which the gizmo will be able to drag on
  42725. * @param color The color of the gizmo
  42726. */
  42727. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42728. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42729. /**
  42730. * If the gizmo is enabled
  42731. */
  42732. isEnabled: boolean;
  42733. /**
  42734. * Disposes of the gizmo
  42735. */
  42736. dispose(): void;
  42737. }
  42738. }
  42739. declare module BABYLON.Debug {
  42740. /**
  42741. * The Axes viewer will show 3 axes in a specific point in space
  42742. */
  42743. export class AxesViewer {
  42744. private _xAxis;
  42745. private _yAxis;
  42746. private _zAxis;
  42747. private _scaleLinesFactor;
  42748. private _instanced;
  42749. /**
  42750. * Gets the hosting scene
  42751. */
  42752. scene: Scene;
  42753. /**
  42754. * Gets or sets a number used to scale line length
  42755. */
  42756. scaleLines: number;
  42757. /** Gets the node hierarchy used to render x-axis */
  42758. readonly xAxis: TransformNode;
  42759. /** Gets the node hierarchy used to render y-axis */
  42760. readonly yAxis: TransformNode;
  42761. /** Gets the node hierarchy used to render z-axis */
  42762. readonly zAxis: TransformNode;
  42763. /**
  42764. * Creates a new AxesViewer
  42765. * @param scene defines the hosting scene
  42766. * @param scaleLines defines a number used to scale line length (1 by default)
  42767. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42768. * @param xAxis defines the node hierarchy used to render the x-axis
  42769. * @param yAxis defines the node hierarchy used to render the y-axis
  42770. * @param zAxis defines the node hierarchy used to render the z-axis
  42771. */
  42772. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42773. /**
  42774. * Force the viewer to update
  42775. * @param position defines the position of the viewer
  42776. * @param xaxis defines the x axis of the viewer
  42777. * @param yaxis defines the y axis of the viewer
  42778. * @param zaxis defines the z axis of the viewer
  42779. */
  42780. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42781. /**
  42782. * Creates an instance of this axes viewer.
  42783. * @returns a new axes viewer with instanced meshes
  42784. */
  42785. createInstance(): AxesViewer;
  42786. /** Releases resources */
  42787. dispose(): void;
  42788. private static _SetRenderingGroupId;
  42789. }
  42790. }
  42791. declare module BABYLON.Debug {
  42792. /**
  42793. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42794. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42795. */
  42796. export class BoneAxesViewer extends AxesViewer {
  42797. /**
  42798. * Gets or sets the target mesh where to display the axes viewer
  42799. */
  42800. mesh: Nullable<Mesh>;
  42801. /**
  42802. * Gets or sets the target bone where to display the axes viewer
  42803. */
  42804. bone: Nullable<Bone>;
  42805. /** Gets current position */
  42806. pos: Vector3;
  42807. /** Gets direction of X axis */
  42808. xaxis: Vector3;
  42809. /** Gets direction of Y axis */
  42810. yaxis: Vector3;
  42811. /** Gets direction of Z axis */
  42812. zaxis: Vector3;
  42813. /**
  42814. * Creates a new BoneAxesViewer
  42815. * @param scene defines the hosting scene
  42816. * @param bone defines the target bone
  42817. * @param mesh defines the target mesh
  42818. * @param scaleLines defines a scaling factor for line length (1 by default)
  42819. */
  42820. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42821. /**
  42822. * Force the viewer to update
  42823. */
  42824. update(): void;
  42825. /** Releases resources */
  42826. dispose(): void;
  42827. }
  42828. }
  42829. declare module BABYLON {
  42830. /**
  42831. * Interface used to define scene explorer extensibility option
  42832. */
  42833. export interface IExplorerExtensibilityOption {
  42834. /**
  42835. * Define the option label
  42836. */
  42837. label: string;
  42838. /**
  42839. * Defines the action to execute on click
  42840. */
  42841. action: (entity: any) => void;
  42842. }
  42843. /**
  42844. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42845. */
  42846. export interface IExplorerExtensibilityGroup {
  42847. /**
  42848. * Defines a predicate to test if a given type mut be extended
  42849. */
  42850. predicate: (entity: any) => boolean;
  42851. /**
  42852. * Gets the list of options added to a type
  42853. */
  42854. entries: IExplorerExtensibilityOption[];
  42855. }
  42856. /**
  42857. * Interface used to define the options to use to create the Inspector
  42858. */
  42859. export interface IInspectorOptions {
  42860. /**
  42861. * Display in overlay mode (default: false)
  42862. */
  42863. overlay?: boolean;
  42864. /**
  42865. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42866. */
  42867. globalRoot?: HTMLElement;
  42868. /**
  42869. * Display the Scene explorer
  42870. */
  42871. showExplorer?: boolean;
  42872. /**
  42873. * Display the property inspector
  42874. */
  42875. showInspector?: boolean;
  42876. /**
  42877. * Display in embed mode (both panes on the right)
  42878. */
  42879. embedMode?: boolean;
  42880. /**
  42881. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42882. */
  42883. handleResize?: boolean;
  42884. /**
  42885. * Allow the panes to popup (default: true)
  42886. */
  42887. enablePopup?: boolean;
  42888. /**
  42889. * Allow the panes to be closed by users (default: true)
  42890. */
  42891. enableClose?: boolean;
  42892. /**
  42893. * Optional list of extensibility entries
  42894. */
  42895. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42896. /**
  42897. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42898. */
  42899. inspectorURL?: string;
  42900. }
  42901. interface Scene {
  42902. /**
  42903. * @hidden
  42904. * Backing field
  42905. */
  42906. _debugLayer: DebugLayer;
  42907. /**
  42908. * Gets the debug layer (aka Inspector) associated with the scene
  42909. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42910. */
  42911. debugLayer: DebugLayer;
  42912. }
  42913. /**
  42914. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42915. * what is happening in your scene
  42916. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42917. */
  42918. export class DebugLayer {
  42919. /**
  42920. * Define the url to get the inspector script from.
  42921. * By default it uses the babylonjs CDN.
  42922. * @ignoreNaming
  42923. */
  42924. static InspectorURL: string;
  42925. private _scene;
  42926. private BJSINSPECTOR;
  42927. private _onPropertyChangedObservable?;
  42928. /**
  42929. * Observable triggered when a property is changed through the inspector.
  42930. */
  42931. readonly onPropertyChangedObservable: any;
  42932. /**
  42933. * Instantiates a new debug layer.
  42934. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42935. * what is happening in your scene
  42936. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42937. * @param scene Defines the scene to inspect
  42938. */
  42939. constructor(scene: Scene);
  42940. /** Creates the inspector window. */
  42941. private _createInspector;
  42942. /**
  42943. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42944. * @param entity defines the entity to select
  42945. * @param lineContainerTitle defines the specific block to highlight
  42946. */
  42947. select(entity: any, lineContainerTitle?: string): void;
  42948. /** Get the inspector from bundle or global */
  42949. private _getGlobalInspector;
  42950. /**
  42951. * Get if the inspector is visible or not.
  42952. * @returns true if visible otherwise, false
  42953. */
  42954. isVisible(): boolean;
  42955. /**
  42956. * Hide the inspector and close its window.
  42957. */
  42958. hide(): void;
  42959. /**
  42960. * Launch the debugLayer.
  42961. * @param config Define the configuration of the inspector
  42962. * @return a promise fulfilled when the debug layer is visible
  42963. */
  42964. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42965. }
  42966. }
  42967. declare module BABYLON {
  42968. /**
  42969. * Class containing static functions to help procedurally build meshes
  42970. */
  42971. export class BoxBuilder {
  42972. /**
  42973. * Creates a box mesh
  42974. * * The parameter `size` sets the size (float) of each box side (default 1)
  42975. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42976. * * 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)
  42977. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42978. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42979. * * 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
  42980. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42981. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42982. * @param name defines the name of the mesh
  42983. * @param options defines the options used to create the mesh
  42984. * @param scene defines the hosting scene
  42985. * @returns the box mesh
  42986. */
  42987. static CreateBox(name: string, options: {
  42988. size?: number;
  42989. width?: number;
  42990. height?: number;
  42991. depth?: number;
  42992. faceUV?: Vector4[];
  42993. faceColors?: Color4[];
  42994. sideOrientation?: number;
  42995. frontUVs?: Vector4;
  42996. backUVs?: Vector4;
  42997. wrap?: boolean;
  42998. topBaseAt?: number;
  42999. bottomBaseAt?: number;
  43000. updatable?: boolean;
  43001. }, scene?: Nullable<Scene>): Mesh;
  43002. }
  43003. }
  43004. declare module BABYLON {
  43005. /**
  43006. * Class containing static functions to help procedurally build meshes
  43007. */
  43008. export class SphereBuilder {
  43009. /**
  43010. * Creates a sphere mesh
  43011. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43012. * * 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`)
  43013. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43014. * * 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
  43015. * * 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)
  43016. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43017. * * 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
  43018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43019. * @param name defines the name of the mesh
  43020. * @param options defines the options used to create the mesh
  43021. * @param scene defines the hosting scene
  43022. * @returns the sphere mesh
  43023. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43024. */
  43025. static CreateSphere(name: string, options: {
  43026. segments?: number;
  43027. diameter?: number;
  43028. diameterX?: number;
  43029. diameterY?: number;
  43030. diameterZ?: number;
  43031. arc?: number;
  43032. slice?: number;
  43033. sideOrientation?: number;
  43034. frontUVs?: Vector4;
  43035. backUVs?: Vector4;
  43036. updatable?: boolean;
  43037. }, scene: any): Mesh;
  43038. }
  43039. }
  43040. declare module BABYLON.Debug {
  43041. /**
  43042. * Used to show the physics impostor around the specific mesh
  43043. */
  43044. export class PhysicsViewer {
  43045. /** @hidden */
  43046. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43047. /** @hidden */
  43048. protected _meshes: Array<Nullable<AbstractMesh>>;
  43049. /** @hidden */
  43050. protected _scene: Nullable<Scene>;
  43051. /** @hidden */
  43052. protected _numMeshes: number;
  43053. /** @hidden */
  43054. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43055. private _renderFunction;
  43056. private _utilityLayer;
  43057. private _debugBoxMesh;
  43058. private _debugSphereMesh;
  43059. private _debugCylinderMesh;
  43060. private _debugMaterial;
  43061. private _debugMeshMeshes;
  43062. /**
  43063. * Creates a new PhysicsViewer
  43064. * @param scene defines the hosting scene
  43065. */
  43066. constructor(scene: Scene);
  43067. /** @hidden */
  43068. protected _updateDebugMeshes(): void;
  43069. /**
  43070. * Renders a specified physic impostor
  43071. * @param impostor defines the impostor to render
  43072. * @param targetMesh defines the mesh represented by the impostor
  43073. * @returns the new debug mesh used to render the impostor
  43074. */
  43075. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43076. /**
  43077. * Hides a specified physic impostor
  43078. * @param impostor defines the impostor to hide
  43079. */
  43080. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43081. private _getDebugMaterial;
  43082. private _getDebugBoxMesh;
  43083. private _getDebugSphereMesh;
  43084. private _getDebugCylinderMesh;
  43085. private _getDebugMeshMesh;
  43086. private _getDebugMesh;
  43087. /** Releases all resources */
  43088. dispose(): void;
  43089. }
  43090. }
  43091. declare module BABYLON {
  43092. /**
  43093. * Class containing static functions to help procedurally build meshes
  43094. */
  43095. export class LinesBuilder {
  43096. /**
  43097. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43098. * * 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
  43099. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43100. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43101. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43102. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43103. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43104. * * 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
  43105. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43107. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43108. * @param name defines the name of the new line system
  43109. * @param options defines the options used to create the line system
  43110. * @param scene defines the hosting scene
  43111. * @returns a new line system mesh
  43112. */
  43113. static CreateLineSystem(name: string, options: {
  43114. lines: Vector3[][];
  43115. updatable?: boolean;
  43116. instance?: Nullable<LinesMesh>;
  43117. colors?: Nullable<Color4[][]>;
  43118. useVertexAlpha?: boolean;
  43119. }, scene: Nullable<Scene>): LinesMesh;
  43120. /**
  43121. * Creates a line mesh
  43122. * 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
  43123. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43124. * * The parameter `points` is an array successive Vector3
  43125. * * 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
  43126. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43127. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43128. * * When updating an instance, remember that only point positions can change, not the number of points
  43129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43130. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43131. * @param name defines the name of the new line system
  43132. * @param options defines the options used to create the line system
  43133. * @param scene defines the hosting scene
  43134. * @returns a new line mesh
  43135. */
  43136. static CreateLines(name: string, options: {
  43137. points: Vector3[];
  43138. updatable?: boolean;
  43139. instance?: Nullable<LinesMesh>;
  43140. colors?: Color4[];
  43141. useVertexAlpha?: boolean;
  43142. }, scene?: Nullable<Scene>): LinesMesh;
  43143. /**
  43144. * Creates a dashed line mesh
  43145. * * 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
  43146. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43147. * * The parameter `points` is an array successive Vector3
  43148. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43149. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43150. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43151. * * 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
  43152. * * When updating an instance, remember that only point positions can change, not the number of points
  43153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43154. * @param name defines the name of the mesh
  43155. * @param options defines the options used to create the mesh
  43156. * @param scene defines the hosting scene
  43157. * @returns the dashed line mesh
  43158. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43159. */
  43160. static CreateDashedLines(name: string, options: {
  43161. points: Vector3[];
  43162. dashSize?: number;
  43163. gapSize?: number;
  43164. dashNb?: number;
  43165. updatable?: boolean;
  43166. instance?: LinesMesh;
  43167. }, scene?: Nullable<Scene>): LinesMesh;
  43168. }
  43169. }
  43170. declare module BABYLON {
  43171. /**
  43172. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43173. * in order to better appreciate the issue one might have.
  43174. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43175. */
  43176. export class RayHelper {
  43177. /**
  43178. * Defines the ray we are currently tryin to visualize.
  43179. */
  43180. ray: Nullable<Ray>;
  43181. private _renderPoints;
  43182. private _renderLine;
  43183. private _renderFunction;
  43184. private _scene;
  43185. private _updateToMeshFunction;
  43186. private _attachedToMesh;
  43187. private _meshSpaceDirection;
  43188. private _meshSpaceOrigin;
  43189. /**
  43190. * Helper function to create a colored helper in a scene in one line.
  43191. * @param ray Defines the ray we are currently tryin to visualize
  43192. * @param scene Defines the scene the ray is used in
  43193. * @param color Defines the color we want to see the ray in
  43194. * @returns The newly created ray helper.
  43195. */
  43196. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43197. /**
  43198. * Instantiate a new ray helper.
  43199. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43200. * in order to better appreciate the issue one might have.
  43201. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43202. * @param ray Defines the ray we are currently tryin to visualize
  43203. */
  43204. constructor(ray: Ray);
  43205. /**
  43206. * Shows the ray we are willing to debug.
  43207. * @param scene Defines the scene the ray needs to be rendered in
  43208. * @param color Defines the color the ray needs to be rendered in
  43209. */
  43210. show(scene: Scene, color?: Color3): void;
  43211. /**
  43212. * Hides the ray we are debugging.
  43213. */
  43214. hide(): void;
  43215. private _render;
  43216. /**
  43217. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43218. * @param mesh Defines the mesh we want the helper attached to
  43219. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43220. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43221. * @param length Defines the length of the ray
  43222. */
  43223. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43224. /**
  43225. * Detach the ray helper from the mesh it has previously been attached to.
  43226. */
  43227. detachFromMesh(): void;
  43228. private _updateToMesh;
  43229. /**
  43230. * Dispose the helper and release its associated resources.
  43231. */
  43232. dispose(): void;
  43233. }
  43234. }
  43235. declare module BABYLON.Debug {
  43236. /**
  43237. * Class used to render a debug view of a given skeleton
  43238. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43239. */
  43240. export class SkeletonViewer {
  43241. /** defines the skeleton to render */
  43242. skeleton: Skeleton;
  43243. /** defines the mesh attached to the skeleton */
  43244. mesh: AbstractMesh;
  43245. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43246. autoUpdateBonesMatrices: boolean;
  43247. /** defines the rendering group id to use with the viewer */
  43248. renderingGroupId: number;
  43249. /** Gets or sets the color used to render the skeleton */
  43250. color: Color3;
  43251. private _scene;
  43252. private _debugLines;
  43253. private _debugMesh;
  43254. private _isEnabled;
  43255. private _renderFunction;
  43256. private _utilityLayer;
  43257. /**
  43258. * Returns the mesh used to render the bones
  43259. */
  43260. readonly debugMesh: Nullable<LinesMesh>;
  43261. /**
  43262. * Creates a new SkeletonViewer
  43263. * @param skeleton defines the skeleton to render
  43264. * @param mesh defines the mesh attached to the skeleton
  43265. * @param scene defines the hosting scene
  43266. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43267. * @param renderingGroupId defines the rendering group id to use with the viewer
  43268. */
  43269. constructor(
  43270. /** defines the skeleton to render */
  43271. skeleton: Skeleton,
  43272. /** defines the mesh attached to the skeleton */
  43273. mesh: AbstractMesh, scene: Scene,
  43274. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43275. autoUpdateBonesMatrices?: boolean,
  43276. /** defines the rendering group id to use with the viewer */
  43277. renderingGroupId?: number);
  43278. /** Gets or sets a boolean indicating if the viewer is enabled */
  43279. isEnabled: boolean;
  43280. private _getBonePosition;
  43281. private _getLinesForBonesWithLength;
  43282. private _getLinesForBonesNoLength;
  43283. /** Update the viewer to sync with current skeleton state */
  43284. update(): void;
  43285. /** Release associated resources */
  43286. dispose(): void;
  43287. }
  43288. }
  43289. declare module BABYLON {
  43290. /**
  43291. * Options to create the null engine
  43292. */
  43293. export class NullEngineOptions {
  43294. /**
  43295. * Render width (Default: 512)
  43296. */
  43297. renderWidth: number;
  43298. /**
  43299. * Render height (Default: 256)
  43300. */
  43301. renderHeight: number;
  43302. /**
  43303. * Texture size (Default: 512)
  43304. */
  43305. textureSize: number;
  43306. /**
  43307. * If delta time between frames should be constant
  43308. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43309. */
  43310. deterministicLockstep: boolean;
  43311. /**
  43312. * Maximum about of steps between frames (Default: 4)
  43313. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43314. */
  43315. lockstepMaxSteps: number;
  43316. }
  43317. /**
  43318. * The null engine class provides support for headless version of babylon.js.
  43319. * This can be used in server side scenario or for testing purposes
  43320. */
  43321. export class NullEngine extends Engine {
  43322. private _options;
  43323. /**
  43324. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43325. */
  43326. isDeterministicLockStep(): boolean;
  43327. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43328. getLockstepMaxSteps(): number;
  43329. /**
  43330. * Sets hardware scaling, used to save performance if needed
  43331. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43332. */
  43333. getHardwareScalingLevel(): number;
  43334. constructor(options?: NullEngineOptions);
  43335. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43336. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43337. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43338. getRenderWidth(useScreen?: boolean): number;
  43339. getRenderHeight(useScreen?: boolean): number;
  43340. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43341. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43342. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43343. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43344. bindSamplers(effect: Effect): void;
  43345. enableEffect(effect: Effect): void;
  43346. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43347. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43348. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43349. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43350. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43351. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43352. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43353. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43354. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43355. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43356. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43357. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43358. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43359. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43360. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43361. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43362. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43363. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43364. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43365. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43366. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43367. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43368. bindBuffers(vertexBuffers: {
  43369. [key: string]: VertexBuffer;
  43370. }, indexBuffer: DataBuffer, effect: Effect): void;
  43371. wipeCaches(bruteForce?: boolean): void;
  43372. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43373. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43374. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43375. /** @hidden */
  43376. _createTexture(): WebGLTexture;
  43377. /** @hidden */
  43378. _releaseTexture(texture: InternalTexture): void;
  43379. 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;
  43380. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43381. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43382. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43383. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43384. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43385. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43386. areAllEffectsReady(): boolean;
  43387. /**
  43388. * @hidden
  43389. * Get the current error code of the webGL context
  43390. * @returns the error code
  43391. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43392. */
  43393. getError(): number;
  43394. /** @hidden */
  43395. _getUnpackAlignement(): number;
  43396. /** @hidden */
  43397. _unpackFlipY(value: boolean): void;
  43398. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43399. /**
  43400. * Updates a dynamic vertex buffer.
  43401. * @param vertexBuffer the vertex buffer to update
  43402. * @param data the data used to update the vertex buffer
  43403. * @param byteOffset the byte offset of the data (optional)
  43404. * @param byteLength the byte length of the data (optional)
  43405. */
  43406. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43407. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43408. /** @hidden */
  43409. _bindTexture(channel: number, texture: InternalTexture): void;
  43410. /** @hidden */
  43411. _releaseBuffer(buffer: DataBuffer): boolean;
  43412. releaseEffects(): void;
  43413. displayLoadingUI(): void;
  43414. hideLoadingUI(): void;
  43415. /** @hidden */
  43416. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43417. /** @hidden */
  43418. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43419. /** @hidden */
  43420. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43421. /** @hidden */
  43422. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43423. }
  43424. }
  43425. declare module BABYLON {
  43426. /** @hidden */
  43427. export class _OcclusionDataStorage {
  43428. /** @hidden */
  43429. occlusionInternalRetryCounter: number;
  43430. /** @hidden */
  43431. isOcclusionQueryInProgress: boolean;
  43432. /** @hidden */
  43433. isOccluded: boolean;
  43434. /** @hidden */
  43435. occlusionRetryCount: number;
  43436. /** @hidden */
  43437. occlusionType: number;
  43438. /** @hidden */
  43439. occlusionQueryAlgorithmType: number;
  43440. }
  43441. interface Engine {
  43442. /**
  43443. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43444. * @return the new query
  43445. */
  43446. createQuery(): WebGLQuery;
  43447. /**
  43448. * Delete and release a webGL query
  43449. * @param query defines the query to delete
  43450. * @return the current engine
  43451. */
  43452. deleteQuery(query: WebGLQuery): Engine;
  43453. /**
  43454. * Check if a given query has resolved and got its value
  43455. * @param query defines the query to check
  43456. * @returns true if the query got its value
  43457. */
  43458. isQueryResultAvailable(query: WebGLQuery): boolean;
  43459. /**
  43460. * Gets the value of a given query
  43461. * @param query defines the query to check
  43462. * @returns the value of the query
  43463. */
  43464. getQueryResult(query: WebGLQuery): number;
  43465. /**
  43466. * Initiates an occlusion query
  43467. * @param algorithmType defines the algorithm to use
  43468. * @param query defines the query to use
  43469. * @returns the current engine
  43470. * @see http://doc.babylonjs.com/features/occlusionquery
  43471. */
  43472. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43473. /**
  43474. * Ends an occlusion query
  43475. * @see http://doc.babylonjs.com/features/occlusionquery
  43476. * @param algorithmType defines the algorithm to use
  43477. * @returns the current engine
  43478. */
  43479. endOcclusionQuery(algorithmType: number): Engine;
  43480. /**
  43481. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43482. * Please note that only one query can be issued at a time
  43483. * @returns a time token used to track the time span
  43484. */
  43485. startTimeQuery(): Nullable<_TimeToken>;
  43486. /**
  43487. * Ends a time query
  43488. * @param token defines the token used to measure the time span
  43489. * @returns the time spent (in ns)
  43490. */
  43491. endTimeQuery(token: _TimeToken): int;
  43492. /** @hidden */
  43493. _currentNonTimestampToken: Nullable<_TimeToken>;
  43494. /** @hidden */
  43495. _createTimeQuery(): WebGLQuery;
  43496. /** @hidden */
  43497. _deleteTimeQuery(query: WebGLQuery): void;
  43498. /** @hidden */
  43499. _getGlAlgorithmType(algorithmType: number): number;
  43500. /** @hidden */
  43501. _getTimeQueryResult(query: WebGLQuery): any;
  43502. /** @hidden */
  43503. _getTimeQueryAvailability(query: WebGLQuery): any;
  43504. }
  43505. interface AbstractMesh {
  43506. /**
  43507. * Backing filed
  43508. * @hidden
  43509. */
  43510. __occlusionDataStorage: _OcclusionDataStorage;
  43511. /**
  43512. * Access property
  43513. * @hidden
  43514. */
  43515. _occlusionDataStorage: _OcclusionDataStorage;
  43516. /**
  43517. * 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.
  43518. * The default value is -1 which means don't break the query and wait till the result
  43519. * @see http://doc.babylonjs.com/features/occlusionquery
  43520. */
  43521. occlusionRetryCount: number;
  43522. /**
  43523. * 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:
  43524. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43525. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43526. * * 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.
  43527. * @see http://doc.babylonjs.com/features/occlusionquery
  43528. */
  43529. occlusionType: number;
  43530. /**
  43531. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43532. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43533. * * 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.
  43534. * @see http://doc.babylonjs.com/features/occlusionquery
  43535. */
  43536. occlusionQueryAlgorithmType: number;
  43537. /**
  43538. * 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
  43539. * @see http://doc.babylonjs.com/features/occlusionquery
  43540. */
  43541. isOccluded: boolean;
  43542. /**
  43543. * Flag to check the progress status of the query
  43544. * @see http://doc.babylonjs.com/features/occlusionquery
  43545. */
  43546. isOcclusionQueryInProgress: boolean;
  43547. }
  43548. }
  43549. declare module BABYLON {
  43550. /** @hidden */
  43551. export var _forceTransformFeedbackToBundle: boolean;
  43552. interface Engine {
  43553. /**
  43554. * Creates a webGL transform feedback object
  43555. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43556. * @returns the webGL transform feedback object
  43557. */
  43558. createTransformFeedback(): WebGLTransformFeedback;
  43559. /**
  43560. * Delete a webGL transform feedback object
  43561. * @param value defines the webGL transform feedback object to delete
  43562. */
  43563. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43564. /**
  43565. * Bind a webGL transform feedback object to the webgl context
  43566. * @param value defines the webGL transform feedback object to bind
  43567. */
  43568. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43569. /**
  43570. * Begins a transform feedback operation
  43571. * @param usePoints defines if points or triangles must be used
  43572. */
  43573. beginTransformFeedback(usePoints: boolean): void;
  43574. /**
  43575. * Ends a transform feedback operation
  43576. */
  43577. endTransformFeedback(): void;
  43578. /**
  43579. * Specify the varyings to use with transform feedback
  43580. * @param program defines the associated webGL program
  43581. * @param value defines the list of strings representing the varying names
  43582. */
  43583. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43584. /**
  43585. * Bind a webGL buffer for a transform feedback operation
  43586. * @param value defines the webGL buffer to bind
  43587. */
  43588. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43589. }
  43590. }
  43591. declare module BABYLON {
  43592. /**
  43593. * Creation options of the multi render target texture.
  43594. */
  43595. export interface IMultiRenderTargetOptions {
  43596. /**
  43597. * Define if the texture needs to create mip maps after render.
  43598. */
  43599. generateMipMaps?: boolean;
  43600. /**
  43601. * Define the types of all the draw buffers we want to create
  43602. */
  43603. types?: number[];
  43604. /**
  43605. * Define the sampling modes of all the draw buffers we want to create
  43606. */
  43607. samplingModes?: number[];
  43608. /**
  43609. * Define if a depth buffer is required
  43610. */
  43611. generateDepthBuffer?: boolean;
  43612. /**
  43613. * Define if a stencil buffer is required
  43614. */
  43615. generateStencilBuffer?: boolean;
  43616. /**
  43617. * Define if a depth texture is required instead of a depth buffer
  43618. */
  43619. generateDepthTexture?: boolean;
  43620. /**
  43621. * Define the number of desired draw buffers
  43622. */
  43623. textureCount?: number;
  43624. /**
  43625. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43626. */
  43627. doNotChangeAspectRatio?: boolean;
  43628. /**
  43629. * Define the default type of the buffers we are creating
  43630. */
  43631. defaultType?: number;
  43632. }
  43633. /**
  43634. * A multi render target, like a render target provides the ability to render to a texture.
  43635. * Unlike the render target, it can render to several draw buffers in one draw.
  43636. * This is specially interesting in deferred rendering or for any effects requiring more than
  43637. * just one color from a single pass.
  43638. */
  43639. export class MultiRenderTarget extends RenderTargetTexture {
  43640. private _internalTextures;
  43641. private _textures;
  43642. private _multiRenderTargetOptions;
  43643. /**
  43644. * Get if draw buffers are currently supported by the used hardware and browser.
  43645. */
  43646. readonly isSupported: boolean;
  43647. /**
  43648. * Get the list of textures generated by the multi render target.
  43649. */
  43650. readonly textures: Texture[];
  43651. /**
  43652. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43653. */
  43654. readonly depthTexture: Texture;
  43655. /**
  43656. * Set the wrapping mode on U of all the textures we are rendering to.
  43657. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43658. */
  43659. wrapU: number;
  43660. /**
  43661. * Set the wrapping mode on V of all the textures we are rendering to.
  43662. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43663. */
  43664. wrapV: number;
  43665. /**
  43666. * Instantiate a new multi render target texture.
  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. * @param name Define the name of the texture
  43672. * @param size Define the size of the buffers to render to
  43673. * @param count Define the number of target we are rendering into
  43674. * @param scene Define the scene the texture belongs to
  43675. * @param options Define the options used to create the multi render target
  43676. */
  43677. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43678. /** @hidden */
  43679. _rebuild(): void;
  43680. private _createInternalTextures;
  43681. private _createTextures;
  43682. /**
  43683. * Define the number of samples used if MSAA is enabled.
  43684. */
  43685. samples: number;
  43686. /**
  43687. * Resize all the textures in the multi render target.
  43688. * Be carrefull as it will recreate all the data in the new texture.
  43689. * @param size Define the new size
  43690. */
  43691. resize(size: any): void;
  43692. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43693. /**
  43694. * Dispose the render targets and their associated resources
  43695. */
  43696. dispose(): void;
  43697. /**
  43698. * Release all the underlying texture used as draw buffers.
  43699. */
  43700. releaseInternalTextures(): void;
  43701. }
  43702. }
  43703. declare module BABYLON {
  43704. interface Engine {
  43705. /**
  43706. * Unbind a list of render target textures from the webGL context
  43707. * This is used only when drawBuffer extension or webGL2 are active
  43708. * @param textures defines the render target textures to unbind
  43709. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43710. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43711. */
  43712. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43713. /**
  43714. * Create a multi render target texture
  43715. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43716. * @param size defines the size of the texture
  43717. * @param options defines the creation options
  43718. * @returns the cube texture as an InternalTexture
  43719. */
  43720. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43721. /**
  43722. * Update the sample count for a given multiple render target texture
  43723. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43724. * @param textures defines the textures to update
  43725. * @param samples defines the sample count to set
  43726. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43727. */
  43728. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43729. }
  43730. }
  43731. declare module BABYLON {
  43732. /**
  43733. * Gather the list of clipboard event types as constants.
  43734. */
  43735. export class ClipboardEventTypes {
  43736. /**
  43737. * The clipboard event is fired when a copy command is active (pressed).
  43738. */
  43739. static readonly COPY: number;
  43740. /**
  43741. * The clipboard event is fired when a cut command is active (pressed).
  43742. */
  43743. static readonly CUT: number;
  43744. /**
  43745. * The clipboard event is fired when a paste command is active (pressed).
  43746. */
  43747. static readonly PASTE: number;
  43748. }
  43749. /**
  43750. * This class is used to store clipboard related info for the onClipboardObservable event.
  43751. */
  43752. export class ClipboardInfo {
  43753. /**
  43754. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43755. */
  43756. type: number;
  43757. /**
  43758. * Defines the related dom event
  43759. */
  43760. event: ClipboardEvent;
  43761. /**
  43762. *Creates an instance of ClipboardInfo.
  43763. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43764. * @param event Defines the related dom event
  43765. */
  43766. constructor(
  43767. /**
  43768. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43769. */
  43770. type: number,
  43771. /**
  43772. * Defines the related dom event
  43773. */
  43774. event: ClipboardEvent);
  43775. /**
  43776. * Get the clipboard event's type from the keycode.
  43777. * @param keyCode Defines the keyCode for the current keyboard event.
  43778. * @return {number}
  43779. */
  43780. static GetTypeFromCharacter(keyCode: number): number;
  43781. }
  43782. }
  43783. declare module BABYLON {
  43784. /**
  43785. * Google Daydream controller
  43786. */
  43787. export class DaydreamController extends WebVRController {
  43788. /**
  43789. * Base Url for the controller model.
  43790. */
  43791. static MODEL_BASE_URL: string;
  43792. /**
  43793. * File name for the controller model.
  43794. */
  43795. static MODEL_FILENAME: string;
  43796. /**
  43797. * Gamepad Id prefix used to identify Daydream Controller.
  43798. */
  43799. static readonly GAMEPAD_ID_PREFIX: string;
  43800. /**
  43801. * Creates a new DaydreamController from a gamepad
  43802. * @param vrGamepad the gamepad that the controller should be created from
  43803. */
  43804. constructor(vrGamepad: any);
  43805. /**
  43806. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43807. * @param scene scene in which to add meshes
  43808. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43809. */
  43810. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43811. /**
  43812. * Called once for each button that changed state since the last frame
  43813. * @param buttonIdx Which button index changed
  43814. * @param state New state of the button
  43815. * @param changes Which properties on the state changed since last frame
  43816. */
  43817. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43818. }
  43819. }
  43820. declare module BABYLON {
  43821. /**
  43822. * Gear VR Controller
  43823. */
  43824. export class GearVRController extends WebVRController {
  43825. /**
  43826. * Base Url for the controller model.
  43827. */
  43828. static MODEL_BASE_URL: string;
  43829. /**
  43830. * File name for the controller model.
  43831. */
  43832. static MODEL_FILENAME: string;
  43833. /**
  43834. * Gamepad Id prefix used to identify this controller.
  43835. */
  43836. static readonly GAMEPAD_ID_PREFIX: string;
  43837. private readonly _buttonIndexToObservableNameMap;
  43838. /**
  43839. * Creates a new GearVRController from a gamepad
  43840. * @param vrGamepad the gamepad that the controller should be created from
  43841. */
  43842. constructor(vrGamepad: any);
  43843. /**
  43844. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43845. * @param scene scene in which to add meshes
  43846. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43847. */
  43848. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43849. /**
  43850. * Called once for each button that changed state since the last frame
  43851. * @param buttonIdx Which button index changed
  43852. * @param state New state of the button
  43853. * @param changes Which properties on the state changed since last frame
  43854. */
  43855. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43856. }
  43857. }
  43858. declare module BABYLON {
  43859. /**
  43860. * Class containing static functions to help procedurally build meshes
  43861. */
  43862. export class PolyhedronBuilder {
  43863. /**
  43864. * Creates a polyhedron mesh
  43865. * * 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
  43866. * * The parameter `size` (positive float, default 1) sets the polygon size
  43867. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43868. * * 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`
  43869. * * 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
  43870. * * 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)`)
  43871. * * 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
  43872. * * 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
  43873. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43874. * * 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
  43875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43876. * @param name defines the name of the mesh
  43877. * @param options defines the options used to create the mesh
  43878. * @param scene defines the hosting scene
  43879. * @returns the polyhedron mesh
  43880. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43881. */
  43882. static CreatePolyhedron(name: string, options: {
  43883. type?: number;
  43884. size?: number;
  43885. sizeX?: number;
  43886. sizeY?: number;
  43887. sizeZ?: number;
  43888. custom?: any;
  43889. faceUV?: Vector4[];
  43890. faceColors?: Color4[];
  43891. flat?: boolean;
  43892. updatable?: boolean;
  43893. sideOrientation?: number;
  43894. frontUVs?: Vector4;
  43895. backUVs?: Vector4;
  43896. }, scene?: Nullable<Scene>): Mesh;
  43897. }
  43898. }
  43899. declare module BABYLON {
  43900. /**
  43901. * Gizmo that enables scaling a mesh along 3 axis
  43902. */
  43903. export class ScaleGizmo extends Gizmo {
  43904. /**
  43905. * Internal gizmo used for interactions on the x axis
  43906. */
  43907. xGizmo: AxisScaleGizmo;
  43908. /**
  43909. * Internal gizmo used for interactions on the y axis
  43910. */
  43911. yGizmo: AxisScaleGizmo;
  43912. /**
  43913. * Internal gizmo used for interactions on the z axis
  43914. */
  43915. zGizmo: AxisScaleGizmo;
  43916. /**
  43917. * Internal gizmo used to scale all axis equally
  43918. */
  43919. uniformScaleGizmo: AxisScaleGizmo;
  43920. private _meshAttached;
  43921. private _updateGizmoRotationToMatchAttachedMesh;
  43922. private _snapDistance;
  43923. private _scaleRatio;
  43924. private _uniformScalingMesh;
  43925. private _octahedron;
  43926. /** Fires an event when any of it's sub gizmos are dragged */
  43927. onDragStartObservable: Observable<unknown>;
  43928. /** Fires an event when any of it's sub gizmos are released from dragging */
  43929. onDragEndObservable: Observable<unknown>;
  43930. attachedMesh: Nullable<AbstractMesh>;
  43931. /**
  43932. * Creates a ScaleGizmo
  43933. * @param gizmoLayer The utility layer the gizmo will be added to
  43934. */
  43935. constructor(gizmoLayer?: UtilityLayerRenderer);
  43936. updateGizmoRotationToMatchAttachedMesh: boolean;
  43937. /**
  43938. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43939. */
  43940. snapDistance: number;
  43941. /**
  43942. * Ratio for the scale of the gizmo (Default: 1)
  43943. */
  43944. scaleRatio: number;
  43945. /**
  43946. * Disposes of the gizmo
  43947. */
  43948. dispose(): void;
  43949. }
  43950. }
  43951. declare module BABYLON {
  43952. /**
  43953. * Single axis scale gizmo
  43954. */
  43955. export class AxisScaleGizmo extends Gizmo {
  43956. /**
  43957. * Drag behavior responsible for the gizmos dragging interactions
  43958. */
  43959. dragBehavior: PointerDragBehavior;
  43960. private _pointerObserver;
  43961. /**
  43962. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43963. */
  43964. snapDistance: number;
  43965. /**
  43966. * Event that fires each time the gizmo snaps to a new location.
  43967. * * snapDistance is the the change in distance
  43968. */
  43969. onSnapObservable: Observable<{
  43970. snapDistance: number;
  43971. }>;
  43972. /**
  43973. * If the scaling operation should be done on all axis (default: false)
  43974. */
  43975. uniformScaling: boolean;
  43976. private _isEnabled;
  43977. private _parent;
  43978. private _arrow;
  43979. private _coloredMaterial;
  43980. private _hoverMaterial;
  43981. /**
  43982. * Creates an AxisScaleGizmo
  43983. * @param gizmoLayer The utility layer the gizmo will be added to
  43984. * @param dragAxis The axis which the gizmo will be able to scale on
  43985. * @param color The color of the gizmo
  43986. */
  43987. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  43988. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43989. /**
  43990. * If the gizmo is enabled
  43991. */
  43992. isEnabled: boolean;
  43993. /**
  43994. * Disposes of the gizmo
  43995. */
  43996. dispose(): void;
  43997. /**
  43998. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43999. * @param mesh The mesh to replace the default mesh of the gizmo
  44000. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44001. */
  44002. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44003. }
  44004. }
  44005. declare module BABYLON {
  44006. /**
  44007. * Bounding box gizmo
  44008. */
  44009. export class BoundingBoxGizmo extends Gizmo {
  44010. private _lineBoundingBox;
  44011. private _rotateSpheresParent;
  44012. private _scaleBoxesParent;
  44013. private _boundingDimensions;
  44014. private _renderObserver;
  44015. private _pointerObserver;
  44016. private _scaleDragSpeed;
  44017. private _tmpQuaternion;
  44018. private _tmpVector;
  44019. private _tmpRotationMatrix;
  44020. /**
  44021. * 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)
  44022. */
  44023. ignoreChildren: boolean;
  44024. /**
  44025. * 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)
  44026. */
  44027. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44028. /**
  44029. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44030. */
  44031. rotationSphereSize: number;
  44032. /**
  44033. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44034. */
  44035. scaleBoxSize: number;
  44036. /**
  44037. * 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)
  44038. */
  44039. fixedDragMeshScreenSize: boolean;
  44040. /**
  44041. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44042. */
  44043. fixedDragMeshScreenSizeDistanceFactor: number;
  44044. /**
  44045. * Fired when a rotation sphere or scale box is dragged
  44046. */
  44047. onDragStartObservable: Observable<{}>;
  44048. /**
  44049. * Fired when a scale box is dragged
  44050. */
  44051. onScaleBoxDragObservable: Observable<{}>;
  44052. /**
  44053. * Fired when a scale box drag is ended
  44054. */
  44055. onScaleBoxDragEndObservable: Observable<{}>;
  44056. /**
  44057. * Fired when a rotation sphere is dragged
  44058. */
  44059. onRotationSphereDragObservable: Observable<{}>;
  44060. /**
  44061. * Fired when a rotation sphere drag is ended
  44062. */
  44063. onRotationSphereDragEndObservable: Observable<{}>;
  44064. /**
  44065. * 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)
  44066. */
  44067. scalePivot: Nullable<Vector3>;
  44068. /**
  44069. * Mesh used as a pivot to rotate the attached mesh
  44070. */
  44071. private _anchorMesh;
  44072. private _existingMeshScale;
  44073. private _dragMesh;
  44074. private pointerDragBehavior;
  44075. private coloredMaterial;
  44076. private hoverColoredMaterial;
  44077. /**
  44078. * Sets the color of the bounding box gizmo
  44079. * @param color the color to set
  44080. */
  44081. setColor(color: Color3): void;
  44082. /**
  44083. * Creates an BoundingBoxGizmo
  44084. * @param gizmoLayer The utility layer the gizmo will be added to
  44085. * @param color The color of the gizmo
  44086. */
  44087. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44088. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44089. private _selectNode;
  44090. /**
  44091. * Updates the bounding box information for the Gizmo
  44092. */
  44093. updateBoundingBox(): void;
  44094. private _updateRotationSpheres;
  44095. private _updateScaleBoxes;
  44096. /**
  44097. * Enables rotation on the specified axis and disables rotation on the others
  44098. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44099. */
  44100. setEnabledRotationAxis(axis: string): void;
  44101. /**
  44102. * Enables/disables scaling
  44103. * @param enable if scaling should be enabled
  44104. */
  44105. setEnabledScaling(enable: boolean): void;
  44106. private _updateDummy;
  44107. /**
  44108. * Enables a pointer drag behavior on the bounding box of the gizmo
  44109. */
  44110. enableDragBehavior(): void;
  44111. /**
  44112. * Disposes of the gizmo
  44113. */
  44114. dispose(): void;
  44115. /**
  44116. * 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)
  44117. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44118. * @returns the bounding box mesh with the passed in mesh as a child
  44119. */
  44120. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44121. /**
  44122. * CustomMeshes are not supported by this gizmo
  44123. * @param mesh The mesh to replace the default mesh of the gizmo
  44124. */
  44125. setCustomMesh(mesh: Mesh): void;
  44126. }
  44127. }
  44128. declare module BABYLON {
  44129. /**
  44130. * Single plane rotation gizmo
  44131. */
  44132. export class PlaneRotationGizmo extends Gizmo {
  44133. /**
  44134. * Drag behavior responsible for the gizmos dragging interactions
  44135. */
  44136. dragBehavior: PointerDragBehavior;
  44137. private _pointerObserver;
  44138. /**
  44139. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44140. */
  44141. snapDistance: number;
  44142. /**
  44143. * Event that fires each time the gizmo snaps to a new location.
  44144. * * snapDistance is the the change in distance
  44145. */
  44146. onSnapObservable: Observable<{
  44147. snapDistance: number;
  44148. }>;
  44149. private _isEnabled;
  44150. private _parent;
  44151. /**
  44152. * Creates a PlaneRotationGizmo
  44153. * @param gizmoLayer The utility layer the gizmo will be added to
  44154. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44155. * @param color The color of the gizmo
  44156. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44157. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44158. */
  44159. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  44160. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44161. /**
  44162. * If the gizmo is enabled
  44163. */
  44164. isEnabled: boolean;
  44165. /**
  44166. * Disposes of the gizmo
  44167. */
  44168. dispose(): void;
  44169. }
  44170. }
  44171. declare module BABYLON {
  44172. /**
  44173. * Gizmo that enables rotating a mesh along 3 axis
  44174. */
  44175. export class RotationGizmo extends Gizmo {
  44176. /**
  44177. * Internal gizmo used for interactions on the x axis
  44178. */
  44179. xGizmo: PlaneRotationGizmo;
  44180. /**
  44181. * Internal gizmo used for interactions on the y axis
  44182. */
  44183. yGizmo: PlaneRotationGizmo;
  44184. /**
  44185. * Internal gizmo used for interactions on the z axis
  44186. */
  44187. zGizmo: PlaneRotationGizmo;
  44188. /** Fires an event when any of it's sub gizmos are dragged */
  44189. onDragStartObservable: Observable<unknown>;
  44190. /** Fires an event when any of it's sub gizmos are released from dragging */
  44191. onDragEndObservable: Observable<unknown>;
  44192. private _meshAttached;
  44193. attachedMesh: Nullable<AbstractMesh>;
  44194. /**
  44195. * Creates a RotationGizmo
  44196. * @param gizmoLayer The utility layer the gizmo will be added to
  44197. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44198. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44199. */
  44200. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  44201. updateGizmoRotationToMatchAttachedMesh: boolean;
  44202. /**
  44203. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44204. */
  44205. snapDistance: number;
  44206. /**
  44207. * Ratio for the scale of the gizmo (Default: 1)
  44208. */
  44209. scaleRatio: number;
  44210. /**
  44211. * Disposes of the gizmo
  44212. */
  44213. dispose(): void;
  44214. /**
  44215. * CustomMeshes are not supported by this gizmo
  44216. * @param mesh The mesh to replace the default mesh of the gizmo
  44217. */
  44218. setCustomMesh(mesh: Mesh): void;
  44219. }
  44220. }
  44221. declare module BABYLON {
  44222. /**
  44223. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44224. */
  44225. export class GizmoManager implements IDisposable {
  44226. private scene;
  44227. /**
  44228. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44229. */
  44230. gizmos: {
  44231. positionGizmo: Nullable<PositionGizmo>;
  44232. rotationGizmo: Nullable<RotationGizmo>;
  44233. scaleGizmo: Nullable<ScaleGizmo>;
  44234. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44235. };
  44236. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44237. clearGizmoOnEmptyPointerEvent: boolean;
  44238. /** Fires an event when the manager is attached to a mesh */
  44239. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44240. private _gizmosEnabled;
  44241. private _pointerObserver;
  44242. private _attachedMesh;
  44243. private _boundingBoxColor;
  44244. private _defaultUtilityLayer;
  44245. private _defaultKeepDepthUtilityLayer;
  44246. /**
  44247. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44248. */
  44249. boundingBoxDragBehavior: SixDofDragBehavior;
  44250. /**
  44251. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44252. */
  44253. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44254. /**
  44255. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44256. */
  44257. usePointerToAttachGizmos: boolean;
  44258. /**
  44259. * Utility layer that the bounding box gizmo belongs to
  44260. */
  44261. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  44262. /**
  44263. * Utility layer that all gizmos besides bounding box belong to
  44264. */
  44265. readonly utilityLayer: UtilityLayerRenderer;
  44266. /**
  44267. * Instatiates a gizmo manager
  44268. * @param scene the scene to overlay the gizmos on top of
  44269. */
  44270. constructor(scene: Scene);
  44271. /**
  44272. * Attaches a set of gizmos to the specified mesh
  44273. * @param mesh The mesh the gizmo's should be attached to
  44274. */
  44275. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44276. /**
  44277. * If the position gizmo is enabled
  44278. */
  44279. positionGizmoEnabled: boolean;
  44280. /**
  44281. * If the rotation gizmo is enabled
  44282. */
  44283. rotationGizmoEnabled: boolean;
  44284. /**
  44285. * If the scale gizmo is enabled
  44286. */
  44287. scaleGizmoEnabled: boolean;
  44288. /**
  44289. * If the boundingBox gizmo is enabled
  44290. */
  44291. boundingBoxGizmoEnabled: boolean;
  44292. /**
  44293. * Disposes of the gizmo manager
  44294. */
  44295. dispose(): void;
  44296. }
  44297. }
  44298. declare module BABYLON {
  44299. /**
  44300. * A directional light is defined by a direction (what a surprise!).
  44301. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44302. * 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.
  44303. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44304. */
  44305. export class DirectionalLight extends ShadowLight {
  44306. private _shadowFrustumSize;
  44307. /**
  44308. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44309. */
  44310. /**
  44311. * Specifies a fix frustum size for the shadow generation.
  44312. */
  44313. shadowFrustumSize: number;
  44314. private _shadowOrthoScale;
  44315. /**
  44316. * Gets the shadow projection scale against the optimal computed one.
  44317. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44318. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44319. */
  44320. /**
  44321. * Sets the shadow projection scale against the optimal computed one.
  44322. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44323. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44324. */
  44325. shadowOrthoScale: number;
  44326. /**
  44327. * Automatically compute the projection matrix to best fit (including all the casters)
  44328. * on each frame.
  44329. */
  44330. autoUpdateExtends: boolean;
  44331. private _orthoLeft;
  44332. private _orthoRight;
  44333. private _orthoTop;
  44334. private _orthoBottom;
  44335. /**
  44336. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44337. * The directional light is emitted from everywhere in the given direction.
  44338. * It can cast shadows.
  44339. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44340. * @param name The friendly name of the light
  44341. * @param direction The direction of the light
  44342. * @param scene The scene the light belongs to
  44343. */
  44344. constructor(name: string, direction: Vector3, scene: Scene);
  44345. /**
  44346. * Returns the string "DirectionalLight".
  44347. * @return The class name
  44348. */
  44349. getClassName(): string;
  44350. /**
  44351. * Returns the integer 1.
  44352. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44353. */
  44354. getTypeID(): number;
  44355. /**
  44356. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44357. * Returns the DirectionalLight Shadow projection matrix.
  44358. */
  44359. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44360. /**
  44361. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44362. * Returns the DirectionalLight Shadow projection matrix.
  44363. */
  44364. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44365. /**
  44366. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44367. * Returns the DirectionalLight Shadow projection matrix.
  44368. */
  44369. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44370. protected _buildUniformLayout(): void;
  44371. /**
  44372. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44373. * @param effect The effect to update
  44374. * @param lightIndex The index of the light in the effect to update
  44375. * @returns The directional light
  44376. */
  44377. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44378. /**
  44379. * Gets the minZ used for shadow according to both the scene and the light.
  44380. *
  44381. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44382. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44383. * @param activeCamera The camera we are returning the min for
  44384. * @returns the depth min z
  44385. */
  44386. getDepthMinZ(activeCamera: Camera): number;
  44387. /**
  44388. * Gets the maxZ used for shadow according to both the scene and the light.
  44389. *
  44390. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44391. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44392. * @param activeCamera The camera we are returning the max for
  44393. * @returns the depth max z
  44394. */
  44395. getDepthMaxZ(activeCamera: Camera): number;
  44396. /**
  44397. * Prepares the list of defines specific to the light type.
  44398. * @param defines the list of defines
  44399. * @param lightIndex defines the index of the light for the effect
  44400. */
  44401. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44402. }
  44403. }
  44404. declare module BABYLON {
  44405. /**
  44406. * Class containing static functions to help procedurally build meshes
  44407. */
  44408. export class HemisphereBuilder {
  44409. /**
  44410. * Creates a hemisphere mesh
  44411. * @param name defines the name of the mesh
  44412. * @param options defines the options used to create the mesh
  44413. * @param scene defines the hosting scene
  44414. * @returns the hemisphere mesh
  44415. */
  44416. static CreateHemisphere(name: string, options: {
  44417. segments?: number;
  44418. diameter?: number;
  44419. sideOrientation?: number;
  44420. }, scene: any): Mesh;
  44421. }
  44422. }
  44423. declare module BABYLON {
  44424. /**
  44425. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44426. * These values define a cone of light starting from the position, emitting toward the direction.
  44427. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44428. * and the exponent defines the speed of the decay of the light with distance (reach).
  44429. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44430. */
  44431. export class SpotLight extends ShadowLight {
  44432. private _angle;
  44433. private _innerAngle;
  44434. private _cosHalfAngle;
  44435. private _lightAngleScale;
  44436. private _lightAngleOffset;
  44437. /**
  44438. * Gets the cone angle of the spot light in Radians.
  44439. */
  44440. /**
  44441. * Sets the cone angle of the spot light in Radians.
  44442. */
  44443. angle: number;
  44444. /**
  44445. * Only used in gltf falloff mode, this defines the angle where
  44446. * the directional falloff will start before cutting at angle which could be seen
  44447. * as outer angle.
  44448. */
  44449. /**
  44450. * Only used in gltf falloff mode, this defines the angle where
  44451. * the directional falloff will start before cutting at angle which could be seen
  44452. * as outer angle.
  44453. */
  44454. innerAngle: number;
  44455. private _shadowAngleScale;
  44456. /**
  44457. * Allows scaling the angle of the light for shadow generation only.
  44458. */
  44459. /**
  44460. * Allows scaling the angle of the light for shadow generation only.
  44461. */
  44462. shadowAngleScale: number;
  44463. /**
  44464. * The light decay speed with the distance from the emission spot.
  44465. */
  44466. exponent: number;
  44467. private _projectionTextureMatrix;
  44468. /**
  44469. * Allows reading the projecton texture
  44470. */
  44471. readonly projectionTextureMatrix: Matrix;
  44472. protected _projectionTextureLightNear: number;
  44473. /**
  44474. * Gets the near clip of the Spotlight for texture projection.
  44475. */
  44476. /**
  44477. * Sets the near clip of the Spotlight for texture projection.
  44478. */
  44479. projectionTextureLightNear: number;
  44480. protected _projectionTextureLightFar: number;
  44481. /**
  44482. * Gets the far clip of the Spotlight for texture projection.
  44483. */
  44484. /**
  44485. * Sets the far clip of the Spotlight for texture projection.
  44486. */
  44487. projectionTextureLightFar: number;
  44488. protected _projectionTextureUpDirection: Vector3;
  44489. /**
  44490. * Gets the Up vector of the Spotlight for texture projection.
  44491. */
  44492. /**
  44493. * Sets the Up vector of the Spotlight for texture projection.
  44494. */
  44495. projectionTextureUpDirection: Vector3;
  44496. private _projectionTexture;
  44497. /**
  44498. * Gets the projection texture of the light.
  44499. */
  44500. /**
  44501. * Sets the projection texture of the light.
  44502. */
  44503. projectionTexture: Nullable<BaseTexture>;
  44504. private _projectionTextureViewLightDirty;
  44505. private _projectionTextureProjectionLightDirty;
  44506. private _projectionTextureDirty;
  44507. private _projectionTextureViewTargetVector;
  44508. private _projectionTextureViewLightMatrix;
  44509. private _projectionTextureProjectionLightMatrix;
  44510. private _projectionTextureScalingMatrix;
  44511. /**
  44512. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44513. * It can cast shadows.
  44514. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44515. * @param name The light friendly name
  44516. * @param position The position of the spot light in the scene
  44517. * @param direction The direction of the light in the scene
  44518. * @param angle The cone angle of the light in Radians
  44519. * @param exponent The light decay speed with the distance from the emission spot
  44520. * @param scene The scene the lights belongs to
  44521. */
  44522. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44523. /**
  44524. * Returns the string "SpotLight".
  44525. * @returns the class name
  44526. */
  44527. getClassName(): string;
  44528. /**
  44529. * Returns the integer 2.
  44530. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44531. */
  44532. getTypeID(): number;
  44533. /**
  44534. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44535. */
  44536. protected _setDirection(value: Vector3): void;
  44537. /**
  44538. * Overrides the position setter to recompute the projection texture view light Matrix.
  44539. */
  44540. protected _setPosition(value: Vector3): void;
  44541. /**
  44542. * 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.
  44543. * Returns the SpotLight.
  44544. */
  44545. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44546. protected _computeProjectionTextureViewLightMatrix(): void;
  44547. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44548. /**
  44549. * Main function for light texture projection matrix computing.
  44550. */
  44551. protected _computeProjectionTextureMatrix(): void;
  44552. protected _buildUniformLayout(): void;
  44553. private _computeAngleValues;
  44554. /**
  44555. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44556. * @param effect The effect to update
  44557. * @param lightIndex The index of the light in the effect to update
  44558. * @returns The spot light
  44559. */
  44560. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44561. /**
  44562. * Disposes the light and the associated resources.
  44563. */
  44564. dispose(): void;
  44565. /**
  44566. * Prepares the list of defines specific to the light type.
  44567. * @param defines the list of defines
  44568. * @param lightIndex defines the index of the light for the effect
  44569. */
  44570. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44571. }
  44572. }
  44573. declare module BABYLON {
  44574. /**
  44575. * Gizmo that enables viewing a light
  44576. */
  44577. export class LightGizmo extends Gizmo {
  44578. private _lightMesh;
  44579. private _material;
  44580. private cachedPosition;
  44581. private cachedForward;
  44582. /**
  44583. * Creates a LightGizmo
  44584. * @param gizmoLayer The utility layer the gizmo will be added to
  44585. */
  44586. constructor(gizmoLayer?: UtilityLayerRenderer);
  44587. private _light;
  44588. /**
  44589. * The light that the gizmo is attached to
  44590. */
  44591. light: Nullable<Light>;
  44592. /**
  44593. * Gets the material used to render the light gizmo
  44594. */
  44595. readonly material: StandardMaterial;
  44596. /**
  44597. * @hidden
  44598. * Updates the gizmo to match the attached mesh's position/rotation
  44599. */
  44600. protected _update(): void;
  44601. private static _Scale;
  44602. /**
  44603. * Creates the lines for a light mesh
  44604. */
  44605. private static _createLightLines;
  44606. /**
  44607. * Disposes of the light gizmo
  44608. */
  44609. dispose(): void;
  44610. private static _CreateHemisphericLightMesh;
  44611. private static _CreatePointLightMesh;
  44612. private static _CreateSpotLightMesh;
  44613. private static _CreateDirectionalLightMesh;
  44614. }
  44615. }
  44616. declare module BABYLON {
  44617. /** @hidden */
  44618. export var backgroundFragmentDeclaration: {
  44619. name: string;
  44620. shader: string;
  44621. };
  44622. }
  44623. declare module BABYLON {
  44624. /** @hidden */
  44625. export var backgroundUboDeclaration: {
  44626. name: string;
  44627. shader: string;
  44628. };
  44629. }
  44630. declare module BABYLON {
  44631. /** @hidden */
  44632. export var backgroundPixelShader: {
  44633. name: string;
  44634. shader: string;
  44635. };
  44636. }
  44637. declare module BABYLON {
  44638. /** @hidden */
  44639. export var backgroundVertexDeclaration: {
  44640. name: string;
  44641. shader: string;
  44642. };
  44643. }
  44644. declare module BABYLON {
  44645. /** @hidden */
  44646. export var backgroundVertexShader: {
  44647. name: string;
  44648. shader: string;
  44649. };
  44650. }
  44651. declare module BABYLON {
  44652. /**
  44653. * Background material used to create an efficient environement around your scene.
  44654. */
  44655. export class BackgroundMaterial extends PushMaterial {
  44656. /**
  44657. * Standard reflectance value at parallel view angle.
  44658. */
  44659. static StandardReflectance0: number;
  44660. /**
  44661. * Standard reflectance value at grazing angle.
  44662. */
  44663. static StandardReflectance90: number;
  44664. protected _primaryColor: Color3;
  44665. /**
  44666. * Key light Color (multiply against the environement texture)
  44667. */
  44668. primaryColor: Color3;
  44669. protected __perceptualColor: Nullable<Color3>;
  44670. /**
  44671. * Experimental Internal Use Only.
  44672. *
  44673. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44674. * This acts as a helper to set the primary color to a more "human friendly" value.
  44675. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44676. * output color as close as possible from the chosen value.
  44677. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44678. * part of lighting setup.)
  44679. */
  44680. _perceptualColor: Nullable<Color3>;
  44681. protected _primaryColorShadowLevel: float;
  44682. /**
  44683. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44684. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44685. */
  44686. primaryColorShadowLevel: float;
  44687. protected _primaryColorHighlightLevel: float;
  44688. /**
  44689. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44690. * The primary color is used at the level chosen to define what the white area would look.
  44691. */
  44692. primaryColorHighlightLevel: float;
  44693. protected _reflectionTexture: Nullable<BaseTexture>;
  44694. /**
  44695. * Reflection Texture used in the material.
  44696. * Should be author in a specific way for the best result (refer to the documentation).
  44697. */
  44698. reflectionTexture: Nullable<BaseTexture>;
  44699. protected _reflectionBlur: float;
  44700. /**
  44701. * Reflection Texture level of blur.
  44702. *
  44703. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44704. * texture twice.
  44705. */
  44706. reflectionBlur: float;
  44707. protected _diffuseTexture: Nullable<BaseTexture>;
  44708. /**
  44709. * Diffuse Texture used in the material.
  44710. * Should be author in a specific way for the best result (refer to the documentation).
  44711. */
  44712. diffuseTexture: Nullable<BaseTexture>;
  44713. protected _shadowLights: Nullable<IShadowLight[]>;
  44714. /**
  44715. * Specify the list of lights casting shadow on the material.
  44716. * All scene shadow lights will be included if null.
  44717. */
  44718. shadowLights: Nullable<IShadowLight[]>;
  44719. protected _shadowLevel: float;
  44720. /**
  44721. * Helps adjusting the shadow to a softer level if required.
  44722. * 0 means black shadows and 1 means no shadows.
  44723. */
  44724. shadowLevel: float;
  44725. protected _sceneCenter: Vector3;
  44726. /**
  44727. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44728. * It is usually zero but might be interesting to modify according to your setup.
  44729. */
  44730. sceneCenter: Vector3;
  44731. protected _opacityFresnel: boolean;
  44732. /**
  44733. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44734. * This helps ensuring a nice transition when the camera goes under the ground.
  44735. */
  44736. opacityFresnel: boolean;
  44737. protected _reflectionFresnel: boolean;
  44738. /**
  44739. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44740. * This helps adding a mirror texture on the ground.
  44741. */
  44742. reflectionFresnel: boolean;
  44743. protected _reflectionFalloffDistance: number;
  44744. /**
  44745. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44746. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44747. */
  44748. reflectionFalloffDistance: number;
  44749. protected _reflectionAmount: number;
  44750. /**
  44751. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44752. */
  44753. reflectionAmount: number;
  44754. protected _reflectionReflectance0: number;
  44755. /**
  44756. * This specifies the weight of the reflection at grazing angle.
  44757. */
  44758. reflectionReflectance0: number;
  44759. protected _reflectionReflectance90: number;
  44760. /**
  44761. * This specifies the weight of the reflection at a perpendicular point of view.
  44762. */
  44763. reflectionReflectance90: number;
  44764. /**
  44765. * Sets the reflection reflectance fresnel values according to the default standard
  44766. * empirically know to work well :-)
  44767. */
  44768. reflectionStandardFresnelWeight: number;
  44769. protected _useRGBColor: boolean;
  44770. /**
  44771. * Helps to directly use the maps channels instead of their level.
  44772. */
  44773. useRGBColor: boolean;
  44774. protected _enableNoise: boolean;
  44775. /**
  44776. * This helps reducing the banding effect that could occur on the background.
  44777. */
  44778. enableNoise: boolean;
  44779. /**
  44780. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44781. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44782. * Recommended to be keep at 1.0 except for special cases.
  44783. */
  44784. fovMultiplier: number;
  44785. private _fovMultiplier;
  44786. /**
  44787. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44788. */
  44789. useEquirectangularFOV: boolean;
  44790. private _maxSimultaneousLights;
  44791. /**
  44792. * Number of Simultaneous lights allowed on the material.
  44793. */
  44794. maxSimultaneousLights: int;
  44795. /**
  44796. * Default configuration related to image processing available in the Background Material.
  44797. */
  44798. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44799. /**
  44800. * Keep track of the image processing observer to allow dispose and replace.
  44801. */
  44802. private _imageProcessingObserver;
  44803. /**
  44804. * Attaches a new image processing configuration to the PBR Material.
  44805. * @param configuration (if null the scene configuration will be use)
  44806. */
  44807. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44808. /**
  44809. * Gets the image processing configuration used either in this material.
  44810. */
  44811. /**
  44812. * Sets the Default image processing configuration used either in the this material.
  44813. *
  44814. * If sets to null, the scene one is in use.
  44815. */
  44816. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44817. /**
  44818. * Gets wether the color curves effect is enabled.
  44819. */
  44820. /**
  44821. * Sets wether the color curves effect is enabled.
  44822. */
  44823. cameraColorCurvesEnabled: boolean;
  44824. /**
  44825. * Gets wether the color grading effect is enabled.
  44826. */
  44827. /**
  44828. * Gets wether the color grading effect is enabled.
  44829. */
  44830. cameraColorGradingEnabled: boolean;
  44831. /**
  44832. * Gets wether tonemapping is enabled or not.
  44833. */
  44834. /**
  44835. * Sets wether tonemapping is enabled or not
  44836. */
  44837. cameraToneMappingEnabled: boolean;
  44838. /**
  44839. * The camera exposure used on this material.
  44840. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44841. * This corresponds to a photographic exposure.
  44842. */
  44843. /**
  44844. * The camera exposure used on this material.
  44845. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44846. * This corresponds to a photographic exposure.
  44847. */
  44848. cameraExposure: float;
  44849. /**
  44850. * Gets The camera contrast used on this material.
  44851. */
  44852. /**
  44853. * Sets The camera contrast used on this material.
  44854. */
  44855. cameraContrast: float;
  44856. /**
  44857. * Gets the Color Grading 2D Lookup Texture.
  44858. */
  44859. /**
  44860. * Sets the Color Grading 2D Lookup Texture.
  44861. */
  44862. cameraColorGradingTexture: Nullable<BaseTexture>;
  44863. /**
  44864. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44865. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44866. * 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;
  44867. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44868. */
  44869. /**
  44870. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44871. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44872. * 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;
  44873. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44874. */
  44875. cameraColorCurves: Nullable<ColorCurves>;
  44876. /**
  44877. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44878. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44879. */
  44880. switchToBGR: boolean;
  44881. private _renderTargets;
  44882. private _reflectionControls;
  44883. private _white;
  44884. private _primaryShadowColor;
  44885. private _primaryHighlightColor;
  44886. /**
  44887. * Instantiates a Background Material in the given scene
  44888. * @param name The friendly name of the material
  44889. * @param scene The scene to add the material to
  44890. */
  44891. constructor(name: string, scene: Scene);
  44892. /**
  44893. * Gets a boolean indicating that current material needs to register RTT
  44894. */
  44895. readonly hasRenderTargetTextures: boolean;
  44896. /**
  44897. * The entire material has been created in order to prevent overdraw.
  44898. * @returns false
  44899. */
  44900. needAlphaTesting(): boolean;
  44901. /**
  44902. * The entire material has been created in order to prevent overdraw.
  44903. * @returns true if blending is enable
  44904. */
  44905. needAlphaBlending(): boolean;
  44906. /**
  44907. * Checks wether the material is ready to be rendered for a given mesh.
  44908. * @param mesh The mesh to render
  44909. * @param subMesh The submesh to check against
  44910. * @param useInstances Specify wether or not the material is used with instances
  44911. * @returns true if all the dependencies are ready (Textures, Effects...)
  44912. */
  44913. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44914. /**
  44915. * Compute the primary color according to the chosen perceptual color.
  44916. */
  44917. private _computePrimaryColorFromPerceptualColor;
  44918. /**
  44919. * Compute the highlights and shadow colors according to their chosen levels.
  44920. */
  44921. private _computePrimaryColors;
  44922. /**
  44923. * Build the uniform buffer used in the material.
  44924. */
  44925. buildUniformLayout(): void;
  44926. /**
  44927. * Unbind the material.
  44928. */
  44929. unbind(): void;
  44930. /**
  44931. * Bind only the world matrix to the material.
  44932. * @param world The world matrix to bind.
  44933. */
  44934. bindOnlyWorldMatrix(world: Matrix): void;
  44935. /**
  44936. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44937. * @param world The world matrix to bind.
  44938. * @param subMesh The submesh to bind for.
  44939. */
  44940. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44941. /**
  44942. * Dispose the material.
  44943. * @param forceDisposeEffect Force disposal of the associated effect.
  44944. * @param forceDisposeTextures Force disposal of the associated textures.
  44945. */
  44946. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44947. /**
  44948. * Clones the material.
  44949. * @param name The cloned name.
  44950. * @returns The cloned material.
  44951. */
  44952. clone(name: string): BackgroundMaterial;
  44953. /**
  44954. * Serializes the current material to its JSON representation.
  44955. * @returns The JSON representation.
  44956. */
  44957. serialize(): any;
  44958. /**
  44959. * Gets the class name of the material
  44960. * @returns "BackgroundMaterial"
  44961. */
  44962. getClassName(): string;
  44963. /**
  44964. * Parse a JSON input to create back a background material.
  44965. * @param source The JSON data to parse
  44966. * @param scene The scene to create the parsed material in
  44967. * @param rootUrl The root url of the assets the material depends upon
  44968. * @returns the instantiated BackgroundMaterial.
  44969. */
  44970. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44971. }
  44972. }
  44973. declare module BABYLON {
  44974. /**
  44975. * Represents the different options available during the creation of
  44976. * a Environment helper.
  44977. *
  44978. * This can control the default ground, skybox and image processing setup of your scene.
  44979. */
  44980. export interface IEnvironmentHelperOptions {
  44981. /**
  44982. * Specifies wether or not to create a ground.
  44983. * True by default.
  44984. */
  44985. createGround: boolean;
  44986. /**
  44987. * Specifies the ground size.
  44988. * 15 by default.
  44989. */
  44990. groundSize: number;
  44991. /**
  44992. * The texture used on the ground for the main color.
  44993. * Comes from the BabylonJS CDN by default.
  44994. *
  44995. * Remarks: Can be either a texture or a url.
  44996. */
  44997. groundTexture: string | BaseTexture;
  44998. /**
  44999. * The color mixed in the ground texture by default.
  45000. * BabylonJS clearColor by default.
  45001. */
  45002. groundColor: Color3;
  45003. /**
  45004. * Specifies the ground opacity.
  45005. * 1 by default.
  45006. */
  45007. groundOpacity: number;
  45008. /**
  45009. * Enables the ground to receive shadows.
  45010. * True by default.
  45011. */
  45012. enableGroundShadow: boolean;
  45013. /**
  45014. * Helps preventing the shadow to be fully black on the ground.
  45015. * 0.5 by default.
  45016. */
  45017. groundShadowLevel: number;
  45018. /**
  45019. * Creates a mirror texture attach to the ground.
  45020. * false by default.
  45021. */
  45022. enableGroundMirror: boolean;
  45023. /**
  45024. * Specifies the ground mirror size ratio.
  45025. * 0.3 by default as the default kernel is 64.
  45026. */
  45027. groundMirrorSizeRatio: number;
  45028. /**
  45029. * Specifies the ground mirror blur kernel size.
  45030. * 64 by default.
  45031. */
  45032. groundMirrorBlurKernel: number;
  45033. /**
  45034. * Specifies the ground mirror visibility amount.
  45035. * 1 by default
  45036. */
  45037. groundMirrorAmount: number;
  45038. /**
  45039. * Specifies the ground mirror reflectance weight.
  45040. * This uses the standard weight of the background material to setup the fresnel effect
  45041. * of the mirror.
  45042. * 1 by default.
  45043. */
  45044. groundMirrorFresnelWeight: number;
  45045. /**
  45046. * Specifies the ground mirror Falloff distance.
  45047. * This can helps reducing the size of the reflection.
  45048. * 0 by Default.
  45049. */
  45050. groundMirrorFallOffDistance: number;
  45051. /**
  45052. * Specifies the ground mirror texture type.
  45053. * Unsigned Int by Default.
  45054. */
  45055. groundMirrorTextureType: number;
  45056. /**
  45057. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45058. * the shown objects.
  45059. */
  45060. groundYBias: number;
  45061. /**
  45062. * Specifies wether or not to create a skybox.
  45063. * True by default.
  45064. */
  45065. createSkybox: boolean;
  45066. /**
  45067. * Specifies the skybox size.
  45068. * 20 by default.
  45069. */
  45070. skyboxSize: number;
  45071. /**
  45072. * The texture used on the skybox for the main color.
  45073. * Comes from the BabylonJS CDN by default.
  45074. *
  45075. * Remarks: Can be either a texture or a url.
  45076. */
  45077. skyboxTexture: string | BaseTexture;
  45078. /**
  45079. * The color mixed in the skybox texture by default.
  45080. * BabylonJS clearColor by default.
  45081. */
  45082. skyboxColor: Color3;
  45083. /**
  45084. * The background rotation around the Y axis of the scene.
  45085. * This helps aligning the key lights of your scene with the background.
  45086. * 0 by default.
  45087. */
  45088. backgroundYRotation: number;
  45089. /**
  45090. * Compute automatically the size of the elements to best fit with the scene.
  45091. */
  45092. sizeAuto: boolean;
  45093. /**
  45094. * Default position of the rootMesh if autoSize is not true.
  45095. */
  45096. rootPosition: Vector3;
  45097. /**
  45098. * Sets up the image processing in the scene.
  45099. * true by default.
  45100. */
  45101. setupImageProcessing: boolean;
  45102. /**
  45103. * The texture used as your environment texture in the scene.
  45104. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45105. *
  45106. * Remarks: Can be either a texture or a url.
  45107. */
  45108. environmentTexture: string | BaseTexture;
  45109. /**
  45110. * The value of the exposure to apply to the scene.
  45111. * 0.6 by default if setupImageProcessing is true.
  45112. */
  45113. cameraExposure: number;
  45114. /**
  45115. * The value of the contrast to apply to the scene.
  45116. * 1.6 by default if setupImageProcessing is true.
  45117. */
  45118. cameraContrast: number;
  45119. /**
  45120. * Specifies wether or not tonemapping should be enabled in the scene.
  45121. * true by default if setupImageProcessing is true.
  45122. */
  45123. toneMappingEnabled: boolean;
  45124. }
  45125. /**
  45126. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45127. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45128. * It also helps with the default setup of your imageProcessing configuration.
  45129. */
  45130. export class EnvironmentHelper {
  45131. /**
  45132. * Default ground texture URL.
  45133. */
  45134. private static _groundTextureCDNUrl;
  45135. /**
  45136. * Default skybox texture URL.
  45137. */
  45138. private static _skyboxTextureCDNUrl;
  45139. /**
  45140. * Default environment texture URL.
  45141. */
  45142. private static _environmentTextureCDNUrl;
  45143. /**
  45144. * Creates the default options for the helper.
  45145. */
  45146. private static _getDefaultOptions;
  45147. private _rootMesh;
  45148. /**
  45149. * Gets the root mesh created by the helper.
  45150. */
  45151. readonly rootMesh: Mesh;
  45152. private _skybox;
  45153. /**
  45154. * Gets the skybox created by the helper.
  45155. */
  45156. readonly skybox: Nullable<Mesh>;
  45157. private _skyboxTexture;
  45158. /**
  45159. * Gets the skybox texture created by the helper.
  45160. */
  45161. readonly skyboxTexture: Nullable<BaseTexture>;
  45162. private _skyboxMaterial;
  45163. /**
  45164. * Gets the skybox material created by the helper.
  45165. */
  45166. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45167. private _ground;
  45168. /**
  45169. * Gets the ground mesh created by the helper.
  45170. */
  45171. readonly ground: Nullable<Mesh>;
  45172. private _groundTexture;
  45173. /**
  45174. * Gets the ground texture created by the helper.
  45175. */
  45176. readonly groundTexture: Nullable<BaseTexture>;
  45177. private _groundMirror;
  45178. /**
  45179. * Gets the ground mirror created by the helper.
  45180. */
  45181. readonly groundMirror: Nullable<MirrorTexture>;
  45182. /**
  45183. * Gets the ground mirror render list to helps pushing the meshes
  45184. * you wish in the ground reflection.
  45185. */
  45186. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45187. private _groundMaterial;
  45188. /**
  45189. * Gets the ground material created by the helper.
  45190. */
  45191. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45192. /**
  45193. * Stores the creation options.
  45194. */
  45195. private readonly _scene;
  45196. private _options;
  45197. /**
  45198. * This observable will be notified with any error during the creation of the environment,
  45199. * mainly texture creation errors.
  45200. */
  45201. onErrorObservable: Observable<{
  45202. message?: string;
  45203. exception?: any;
  45204. }>;
  45205. /**
  45206. * constructor
  45207. * @param options Defines the options we want to customize the helper
  45208. * @param scene The scene to add the material to
  45209. */
  45210. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45211. /**
  45212. * Updates the background according to the new options
  45213. * @param options
  45214. */
  45215. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45216. /**
  45217. * Sets the primary color of all the available elements.
  45218. * @param color the main color to affect to the ground and the background
  45219. */
  45220. setMainColor(color: Color3): void;
  45221. /**
  45222. * Setup the image processing according to the specified options.
  45223. */
  45224. private _setupImageProcessing;
  45225. /**
  45226. * Setup the environment texture according to the specified options.
  45227. */
  45228. private _setupEnvironmentTexture;
  45229. /**
  45230. * Setup the background according to the specified options.
  45231. */
  45232. private _setupBackground;
  45233. /**
  45234. * Get the scene sizes according to the setup.
  45235. */
  45236. private _getSceneSize;
  45237. /**
  45238. * Setup the ground according to the specified options.
  45239. */
  45240. private _setupGround;
  45241. /**
  45242. * Setup the ground material according to the specified options.
  45243. */
  45244. private _setupGroundMaterial;
  45245. /**
  45246. * Setup the ground diffuse texture according to the specified options.
  45247. */
  45248. private _setupGroundDiffuseTexture;
  45249. /**
  45250. * Setup the ground mirror texture according to the specified options.
  45251. */
  45252. private _setupGroundMirrorTexture;
  45253. /**
  45254. * Setup the ground to receive the mirror texture.
  45255. */
  45256. private _setupMirrorInGroundMaterial;
  45257. /**
  45258. * Setup the skybox according to the specified options.
  45259. */
  45260. private _setupSkybox;
  45261. /**
  45262. * Setup the skybox material according to the specified options.
  45263. */
  45264. private _setupSkyboxMaterial;
  45265. /**
  45266. * Setup the skybox reflection texture according to the specified options.
  45267. */
  45268. private _setupSkyboxReflectionTexture;
  45269. private _errorHandler;
  45270. /**
  45271. * Dispose all the elements created by the Helper.
  45272. */
  45273. dispose(): void;
  45274. }
  45275. }
  45276. declare module BABYLON {
  45277. /**
  45278. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45279. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45280. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45281. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45282. */
  45283. export class PhotoDome extends TransformNode {
  45284. /**
  45285. * Define the image as a Monoscopic panoramic 360 image.
  45286. */
  45287. static readonly MODE_MONOSCOPIC: number;
  45288. /**
  45289. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45290. */
  45291. static readonly MODE_TOPBOTTOM: number;
  45292. /**
  45293. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45294. */
  45295. static readonly MODE_SIDEBYSIDE: number;
  45296. private _useDirectMapping;
  45297. /**
  45298. * The texture being displayed on the sphere
  45299. */
  45300. protected _photoTexture: Texture;
  45301. /**
  45302. * Gets or sets the texture being displayed on the sphere
  45303. */
  45304. photoTexture: Texture;
  45305. /**
  45306. * Observable raised when an error occured while loading the 360 image
  45307. */
  45308. onLoadErrorObservable: Observable<string>;
  45309. /**
  45310. * The skybox material
  45311. */
  45312. protected _material: BackgroundMaterial;
  45313. /**
  45314. * The surface used for the skybox
  45315. */
  45316. protected _mesh: Mesh;
  45317. /**
  45318. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45319. * Also see the options.resolution property.
  45320. */
  45321. fovMultiplier: number;
  45322. private _imageMode;
  45323. /**
  45324. * Gets or set the current video mode for the video. It can be:
  45325. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  45326. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45327. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45328. */
  45329. imageMode: number;
  45330. /**
  45331. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45332. * @param name Element's name, child elements will append suffixes for their own names.
  45333. * @param urlsOfPhoto defines the url of the photo to display
  45334. * @param options defines an object containing optional or exposed sub element properties
  45335. * @param onError defines a callback called when an error occured while loading the texture
  45336. */
  45337. constructor(name: string, urlOfPhoto: string, options: {
  45338. resolution?: number;
  45339. size?: number;
  45340. useDirectMapping?: boolean;
  45341. faceForward?: boolean;
  45342. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45343. private _onBeforeCameraRenderObserver;
  45344. private _changeImageMode;
  45345. /**
  45346. * Releases resources associated with this node.
  45347. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45348. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45349. */
  45350. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45351. }
  45352. }
  45353. declare module BABYLON {
  45354. /** @hidden */
  45355. export var rgbdDecodePixelShader: {
  45356. name: string;
  45357. shader: string;
  45358. };
  45359. }
  45360. declare module BABYLON {
  45361. /**
  45362. * Class used to host texture specific utilities
  45363. */
  45364. export class BRDFTextureTools {
  45365. /**
  45366. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45367. * @param texture the texture to expand.
  45368. */
  45369. private static _ExpandDefaultBRDFTexture;
  45370. /**
  45371. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45372. * @param scene defines the hosting scene
  45373. * @returns the environment BRDF texture
  45374. */
  45375. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45376. private static _environmentBRDFBase64Texture;
  45377. }
  45378. }
  45379. declare module BABYLON {
  45380. /**
  45381. * @hidden
  45382. */
  45383. export interface IMaterialClearCoatDefines {
  45384. CLEARCOAT: boolean;
  45385. CLEARCOAT_DEFAULTIOR: boolean;
  45386. CLEARCOAT_TEXTURE: boolean;
  45387. CLEARCOAT_TEXTUREDIRECTUV: number;
  45388. CLEARCOAT_BUMP: boolean;
  45389. CLEARCOAT_BUMPDIRECTUV: number;
  45390. CLEARCOAT_TINT: boolean;
  45391. CLEARCOAT_TINT_TEXTURE: boolean;
  45392. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45393. /** @hidden */
  45394. _areTexturesDirty: boolean;
  45395. }
  45396. /**
  45397. * Define the code related to the clear coat parameters of the pbr material.
  45398. */
  45399. export class PBRClearCoatConfiguration {
  45400. /**
  45401. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45402. * The default fits with a polyurethane material.
  45403. */
  45404. private static readonly _DefaultIndexOfRefraction;
  45405. private _isEnabled;
  45406. /**
  45407. * Defines if the clear coat is enabled in the material.
  45408. */
  45409. isEnabled: boolean;
  45410. /**
  45411. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45412. */
  45413. intensity: number;
  45414. /**
  45415. * Defines the clear coat layer roughness.
  45416. */
  45417. roughness: number;
  45418. private _indexOfRefraction;
  45419. /**
  45420. * Defines the index of refraction of the clear coat.
  45421. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45422. * The default fits with a polyurethane material.
  45423. * Changing the default value is more performance intensive.
  45424. */
  45425. indexOfRefraction: number;
  45426. private _texture;
  45427. /**
  45428. * Stores the clear coat values in a texture.
  45429. */
  45430. texture: Nullable<BaseTexture>;
  45431. private _bumpTexture;
  45432. /**
  45433. * Define the clear coat specific bump texture.
  45434. */
  45435. bumpTexture: Nullable<BaseTexture>;
  45436. private _isTintEnabled;
  45437. /**
  45438. * Defines if the clear coat tint is enabled in the material.
  45439. */
  45440. isTintEnabled: boolean;
  45441. /**
  45442. * Defines the clear coat tint of the material.
  45443. * This is only use if tint is enabled
  45444. */
  45445. tintColor: Color3;
  45446. /**
  45447. * Defines the distance at which the tint color should be found in the
  45448. * clear coat media.
  45449. * This is only use if tint is enabled
  45450. */
  45451. tintColorAtDistance: number;
  45452. /**
  45453. * Defines the clear coat layer thickness.
  45454. * This is only use if tint is enabled
  45455. */
  45456. tintThickness: number;
  45457. private _tintTexture;
  45458. /**
  45459. * Stores the clear tint values in a texture.
  45460. * rgb is tint
  45461. * a is a thickness factor
  45462. */
  45463. tintTexture: Nullable<BaseTexture>;
  45464. /** @hidden */
  45465. private _internalMarkAllSubMeshesAsTexturesDirty;
  45466. /** @hidden */
  45467. _markAllSubMeshesAsTexturesDirty(): void;
  45468. /**
  45469. * Instantiate a new istance of clear coat configuration.
  45470. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45471. */
  45472. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45473. /**
  45474. * Gets wehter the submesh is ready to be used or not.
  45475. * @param defines the list of "defines" to update.
  45476. * @param scene defines the scene the material belongs to.
  45477. * @param engine defines the engine the material belongs to.
  45478. * @param disableBumpMap defines wether the material disables bump or not.
  45479. * @returns - boolean indicating that the submesh is ready or not.
  45480. */
  45481. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45482. /**
  45483. * Checks to see if a texture is used in the material.
  45484. * @param defines the list of "defines" to update.
  45485. * @param scene defines the scene to the material belongs to.
  45486. */
  45487. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45488. /**
  45489. * Binds the material data.
  45490. * @param uniformBuffer defines the Uniform buffer to fill in.
  45491. * @param scene defines the scene the material belongs to.
  45492. * @param engine defines the engine the material belongs to.
  45493. * @param disableBumpMap defines wether the material disables bump or not.
  45494. * @param isFrozen defines wether the material is frozen or not.
  45495. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45496. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45497. */
  45498. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45499. /**
  45500. * Checks to see if a texture is used in the material.
  45501. * @param texture - Base texture to use.
  45502. * @returns - Boolean specifying if a texture is used in the material.
  45503. */
  45504. hasTexture(texture: BaseTexture): boolean;
  45505. /**
  45506. * Returns an array of the actively used textures.
  45507. * @param activeTextures Array of BaseTextures
  45508. */
  45509. getActiveTextures(activeTextures: BaseTexture[]): void;
  45510. /**
  45511. * Returns the animatable textures.
  45512. * @param animatables Array of animatable textures.
  45513. */
  45514. getAnimatables(animatables: IAnimatable[]): void;
  45515. /**
  45516. * Disposes the resources of the material.
  45517. * @param forceDisposeTextures - Forces the disposal of all textures.
  45518. */
  45519. dispose(forceDisposeTextures?: boolean): void;
  45520. /**
  45521. * Get the current class name of the texture useful for serialization or dynamic coding.
  45522. * @returns "PBRClearCoatConfiguration"
  45523. */
  45524. getClassName(): string;
  45525. /**
  45526. * Add fallbacks to the effect fallbacks list.
  45527. * @param defines defines the Base texture to use.
  45528. * @param fallbacks defines the current fallback list.
  45529. * @param currentRank defines the current fallback rank.
  45530. * @returns the new fallback rank.
  45531. */
  45532. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45533. /**
  45534. * Add the required uniforms to the current list.
  45535. * @param uniforms defines the current uniform list.
  45536. */
  45537. static AddUniforms(uniforms: string[]): void;
  45538. /**
  45539. * Add the required samplers to the current list.
  45540. * @param samplers defines the current sampler list.
  45541. */
  45542. static AddSamplers(samplers: string[]): void;
  45543. /**
  45544. * Add the required uniforms to the current buffer.
  45545. * @param uniformBuffer defines the current uniform buffer.
  45546. */
  45547. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45548. /**
  45549. * Makes a duplicate of the current configuration into another one.
  45550. * @param clearCoatConfiguration define the config where to copy the info
  45551. */
  45552. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45553. /**
  45554. * Serializes this clear coat configuration.
  45555. * @returns - An object with the serialized config.
  45556. */
  45557. serialize(): any;
  45558. /**
  45559. * Parses a anisotropy Configuration from a serialized object.
  45560. * @param source - Serialized object.
  45561. * @param scene Defines the scene we are parsing for
  45562. * @param rootUrl Defines the rootUrl to load from
  45563. */
  45564. parse(source: any, scene: Scene, rootUrl: string): void;
  45565. }
  45566. }
  45567. declare module BABYLON {
  45568. /**
  45569. * @hidden
  45570. */
  45571. export interface IMaterialAnisotropicDefines {
  45572. ANISOTROPIC: boolean;
  45573. ANISOTROPIC_TEXTURE: boolean;
  45574. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45575. MAINUV1: boolean;
  45576. _areTexturesDirty: boolean;
  45577. _needUVs: boolean;
  45578. }
  45579. /**
  45580. * Define the code related to the anisotropic parameters of the pbr material.
  45581. */
  45582. export class PBRAnisotropicConfiguration {
  45583. private _isEnabled;
  45584. /**
  45585. * Defines if the anisotropy is enabled in the material.
  45586. */
  45587. isEnabled: boolean;
  45588. /**
  45589. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45590. */
  45591. intensity: number;
  45592. /**
  45593. * Defines if the effect is along the tangents, bitangents or in between.
  45594. * By default, the effect is "strectching" the highlights along the tangents.
  45595. */
  45596. direction: Vector2;
  45597. private _texture;
  45598. /**
  45599. * Stores the anisotropy values in a texture.
  45600. * rg is direction (like normal from -1 to 1)
  45601. * b is a intensity
  45602. */
  45603. texture: Nullable<BaseTexture>;
  45604. /** @hidden */
  45605. private _internalMarkAllSubMeshesAsTexturesDirty;
  45606. /** @hidden */
  45607. _markAllSubMeshesAsTexturesDirty(): void;
  45608. /**
  45609. * Instantiate a new istance of anisotropy configuration.
  45610. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45611. */
  45612. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45613. /**
  45614. * Specifies that the submesh is ready to be used.
  45615. * @param defines the list of "defines" to update.
  45616. * @param scene defines the scene the material belongs to.
  45617. * @returns - boolean indicating that the submesh is ready or not.
  45618. */
  45619. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45620. /**
  45621. * Checks to see if a texture is used in the material.
  45622. * @param defines the list of "defines" to update.
  45623. * @param mesh the mesh we are preparing the defines for.
  45624. * @param scene defines the scene the material belongs to.
  45625. */
  45626. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45627. /**
  45628. * Binds the material data.
  45629. * @param uniformBuffer defines the Uniform buffer to fill in.
  45630. * @param scene defines the scene the material belongs to.
  45631. * @param isFrozen defines wether the material is frozen or not.
  45632. */
  45633. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45634. /**
  45635. * Checks to see if a texture is used in the material.
  45636. * @param texture - Base texture to use.
  45637. * @returns - Boolean specifying if a texture is used in the material.
  45638. */
  45639. hasTexture(texture: BaseTexture): boolean;
  45640. /**
  45641. * Returns an array of the actively used textures.
  45642. * @param activeTextures Array of BaseTextures
  45643. */
  45644. getActiveTextures(activeTextures: BaseTexture[]): void;
  45645. /**
  45646. * Returns the animatable textures.
  45647. * @param animatables Array of animatable textures.
  45648. */
  45649. getAnimatables(animatables: IAnimatable[]): void;
  45650. /**
  45651. * Disposes the resources of the material.
  45652. * @param forceDisposeTextures - Forces the disposal of all textures.
  45653. */
  45654. dispose(forceDisposeTextures?: boolean): void;
  45655. /**
  45656. * Get the current class name of the texture useful for serialization or dynamic coding.
  45657. * @returns "PBRAnisotropicConfiguration"
  45658. */
  45659. getClassName(): string;
  45660. /**
  45661. * Add fallbacks to the effect fallbacks list.
  45662. * @param defines defines the Base texture to use.
  45663. * @param fallbacks defines the current fallback list.
  45664. * @param currentRank defines the current fallback rank.
  45665. * @returns the new fallback rank.
  45666. */
  45667. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45668. /**
  45669. * Add the required uniforms to the current list.
  45670. * @param uniforms defines the current uniform list.
  45671. */
  45672. static AddUniforms(uniforms: string[]): void;
  45673. /**
  45674. * Add the required uniforms to the current buffer.
  45675. * @param uniformBuffer defines the current uniform buffer.
  45676. */
  45677. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45678. /**
  45679. * Add the required samplers to the current list.
  45680. * @param samplers defines the current sampler list.
  45681. */
  45682. static AddSamplers(samplers: string[]): void;
  45683. /**
  45684. * Makes a duplicate of the current configuration into another one.
  45685. * @param anisotropicConfiguration define the config where to copy the info
  45686. */
  45687. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45688. /**
  45689. * Serializes this anisotropy configuration.
  45690. * @returns - An object with the serialized config.
  45691. */
  45692. serialize(): any;
  45693. /**
  45694. * Parses a anisotropy Configuration from a serialized object.
  45695. * @param source - Serialized object.
  45696. * @param scene Defines the scene we are parsing for
  45697. * @param rootUrl Defines the rootUrl to load from
  45698. */
  45699. parse(source: any, scene: Scene, rootUrl: string): void;
  45700. }
  45701. }
  45702. declare module BABYLON {
  45703. /**
  45704. * @hidden
  45705. */
  45706. export interface IMaterialBRDFDefines {
  45707. BRDF_V_HEIGHT_CORRELATED: boolean;
  45708. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45709. SPHERICAL_HARMONICS: boolean;
  45710. /** @hidden */
  45711. _areMiscDirty: boolean;
  45712. }
  45713. /**
  45714. * Define the code related to the BRDF parameters of the pbr material.
  45715. */
  45716. export class PBRBRDFConfiguration {
  45717. /**
  45718. * Default value used for the energy conservation.
  45719. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45720. */
  45721. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  45722. /**
  45723. * Default value used for the Smith Visibility Height Correlated mode.
  45724. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45725. */
  45726. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45727. /**
  45728. * Default value used for the IBL diffuse part.
  45729. * This can help switching back to the polynomials mode globally which is a tiny bit
  45730. * less GPU intensive at the drawback of a lower quality.
  45731. */
  45732. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  45733. private _useEnergyConservation;
  45734. /**
  45735. * Defines if the material uses energy conservation.
  45736. */
  45737. useEnergyConservation: boolean;
  45738. private _useSmithVisibilityHeightCorrelated;
  45739. /**
  45740. * LEGACY Mode set to false
  45741. * Defines if the material uses height smith correlated visibility term.
  45742. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45743. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45744. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45745. * Not relying on height correlated will also disable energy conservation.
  45746. */
  45747. useSmithVisibilityHeightCorrelated: boolean;
  45748. private _useSphericalHarmonics;
  45749. /**
  45750. * LEGACY Mode set to false
  45751. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  45752. * diffuse part of the IBL.
  45753. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  45754. * to the ground truth.
  45755. */
  45756. useSphericalHarmonics: boolean;
  45757. /** @hidden */
  45758. private _internalMarkAllSubMeshesAsMiscDirty;
  45759. /** @hidden */
  45760. _markAllSubMeshesAsMiscDirty(): void;
  45761. /**
  45762. * Instantiate a new istance of clear coat configuration.
  45763. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45764. */
  45765. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45766. /**
  45767. * Checks to see if a texture is used in the material.
  45768. * @param defines the list of "defines" to update.
  45769. */
  45770. prepareDefines(defines: IMaterialBRDFDefines): void;
  45771. /**
  45772. * Get the current class name of the texture useful for serialization or dynamic coding.
  45773. * @returns "PBRClearCoatConfiguration"
  45774. */
  45775. getClassName(): string;
  45776. /**
  45777. * Makes a duplicate of the current configuration into another one.
  45778. * @param brdfConfiguration define the config where to copy the info
  45779. */
  45780. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45781. /**
  45782. * Serializes this BRDF configuration.
  45783. * @returns - An object with the serialized config.
  45784. */
  45785. serialize(): any;
  45786. /**
  45787. * Parses a anisotropy Configuration from a serialized object.
  45788. * @param source - Serialized object.
  45789. * @param scene Defines the scene we are parsing for
  45790. * @param rootUrl Defines the rootUrl to load from
  45791. */
  45792. parse(source: any, scene: Scene, rootUrl: string): void;
  45793. }
  45794. }
  45795. declare module BABYLON {
  45796. /**
  45797. * @hidden
  45798. */
  45799. export interface IMaterialSheenDefines {
  45800. SHEEN: boolean;
  45801. SHEEN_TEXTURE: boolean;
  45802. SHEEN_TEXTUREDIRECTUV: number;
  45803. SHEEN_LINKWITHALBEDO: boolean;
  45804. /** @hidden */
  45805. _areTexturesDirty: boolean;
  45806. }
  45807. /**
  45808. * Define the code related to the Sheen parameters of the pbr material.
  45809. */
  45810. export class PBRSheenConfiguration {
  45811. private _isEnabled;
  45812. /**
  45813. * Defines if the material uses sheen.
  45814. */
  45815. isEnabled: boolean;
  45816. private _linkSheenWithAlbedo;
  45817. /**
  45818. * Defines if the sheen is linked to the sheen color.
  45819. */
  45820. linkSheenWithAlbedo: boolean;
  45821. /**
  45822. * Defines the sheen intensity.
  45823. */
  45824. intensity: number;
  45825. /**
  45826. * Defines the sheen color.
  45827. */
  45828. color: Color3;
  45829. private _texture;
  45830. /**
  45831. * Stores the sheen tint values in a texture.
  45832. * rgb is tint
  45833. * a is a intensity
  45834. */
  45835. texture: Nullable<BaseTexture>;
  45836. /** @hidden */
  45837. private _internalMarkAllSubMeshesAsTexturesDirty;
  45838. /** @hidden */
  45839. _markAllSubMeshesAsTexturesDirty(): void;
  45840. /**
  45841. * Instantiate a new istance of clear coat configuration.
  45842. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45843. */
  45844. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45845. /**
  45846. * Specifies that the submesh is ready to be used.
  45847. * @param defines the list of "defines" to update.
  45848. * @param scene defines the scene the material belongs to.
  45849. * @returns - boolean indicating that the submesh is ready or not.
  45850. */
  45851. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45852. /**
  45853. * Checks to see if a texture is used in the material.
  45854. * @param defines the list of "defines" to update.
  45855. * @param scene defines the scene the material belongs to.
  45856. */
  45857. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45858. /**
  45859. * Binds the material data.
  45860. * @param uniformBuffer defines the Uniform buffer to fill in.
  45861. * @param scene defines the scene the material belongs to.
  45862. * @param isFrozen defines wether the material is frozen or not.
  45863. */
  45864. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45865. /**
  45866. * Checks to see if a texture is used in the material.
  45867. * @param texture - Base texture to use.
  45868. * @returns - Boolean specifying if a texture is used in the material.
  45869. */
  45870. hasTexture(texture: BaseTexture): boolean;
  45871. /**
  45872. * Returns an array of the actively used textures.
  45873. * @param activeTextures Array of BaseTextures
  45874. */
  45875. getActiveTextures(activeTextures: BaseTexture[]): void;
  45876. /**
  45877. * Returns the animatable textures.
  45878. * @param animatables Array of animatable textures.
  45879. */
  45880. getAnimatables(animatables: IAnimatable[]): void;
  45881. /**
  45882. * Disposes the resources of the material.
  45883. * @param forceDisposeTextures - Forces the disposal of all textures.
  45884. */
  45885. dispose(forceDisposeTextures?: boolean): void;
  45886. /**
  45887. * Get the current class name of the texture useful for serialization or dynamic coding.
  45888. * @returns "PBRSheenConfiguration"
  45889. */
  45890. getClassName(): string;
  45891. /**
  45892. * Add fallbacks to the effect fallbacks list.
  45893. * @param defines defines the Base texture to use.
  45894. * @param fallbacks defines the current fallback list.
  45895. * @param currentRank defines the current fallback rank.
  45896. * @returns the new fallback rank.
  45897. */
  45898. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45899. /**
  45900. * Add the required uniforms to the current list.
  45901. * @param uniforms defines the current uniform list.
  45902. */
  45903. static AddUniforms(uniforms: string[]): void;
  45904. /**
  45905. * Add the required uniforms to the current buffer.
  45906. * @param uniformBuffer defines the current uniform buffer.
  45907. */
  45908. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45909. /**
  45910. * Add the required samplers to the current list.
  45911. * @param samplers defines the current sampler list.
  45912. */
  45913. static AddSamplers(samplers: string[]): void;
  45914. /**
  45915. * Makes a duplicate of the current configuration into another one.
  45916. * @param sheenConfiguration define the config where to copy the info
  45917. */
  45918. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45919. /**
  45920. * Serializes this BRDF configuration.
  45921. * @returns - An object with the serialized config.
  45922. */
  45923. serialize(): any;
  45924. /**
  45925. * Parses a anisotropy Configuration from a serialized object.
  45926. * @param source - Serialized object.
  45927. * @param scene Defines the scene we are parsing for
  45928. * @param rootUrl Defines the rootUrl to load from
  45929. */
  45930. parse(source: any, scene: Scene, rootUrl: string): void;
  45931. }
  45932. }
  45933. declare module BABYLON {
  45934. /**
  45935. * @hidden
  45936. */
  45937. export interface IMaterialSubSurfaceDefines {
  45938. SUBSURFACE: boolean;
  45939. SS_REFRACTION: boolean;
  45940. SS_TRANSLUCENCY: boolean;
  45941. SS_SCATERRING: boolean;
  45942. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45943. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45944. SS_REFRACTIONMAP_3D: boolean;
  45945. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45946. SS_LODINREFRACTIONALPHA: boolean;
  45947. SS_GAMMAREFRACTION: boolean;
  45948. SS_RGBDREFRACTION: boolean;
  45949. SS_LINEARSPECULARREFRACTION: boolean;
  45950. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45951. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45952. /** @hidden */
  45953. _areTexturesDirty: boolean;
  45954. }
  45955. /**
  45956. * Define the code related to the sub surface parameters of the pbr material.
  45957. */
  45958. export class PBRSubSurfaceConfiguration {
  45959. private _isRefractionEnabled;
  45960. /**
  45961. * Defines if the refraction is enabled in the material.
  45962. */
  45963. isRefractionEnabled: boolean;
  45964. private _isTranslucencyEnabled;
  45965. /**
  45966. * Defines if the translucency is enabled in the material.
  45967. */
  45968. isTranslucencyEnabled: boolean;
  45969. private _isScatteringEnabled;
  45970. /**
  45971. * Defines the refraction intensity of the material.
  45972. * The refraction when enabled replaces the Diffuse part of the material.
  45973. * The intensity helps transitionning between diffuse and refraction.
  45974. */
  45975. refractionIntensity: number;
  45976. /**
  45977. * Defines the translucency intensity of the material.
  45978. * When translucency has been enabled, this defines how much of the "translucency"
  45979. * is addded to the diffuse part of the material.
  45980. */
  45981. translucencyIntensity: number;
  45982. /**
  45983. * Defines the scattering intensity of the material.
  45984. * When scattering has been enabled, this defines how much of the "scattered light"
  45985. * is addded to the diffuse part of the material.
  45986. */
  45987. scatteringIntensity: number;
  45988. private _thicknessTexture;
  45989. /**
  45990. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  45991. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  45992. * 0 would mean minimumThickness
  45993. * 1 would mean maximumThickness
  45994. * The other channels might be use as a mask to vary the different effects intensity.
  45995. */
  45996. thicknessTexture: Nullable<BaseTexture>;
  45997. private _refractionTexture;
  45998. /**
  45999. * Defines the texture to use for refraction.
  46000. */
  46001. refractionTexture: Nullable<BaseTexture>;
  46002. private _indexOfRefraction;
  46003. /**
  46004. * Defines the index of refraction used in the material.
  46005. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46006. */
  46007. indexOfRefraction: number;
  46008. private _invertRefractionY;
  46009. /**
  46010. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46011. */
  46012. invertRefractionY: boolean;
  46013. private _linkRefractionWithTransparency;
  46014. /**
  46015. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46016. * Materials half opaque for instance using refraction could benefit from this control.
  46017. */
  46018. linkRefractionWithTransparency: boolean;
  46019. /**
  46020. * Defines the minimum thickness stored in the thickness map.
  46021. * If no thickness map is defined, this value will be used to simulate thickness.
  46022. */
  46023. minimumThickness: number;
  46024. /**
  46025. * Defines the maximum thickness stored in the thickness map.
  46026. */
  46027. maximumThickness: number;
  46028. /**
  46029. * Defines the volume tint of the material.
  46030. * This is used for both translucency and scattering.
  46031. */
  46032. tintColor: Color3;
  46033. /**
  46034. * Defines the distance at which the tint color should be found in the media.
  46035. * This is used for refraction only.
  46036. */
  46037. tintColorAtDistance: number;
  46038. /**
  46039. * Defines how far each channel transmit through the media.
  46040. * It is defined as a color to simplify it selection.
  46041. */
  46042. diffusionDistance: Color3;
  46043. private _useMaskFromThicknessTexture;
  46044. /**
  46045. * Stores the intensity of the different subsurface effects in the thickness texture.
  46046. * * the green channel is the translucency intensity.
  46047. * * the blue channel is the scattering intensity.
  46048. * * the alpha channel is the refraction intensity.
  46049. */
  46050. useMaskFromThicknessTexture: boolean;
  46051. /** @hidden */
  46052. private _internalMarkAllSubMeshesAsTexturesDirty;
  46053. /** @hidden */
  46054. _markAllSubMeshesAsTexturesDirty(): void;
  46055. /**
  46056. * Instantiate a new istance of sub surface configuration.
  46057. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46058. */
  46059. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46060. /**
  46061. * Gets wehter the submesh is ready to be used or not.
  46062. * @param defines the list of "defines" to update.
  46063. * @param scene defines the scene the material belongs to.
  46064. * @returns - boolean indicating that the submesh is ready or not.
  46065. */
  46066. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46067. /**
  46068. * Checks to see if a texture is used in the material.
  46069. * @param defines the list of "defines" to update.
  46070. * @param scene defines the scene to the material belongs to.
  46071. */
  46072. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46073. /**
  46074. * Binds the material data.
  46075. * @param uniformBuffer defines the Uniform buffer to fill in.
  46076. * @param scene defines the scene the material belongs to.
  46077. * @param engine defines the engine the material belongs to.
  46078. * @param isFrozen defines wether the material is frozen or not.
  46079. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46080. */
  46081. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46082. /**
  46083. * Unbinds the material from the mesh.
  46084. * @param activeEffect defines the effect that should be unbound from.
  46085. * @returns true if unbound, otherwise false
  46086. */
  46087. unbind(activeEffect: Effect): boolean;
  46088. /**
  46089. * Returns the texture used for refraction or null if none is used.
  46090. * @param scene defines the scene the material belongs to.
  46091. * @returns - Refraction texture if present. If no refraction texture and refraction
  46092. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46093. */
  46094. private _getRefractionTexture;
  46095. /**
  46096. * Returns true if alpha blending should be disabled.
  46097. */
  46098. readonly disableAlphaBlending: boolean;
  46099. /**
  46100. * Fills the list of render target textures.
  46101. * @param renderTargets the list of render targets to update
  46102. */
  46103. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46104. /**
  46105. * Checks to see if a texture is used in the material.
  46106. * @param texture - Base texture to use.
  46107. * @returns - Boolean specifying if a texture is used in the material.
  46108. */
  46109. hasTexture(texture: BaseTexture): boolean;
  46110. /**
  46111. * Gets a boolean indicating that current material needs to register RTT
  46112. * @returns true if this uses a render target otherwise false.
  46113. */
  46114. hasRenderTargetTextures(): boolean;
  46115. /**
  46116. * Returns an array of the actively used textures.
  46117. * @param activeTextures Array of BaseTextures
  46118. */
  46119. getActiveTextures(activeTextures: BaseTexture[]): void;
  46120. /**
  46121. * Returns the animatable textures.
  46122. * @param animatables Array of animatable textures.
  46123. */
  46124. getAnimatables(animatables: IAnimatable[]): void;
  46125. /**
  46126. * Disposes the resources of the material.
  46127. * @param forceDisposeTextures - Forces the disposal of all textures.
  46128. */
  46129. dispose(forceDisposeTextures?: boolean): void;
  46130. /**
  46131. * Get the current class name of the texture useful for serialization or dynamic coding.
  46132. * @returns "PBRSubSurfaceConfiguration"
  46133. */
  46134. getClassName(): string;
  46135. /**
  46136. * Add fallbacks to the effect fallbacks list.
  46137. * @param defines defines the Base texture to use.
  46138. * @param fallbacks defines the current fallback list.
  46139. * @param currentRank defines the current fallback rank.
  46140. * @returns the new fallback rank.
  46141. */
  46142. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46143. /**
  46144. * Add the required uniforms to the current list.
  46145. * @param uniforms defines the current uniform list.
  46146. */
  46147. static AddUniforms(uniforms: string[]): void;
  46148. /**
  46149. * Add the required samplers to the current list.
  46150. * @param samplers defines the current sampler list.
  46151. */
  46152. static AddSamplers(samplers: string[]): void;
  46153. /**
  46154. * Add the required uniforms to the current buffer.
  46155. * @param uniformBuffer defines the current uniform buffer.
  46156. */
  46157. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46158. /**
  46159. * Makes a duplicate of the current configuration into another one.
  46160. * @param configuration define the config where to copy the info
  46161. */
  46162. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46163. /**
  46164. * Serializes this Sub Surface configuration.
  46165. * @returns - An object with the serialized config.
  46166. */
  46167. serialize(): any;
  46168. /**
  46169. * Parses a anisotropy Configuration from a serialized object.
  46170. * @param source - Serialized object.
  46171. * @param scene Defines the scene we are parsing for
  46172. * @param rootUrl Defines the rootUrl to load from
  46173. */
  46174. parse(source: any, scene: Scene, rootUrl: string): void;
  46175. }
  46176. }
  46177. declare module BABYLON {
  46178. /** @hidden */
  46179. export var pbrFragmentDeclaration: {
  46180. name: string;
  46181. shader: string;
  46182. };
  46183. }
  46184. declare module BABYLON {
  46185. /** @hidden */
  46186. export var pbrUboDeclaration: {
  46187. name: string;
  46188. shader: string;
  46189. };
  46190. }
  46191. declare module BABYLON {
  46192. /** @hidden */
  46193. export var pbrFragmentExtraDeclaration: {
  46194. name: string;
  46195. shader: string;
  46196. };
  46197. }
  46198. declare module BABYLON {
  46199. /** @hidden */
  46200. export var pbrFragmentSamplersDeclaration: {
  46201. name: string;
  46202. shader: string;
  46203. };
  46204. }
  46205. declare module BABYLON {
  46206. /** @hidden */
  46207. export var pbrHelperFunctions: {
  46208. name: string;
  46209. shader: string;
  46210. };
  46211. }
  46212. declare module BABYLON {
  46213. /** @hidden */
  46214. export var harmonicsFunctions: {
  46215. name: string;
  46216. shader: string;
  46217. };
  46218. }
  46219. declare module BABYLON {
  46220. /** @hidden */
  46221. export var pbrDirectLightingSetupFunctions: {
  46222. name: string;
  46223. shader: string;
  46224. };
  46225. }
  46226. declare module BABYLON {
  46227. /** @hidden */
  46228. export var pbrDirectLightingFalloffFunctions: {
  46229. name: string;
  46230. shader: string;
  46231. };
  46232. }
  46233. declare module BABYLON {
  46234. /** @hidden */
  46235. export var pbrBRDFFunctions: {
  46236. name: string;
  46237. shader: string;
  46238. };
  46239. }
  46240. declare module BABYLON {
  46241. /** @hidden */
  46242. export var pbrDirectLightingFunctions: {
  46243. name: string;
  46244. shader: string;
  46245. };
  46246. }
  46247. declare module BABYLON {
  46248. /** @hidden */
  46249. export var pbrIBLFunctions: {
  46250. name: string;
  46251. shader: string;
  46252. };
  46253. }
  46254. declare module BABYLON {
  46255. /** @hidden */
  46256. export var pbrDebug: {
  46257. name: string;
  46258. shader: string;
  46259. };
  46260. }
  46261. declare module BABYLON {
  46262. /** @hidden */
  46263. export var pbrPixelShader: {
  46264. name: string;
  46265. shader: string;
  46266. };
  46267. }
  46268. declare module BABYLON {
  46269. /** @hidden */
  46270. export var pbrVertexDeclaration: {
  46271. name: string;
  46272. shader: string;
  46273. };
  46274. }
  46275. declare module BABYLON {
  46276. /** @hidden */
  46277. export var pbrVertexShader: {
  46278. name: string;
  46279. shader: string;
  46280. };
  46281. }
  46282. declare module BABYLON {
  46283. /**
  46284. * Manages the defines for the PBR Material.
  46285. * @hidden
  46286. */
  46287. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46288. PBR: boolean;
  46289. MAINUV1: boolean;
  46290. MAINUV2: boolean;
  46291. UV1: boolean;
  46292. UV2: boolean;
  46293. ALBEDO: boolean;
  46294. ALBEDODIRECTUV: number;
  46295. VERTEXCOLOR: boolean;
  46296. AMBIENT: boolean;
  46297. AMBIENTDIRECTUV: number;
  46298. AMBIENTINGRAYSCALE: boolean;
  46299. OPACITY: boolean;
  46300. VERTEXALPHA: boolean;
  46301. OPACITYDIRECTUV: number;
  46302. OPACITYRGB: boolean;
  46303. ALPHATEST: boolean;
  46304. DEPTHPREPASS: boolean;
  46305. ALPHABLEND: boolean;
  46306. ALPHAFROMALBEDO: boolean;
  46307. ALPHATESTVALUE: string;
  46308. SPECULAROVERALPHA: boolean;
  46309. RADIANCEOVERALPHA: boolean;
  46310. ALPHAFRESNEL: boolean;
  46311. LINEARALPHAFRESNEL: boolean;
  46312. PREMULTIPLYALPHA: boolean;
  46313. EMISSIVE: boolean;
  46314. EMISSIVEDIRECTUV: number;
  46315. REFLECTIVITY: boolean;
  46316. REFLECTIVITYDIRECTUV: number;
  46317. SPECULARTERM: boolean;
  46318. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46319. MICROSURFACEAUTOMATIC: boolean;
  46320. LODBASEDMICROSFURACE: boolean;
  46321. MICROSURFACEMAP: boolean;
  46322. MICROSURFACEMAPDIRECTUV: number;
  46323. METALLICWORKFLOW: boolean;
  46324. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46325. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46326. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46327. AOSTOREINMETALMAPRED: boolean;
  46328. ENVIRONMENTBRDF: boolean;
  46329. ENVIRONMENTBRDF_RGBD: boolean;
  46330. NORMAL: boolean;
  46331. TANGENT: boolean;
  46332. BUMP: boolean;
  46333. BUMPDIRECTUV: number;
  46334. OBJECTSPACE_NORMALMAP: boolean;
  46335. PARALLAX: boolean;
  46336. PARALLAXOCCLUSION: boolean;
  46337. NORMALXYSCALE: boolean;
  46338. LIGHTMAP: boolean;
  46339. LIGHTMAPDIRECTUV: number;
  46340. USELIGHTMAPASSHADOWMAP: boolean;
  46341. GAMMALIGHTMAP: boolean;
  46342. REFLECTION: boolean;
  46343. REFLECTIONMAP_3D: boolean;
  46344. REFLECTIONMAP_SPHERICAL: boolean;
  46345. REFLECTIONMAP_PLANAR: boolean;
  46346. REFLECTIONMAP_CUBIC: boolean;
  46347. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46348. REFLECTIONMAP_PROJECTION: boolean;
  46349. REFLECTIONMAP_SKYBOX: boolean;
  46350. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46351. REFLECTIONMAP_EXPLICIT: boolean;
  46352. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46353. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46354. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46355. INVERTCUBICMAP: boolean;
  46356. USESPHERICALFROMREFLECTIONMAP: boolean;
  46357. USEIRRADIANCEMAP: boolean;
  46358. SPHERICAL_HARMONICS: boolean;
  46359. USESPHERICALINVERTEX: boolean;
  46360. REFLECTIONMAP_OPPOSITEZ: boolean;
  46361. LODINREFLECTIONALPHA: boolean;
  46362. GAMMAREFLECTION: boolean;
  46363. RGBDREFLECTION: boolean;
  46364. LINEARSPECULARREFLECTION: boolean;
  46365. RADIANCEOCCLUSION: boolean;
  46366. HORIZONOCCLUSION: boolean;
  46367. INSTANCES: boolean;
  46368. NUM_BONE_INFLUENCERS: number;
  46369. BonesPerMesh: number;
  46370. BONETEXTURE: boolean;
  46371. NONUNIFORMSCALING: boolean;
  46372. MORPHTARGETS: boolean;
  46373. MORPHTARGETS_NORMAL: boolean;
  46374. MORPHTARGETS_TANGENT: boolean;
  46375. MORPHTARGETS_UV: boolean;
  46376. NUM_MORPH_INFLUENCERS: number;
  46377. IMAGEPROCESSING: boolean;
  46378. VIGNETTE: boolean;
  46379. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46380. VIGNETTEBLENDMODEOPAQUE: boolean;
  46381. TONEMAPPING: boolean;
  46382. TONEMAPPING_ACES: boolean;
  46383. CONTRAST: boolean;
  46384. COLORCURVES: boolean;
  46385. COLORGRADING: boolean;
  46386. COLORGRADING3D: boolean;
  46387. SAMPLER3DGREENDEPTH: boolean;
  46388. SAMPLER3DBGRMAP: boolean;
  46389. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46390. EXPOSURE: boolean;
  46391. MULTIVIEW: boolean;
  46392. USEPHYSICALLIGHTFALLOFF: boolean;
  46393. USEGLTFLIGHTFALLOFF: boolean;
  46394. TWOSIDEDLIGHTING: boolean;
  46395. SHADOWFLOAT: boolean;
  46396. CLIPPLANE: boolean;
  46397. CLIPPLANE2: boolean;
  46398. CLIPPLANE3: boolean;
  46399. CLIPPLANE4: boolean;
  46400. POINTSIZE: boolean;
  46401. FOG: boolean;
  46402. LOGARITHMICDEPTH: boolean;
  46403. FORCENORMALFORWARD: boolean;
  46404. SPECULARAA: boolean;
  46405. CLEARCOAT: boolean;
  46406. CLEARCOAT_DEFAULTIOR: boolean;
  46407. CLEARCOAT_TEXTURE: boolean;
  46408. CLEARCOAT_TEXTUREDIRECTUV: number;
  46409. CLEARCOAT_BUMP: boolean;
  46410. CLEARCOAT_BUMPDIRECTUV: number;
  46411. CLEARCOAT_TINT: boolean;
  46412. CLEARCOAT_TINT_TEXTURE: boolean;
  46413. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46414. ANISOTROPIC: boolean;
  46415. ANISOTROPIC_TEXTURE: boolean;
  46416. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46417. BRDF_V_HEIGHT_CORRELATED: boolean;
  46418. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46419. SHEEN: boolean;
  46420. SHEEN_TEXTURE: boolean;
  46421. SHEEN_TEXTUREDIRECTUV: number;
  46422. SHEEN_LINKWITHALBEDO: boolean;
  46423. SUBSURFACE: boolean;
  46424. SS_REFRACTION: boolean;
  46425. SS_TRANSLUCENCY: boolean;
  46426. SS_SCATERRING: boolean;
  46427. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46428. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46429. SS_REFRACTIONMAP_3D: boolean;
  46430. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46431. SS_LODINREFRACTIONALPHA: boolean;
  46432. SS_GAMMAREFRACTION: boolean;
  46433. SS_RGBDREFRACTION: boolean;
  46434. SS_LINEARSPECULARREFRACTION: boolean;
  46435. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46436. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46437. UNLIT: boolean;
  46438. DEBUGMODE: number;
  46439. /**
  46440. * Initializes the PBR Material defines.
  46441. */
  46442. constructor();
  46443. /**
  46444. * Resets the PBR Material defines.
  46445. */
  46446. reset(): void;
  46447. }
  46448. /**
  46449. * The Physically based material base class of BJS.
  46450. *
  46451. * This offers the main features of a standard PBR material.
  46452. * For more information, please refer to the documentation :
  46453. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46454. */
  46455. export abstract class PBRBaseMaterial extends PushMaterial {
  46456. /**
  46457. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46458. */
  46459. static readonly PBRMATERIAL_OPAQUE: number;
  46460. /**
  46461. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46462. */
  46463. static readonly PBRMATERIAL_ALPHATEST: number;
  46464. /**
  46465. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46466. */
  46467. static readonly PBRMATERIAL_ALPHABLEND: number;
  46468. /**
  46469. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46470. * They are also discarded below the alpha cutoff threshold to improve performances.
  46471. */
  46472. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46473. /**
  46474. * Defines the default value of how much AO map is occluding the analytical lights
  46475. * (point spot...).
  46476. */
  46477. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46478. /**
  46479. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46480. */
  46481. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46482. /**
  46483. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46484. * to enhance interoperability with other engines.
  46485. */
  46486. static readonly LIGHTFALLOFF_GLTF: number;
  46487. /**
  46488. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46489. * to enhance interoperability with other materials.
  46490. */
  46491. static readonly LIGHTFALLOFF_STANDARD: number;
  46492. /**
  46493. * Intensity of the direct lights e.g. the four lights available in your scene.
  46494. * This impacts both the direct diffuse and specular highlights.
  46495. */
  46496. protected _directIntensity: number;
  46497. /**
  46498. * Intensity of the emissive part of the material.
  46499. * This helps controlling the emissive effect without modifying the emissive color.
  46500. */
  46501. protected _emissiveIntensity: number;
  46502. /**
  46503. * Intensity of the environment e.g. how much the environment will light the object
  46504. * either through harmonics for rough material or through the refelction for shiny ones.
  46505. */
  46506. protected _environmentIntensity: number;
  46507. /**
  46508. * This is a special control allowing the reduction of the specular highlights coming from the
  46509. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46510. */
  46511. protected _specularIntensity: number;
  46512. /**
  46513. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46514. */
  46515. private _lightingInfos;
  46516. /**
  46517. * Debug Control allowing disabling the bump map on this material.
  46518. */
  46519. protected _disableBumpMap: boolean;
  46520. /**
  46521. * AKA Diffuse Texture in standard nomenclature.
  46522. */
  46523. protected _albedoTexture: Nullable<BaseTexture>;
  46524. /**
  46525. * AKA Occlusion Texture in other nomenclature.
  46526. */
  46527. protected _ambientTexture: Nullable<BaseTexture>;
  46528. /**
  46529. * AKA Occlusion Texture Intensity in other nomenclature.
  46530. */
  46531. protected _ambientTextureStrength: number;
  46532. /**
  46533. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46534. * 1 means it completely occludes it
  46535. * 0 mean it has no impact
  46536. */
  46537. protected _ambientTextureImpactOnAnalyticalLights: number;
  46538. /**
  46539. * Stores the alpha values in a texture.
  46540. */
  46541. protected _opacityTexture: Nullable<BaseTexture>;
  46542. /**
  46543. * Stores the reflection values in a texture.
  46544. */
  46545. protected _reflectionTexture: Nullable<BaseTexture>;
  46546. /**
  46547. * Stores the emissive values in a texture.
  46548. */
  46549. protected _emissiveTexture: Nullable<BaseTexture>;
  46550. /**
  46551. * AKA Specular texture in other nomenclature.
  46552. */
  46553. protected _reflectivityTexture: Nullable<BaseTexture>;
  46554. /**
  46555. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46556. */
  46557. protected _metallicTexture: Nullable<BaseTexture>;
  46558. /**
  46559. * Specifies the metallic scalar of the metallic/roughness workflow.
  46560. * Can also be used to scale the metalness values of the metallic texture.
  46561. */
  46562. protected _metallic: Nullable<number>;
  46563. /**
  46564. * Specifies the roughness scalar of the metallic/roughness workflow.
  46565. * Can also be used to scale the roughness values of the metallic texture.
  46566. */
  46567. protected _roughness: Nullable<number>;
  46568. /**
  46569. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46570. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46571. */
  46572. protected _microSurfaceTexture: Nullable<BaseTexture>;
  46573. /**
  46574. * Stores surface normal data used to displace a mesh in a texture.
  46575. */
  46576. protected _bumpTexture: Nullable<BaseTexture>;
  46577. /**
  46578. * Stores the pre-calculated light information of a mesh in a texture.
  46579. */
  46580. protected _lightmapTexture: Nullable<BaseTexture>;
  46581. /**
  46582. * The color of a material in ambient lighting.
  46583. */
  46584. protected _ambientColor: Color3;
  46585. /**
  46586. * AKA Diffuse Color in other nomenclature.
  46587. */
  46588. protected _albedoColor: Color3;
  46589. /**
  46590. * AKA Specular Color in other nomenclature.
  46591. */
  46592. protected _reflectivityColor: Color3;
  46593. /**
  46594. * The color applied when light is reflected from a material.
  46595. */
  46596. protected _reflectionColor: Color3;
  46597. /**
  46598. * The color applied when light is emitted from a material.
  46599. */
  46600. protected _emissiveColor: Color3;
  46601. /**
  46602. * AKA Glossiness in other nomenclature.
  46603. */
  46604. protected _microSurface: number;
  46605. /**
  46606. * Specifies that the material will use the light map as a show map.
  46607. */
  46608. protected _useLightmapAsShadowmap: boolean;
  46609. /**
  46610. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46611. * makes the reflect vector face the model (under horizon).
  46612. */
  46613. protected _useHorizonOcclusion: boolean;
  46614. /**
  46615. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46616. * too much the area relying on ambient texture to define their ambient occlusion.
  46617. */
  46618. protected _useRadianceOcclusion: boolean;
  46619. /**
  46620. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46621. */
  46622. protected _useAlphaFromAlbedoTexture: boolean;
  46623. /**
  46624. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  46625. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46626. */
  46627. protected _useSpecularOverAlpha: boolean;
  46628. /**
  46629. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46630. */
  46631. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46632. /**
  46633. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46634. */
  46635. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  46636. /**
  46637. * Specifies if the metallic texture contains the roughness information in its green channel.
  46638. */
  46639. protected _useRoughnessFromMetallicTextureGreen: boolean;
  46640. /**
  46641. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46642. */
  46643. protected _useMetallnessFromMetallicTextureBlue: boolean;
  46644. /**
  46645. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46646. */
  46647. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  46648. /**
  46649. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46650. */
  46651. protected _useAmbientInGrayScale: boolean;
  46652. /**
  46653. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46654. * The material will try to infer what glossiness each pixel should be.
  46655. */
  46656. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  46657. /**
  46658. * Defines the falloff type used in this material.
  46659. * It by default is Physical.
  46660. */
  46661. protected _lightFalloff: number;
  46662. /**
  46663. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46664. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46665. */
  46666. protected _useRadianceOverAlpha: boolean;
  46667. /**
  46668. * Allows using an object space normal map (instead of tangent space).
  46669. */
  46670. protected _useObjectSpaceNormalMap: boolean;
  46671. /**
  46672. * Allows using the bump map in parallax mode.
  46673. */
  46674. protected _useParallax: boolean;
  46675. /**
  46676. * Allows using the bump map in parallax occlusion mode.
  46677. */
  46678. protected _useParallaxOcclusion: boolean;
  46679. /**
  46680. * Controls the scale bias of the parallax mode.
  46681. */
  46682. protected _parallaxScaleBias: number;
  46683. /**
  46684. * If sets to true, disables all the lights affecting the material.
  46685. */
  46686. protected _disableLighting: boolean;
  46687. /**
  46688. * Number of Simultaneous lights allowed on the material.
  46689. */
  46690. protected _maxSimultaneousLights: number;
  46691. /**
  46692. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46693. */
  46694. protected _invertNormalMapX: boolean;
  46695. /**
  46696. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46697. */
  46698. protected _invertNormalMapY: boolean;
  46699. /**
  46700. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46701. */
  46702. protected _twoSidedLighting: boolean;
  46703. /**
  46704. * Defines the alpha limits in alpha test mode.
  46705. */
  46706. protected _alphaCutOff: number;
  46707. /**
  46708. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46709. */
  46710. protected _forceAlphaTest: boolean;
  46711. /**
  46712. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46713. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46714. */
  46715. protected _useAlphaFresnel: boolean;
  46716. /**
  46717. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46718. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46719. */
  46720. protected _useLinearAlphaFresnel: boolean;
  46721. /**
  46722. * The transparency mode of the material.
  46723. */
  46724. protected _transparencyMode: Nullable<number>;
  46725. /**
  46726. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  46727. * from cos thetav and roughness:
  46728. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  46729. */
  46730. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  46731. /**
  46732. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46733. */
  46734. protected _forceIrradianceInFragment: boolean;
  46735. /**
  46736. * Force normal to face away from face.
  46737. */
  46738. protected _forceNormalForward: boolean;
  46739. /**
  46740. * Enables specular anti aliasing in the PBR shader.
  46741. * It will both interacts on the Geometry for analytical and IBL lighting.
  46742. * It also prefilter the roughness map based on the bump values.
  46743. */
  46744. protected _enableSpecularAntiAliasing: boolean;
  46745. /**
  46746. * Default configuration related to image processing available in the PBR Material.
  46747. */
  46748. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46749. /**
  46750. * Keep track of the image processing observer to allow dispose and replace.
  46751. */
  46752. private _imageProcessingObserver;
  46753. /**
  46754. * Attaches a new image processing configuration to the PBR Material.
  46755. * @param configuration
  46756. */
  46757. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46758. /**
  46759. * Stores the available render targets.
  46760. */
  46761. private _renderTargets;
  46762. /**
  46763. * Sets the global ambient color for the material used in lighting calculations.
  46764. */
  46765. private _globalAmbientColor;
  46766. /**
  46767. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46768. */
  46769. private _useLogarithmicDepth;
  46770. /**
  46771. * If set to true, no lighting calculations will be applied.
  46772. */
  46773. private _unlit;
  46774. private _debugMode;
  46775. /**
  46776. * @hidden
  46777. * This is reserved for the inspector.
  46778. * Defines the material debug mode.
  46779. * It helps seeing only some components of the material while troubleshooting.
  46780. */
  46781. debugMode: number;
  46782. /**
  46783. * @hidden
  46784. * This is reserved for the inspector.
  46785. * Specify from where on screen the debug mode should start.
  46786. * The value goes from -1 (full screen) to 1 (not visible)
  46787. * It helps with side by side comparison against the final render
  46788. * This defaults to -1
  46789. */
  46790. private debugLimit;
  46791. /**
  46792. * @hidden
  46793. * This is reserved for the inspector.
  46794. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46795. * You can use the factor to better multiply the final value.
  46796. */
  46797. private debugFactor;
  46798. /**
  46799. * Defines the clear coat layer parameters for the material.
  46800. */
  46801. readonly clearCoat: PBRClearCoatConfiguration;
  46802. /**
  46803. * Defines the anisotropic parameters for the material.
  46804. */
  46805. readonly anisotropy: PBRAnisotropicConfiguration;
  46806. /**
  46807. * Defines the BRDF parameters for the material.
  46808. */
  46809. readonly brdf: PBRBRDFConfiguration;
  46810. /**
  46811. * Defines the Sheen parameters for the material.
  46812. */
  46813. readonly sheen: PBRSheenConfiguration;
  46814. /**
  46815. * Defines the SubSurface parameters for the material.
  46816. */
  46817. readonly subSurface: PBRSubSurfaceConfiguration;
  46818. /**
  46819. * Custom callback helping to override the default shader used in the material.
  46820. */
  46821. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46822. /**
  46823. * Instantiates a new PBRMaterial instance.
  46824. *
  46825. * @param name The material name
  46826. * @param scene The scene the material will be use in.
  46827. */
  46828. constructor(name: string, scene: Scene);
  46829. /**
  46830. * Gets a boolean indicating that current material needs to register RTT
  46831. */
  46832. readonly hasRenderTargetTextures: boolean;
  46833. /**
  46834. * Gets the name of the material class.
  46835. */
  46836. getClassName(): string;
  46837. /**
  46838. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46839. */
  46840. /**
  46841. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46842. */
  46843. useLogarithmicDepth: boolean;
  46844. /**
  46845. * Gets the current transparency mode.
  46846. */
  46847. /**
  46848. * Sets the transparency mode of the material.
  46849. *
  46850. * | Value | Type | Description |
  46851. * | ----- | ----------------------------------- | ----------- |
  46852. * | 0 | OPAQUE | |
  46853. * | 1 | ALPHATEST | |
  46854. * | 2 | ALPHABLEND | |
  46855. * | 3 | ALPHATESTANDBLEND | |
  46856. *
  46857. */
  46858. transparencyMode: Nullable<number>;
  46859. /**
  46860. * Returns true if alpha blending should be disabled.
  46861. */
  46862. private readonly _disableAlphaBlending;
  46863. /**
  46864. * Specifies whether or not this material should be rendered in alpha blend mode.
  46865. */
  46866. needAlphaBlending(): boolean;
  46867. /**
  46868. * Specifies if the mesh will require alpha blending.
  46869. * @param mesh - BJS mesh.
  46870. */
  46871. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46872. /**
  46873. * Specifies whether or not this material should be rendered in alpha test mode.
  46874. */
  46875. needAlphaTesting(): boolean;
  46876. /**
  46877. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46878. */
  46879. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46880. /**
  46881. * Gets the texture used for the alpha test.
  46882. */
  46883. getAlphaTestTexture(): Nullable<BaseTexture>;
  46884. /**
  46885. * Specifies that the submesh is ready to be used.
  46886. * @param mesh - BJS mesh.
  46887. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46888. * @param useInstances - Specifies that instances should be used.
  46889. * @returns - boolean indicating that the submesh is ready or not.
  46890. */
  46891. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46892. /**
  46893. * Specifies if the material uses metallic roughness workflow.
  46894. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46895. */
  46896. isMetallicWorkflow(): boolean;
  46897. private _prepareEffect;
  46898. private _prepareDefines;
  46899. /**
  46900. * Force shader compilation
  46901. */
  46902. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46903. clipPlane: boolean;
  46904. }>): void;
  46905. /**
  46906. * Initializes the uniform buffer layout for the shader.
  46907. */
  46908. buildUniformLayout(): void;
  46909. /**
  46910. * Unbinds the material from the mesh
  46911. */
  46912. unbind(): void;
  46913. /**
  46914. * Binds the submesh data.
  46915. * @param world - The world matrix.
  46916. * @param mesh - The BJS mesh.
  46917. * @param subMesh - A submesh of the BJS mesh.
  46918. */
  46919. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46920. /**
  46921. * Returns the animatable textures.
  46922. * @returns - Array of animatable textures.
  46923. */
  46924. getAnimatables(): IAnimatable[];
  46925. /**
  46926. * Returns the texture used for reflections.
  46927. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46928. */
  46929. private _getReflectionTexture;
  46930. /**
  46931. * Returns an array of the actively used textures.
  46932. * @returns - Array of BaseTextures
  46933. */
  46934. getActiveTextures(): BaseTexture[];
  46935. /**
  46936. * Checks to see if a texture is used in the material.
  46937. * @param texture - Base texture to use.
  46938. * @returns - Boolean specifying if a texture is used in the material.
  46939. */
  46940. hasTexture(texture: BaseTexture): boolean;
  46941. /**
  46942. * Disposes the resources of the material.
  46943. * @param forceDisposeEffect - Forces the disposal of effects.
  46944. * @param forceDisposeTextures - Forces the disposal of all textures.
  46945. */
  46946. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46947. }
  46948. }
  46949. declare module BABYLON {
  46950. /**
  46951. * The Physically based material of BJS.
  46952. *
  46953. * This offers the main features of a standard PBR material.
  46954. * For more information, please refer to the documentation :
  46955. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46956. */
  46957. export class PBRMaterial extends PBRBaseMaterial {
  46958. /**
  46959. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46960. */
  46961. static readonly PBRMATERIAL_OPAQUE: number;
  46962. /**
  46963. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46964. */
  46965. static readonly PBRMATERIAL_ALPHATEST: number;
  46966. /**
  46967. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46968. */
  46969. static readonly PBRMATERIAL_ALPHABLEND: number;
  46970. /**
  46971. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46972. * They are also discarded below the alpha cutoff threshold to improve performances.
  46973. */
  46974. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46975. /**
  46976. * Defines the default value of how much AO map is occluding the analytical lights
  46977. * (point spot...).
  46978. */
  46979. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46980. /**
  46981. * Intensity of the direct lights e.g. the four lights available in your scene.
  46982. * This impacts both the direct diffuse and specular highlights.
  46983. */
  46984. directIntensity: number;
  46985. /**
  46986. * Intensity of the emissive part of the material.
  46987. * This helps controlling the emissive effect without modifying the emissive color.
  46988. */
  46989. emissiveIntensity: number;
  46990. /**
  46991. * Intensity of the environment e.g. how much the environment will light the object
  46992. * either through harmonics for rough material or through the refelction for shiny ones.
  46993. */
  46994. environmentIntensity: number;
  46995. /**
  46996. * This is a special control allowing the reduction of the specular highlights coming from the
  46997. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46998. */
  46999. specularIntensity: number;
  47000. /**
  47001. * Debug Control allowing disabling the bump map on this material.
  47002. */
  47003. disableBumpMap: boolean;
  47004. /**
  47005. * AKA Diffuse Texture in standard nomenclature.
  47006. */
  47007. albedoTexture: BaseTexture;
  47008. /**
  47009. * AKA Occlusion Texture in other nomenclature.
  47010. */
  47011. ambientTexture: BaseTexture;
  47012. /**
  47013. * AKA Occlusion Texture Intensity in other nomenclature.
  47014. */
  47015. ambientTextureStrength: number;
  47016. /**
  47017. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47018. * 1 means it completely occludes it
  47019. * 0 mean it has no impact
  47020. */
  47021. ambientTextureImpactOnAnalyticalLights: number;
  47022. /**
  47023. * Stores the alpha values in a texture.
  47024. */
  47025. opacityTexture: BaseTexture;
  47026. /**
  47027. * Stores the reflection values in a texture.
  47028. */
  47029. reflectionTexture: Nullable<BaseTexture>;
  47030. /**
  47031. * Stores the emissive values in a texture.
  47032. */
  47033. emissiveTexture: BaseTexture;
  47034. /**
  47035. * AKA Specular texture in other nomenclature.
  47036. */
  47037. reflectivityTexture: BaseTexture;
  47038. /**
  47039. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47040. */
  47041. metallicTexture: BaseTexture;
  47042. /**
  47043. * Specifies the metallic scalar of the metallic/roughness workflow.
  47044. * Can also be used to scale the metalness values of the metallic texture.
  47045. */
  47046. metallic: Nullable<number>;
  47047. /**
  47048. * Specifies the roughness scalar of the metallic/roughness workflow.
  47049. * Can also be used to scale the roughness values of the metallic texture.
  47050. */
  47051. roughness: Nullable<number>;
  47052. /**
  47053. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47054. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47055. */
  47056. microSurfaceTexture: BaseTexture;
  47057. /**
  47058. * Stores surface normal data used to displace a mesh in a texture.
  47059. */
  47060. bumpTexture: BaseTexture;
  47061. /**
  47062. * Stores the pre-calculated light information of a mesh in a texture.
  47063. */
  47064. lightmapTexture: BaseTexture;
  47065. /**
  47066. * Stores the refracted light information in a texture.
  47067. */
  47068. refractionTexture: Nullable<BaseTexture>;
  47069. /**
  47070. * The color of a material in ambient lighting.
  47071. */
  47072. ambientColor: Color3;
  47073. /**
  47074. * AKA Diffuse Color in other nomenclature.
  47075. */
  47076. albedoColor: Color3;
  47077. /**
  47078. * AKA Specular Color in other nomenclature.
  47079. */
  47080. reflectivityColor: Color3;
  47081. /**
  47082. * The color reflected from the material.
  47083. */
  47084. reflectionColor: Color3;
  47085. /**
  47086. * The color emitted from the material.
  47087. */
  47088. emissiveColor: Color3;
  47089. /**
  47090. * AKA Glossiness in other nomenclature.
  47091. */
  47092. microSurface: number;
  47093. /**
  47094. * source material index of refraction (IOR)' / 'destination material IOR.
  47095. */
  47096. indexOfRefraction: number;
  47097. /**
  47098. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47099. */
  47100. invertRefractionY: boolean;
  47101. /**
  47102. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47103. * Materials half opaque for instance using refraction could benefit from this control.
  47104. */
  47105. linkRefractionWithTransparency: boolean;
  47106. /**
  47107. * If true, the light map contains occlusion information instead of lighting info.
  47108. */
  47109. useLightmapAsShadowmap: boolean;
  47110. /**
  47111. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47112. */
  47113. useAlphaFromAlbedoTexture: boolean;
  47114. /**
  47115. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47116. */
  47117. forceAlphaTest: boolean;
  47118. /**
  47119. * Defines the alpha limits in alpha test mode.
  47120. */
  47121. alphaCutOff: number;
  47122. /**
  47123. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47124. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47125. */
  47126. useSpecularOverAlpha: boolean;
  47127. /**
  47128. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47129. */
  47130. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47131. /**
  47132. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47133. */
  47134. useRoughnessFromMetallicTextureAlpha: boolean;
  47135. /**
  47136. * Specifies if the metallic texture contains the roughness information in its green channel.
  47137. */
  47138. useRoughnessFromMetallicTextureGreen: boolean;
  47139. /**
  47140. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47141. */
  47142. useMetallnessFromMetallicTextureBlue: boolean;
  47143. /**
  47144. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47145. */
  47146. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47147. /**
  47148. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47149. */
  47150. useAmbientInGrayScale: boolean;
  47151. /**
  47152. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47153. * The material will try to infer what glossiness each pixel should be.
  47154. */
  47155. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47156. /**
  47157. * BJS is using an harcoded light falloff based on a manually sets up range.
  47158. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47159. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47160. */
  47161. /**
  47162. * BJS is using an harcoded light falloff based on a manually sets up range.
  47163. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47164. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47165. */
  47166. usePhysicalLightFalloff: boolean;
  47167. /**
  47168. * In order to support the falloff compatibility with gltf, a special mode has been added
  47169. * to reproduce the gltf light falloff.
  47170. */
  47171. /**
  47172. * In order to support the falloff compatibility with gltf, a special mode has been added
  47173. * to reproduce the gltf light falloff.
  47174. */
  47175. useGLTFLightFalloff: boolean;
  47176. /**
  47177. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47178. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47179. */
  47180. useRadianceOverAlpha: boolean;
  47181. /**
  47182. * Allows using an object space normal map (instead of tangent space).
  47183. */
  47184. useObjectSpaceNormalMap: boolean;
  47185. /**
  47186. * Allows using the bump map in parallax mode.
  47187. */
  47188. useParallax: boolean;
  47189. /**
  47190. * Allows using the bump map in parallax occlusion mode.
  47191. */
  47192. useParallaxOcclusion: boolean;
  47193. /**
  47194. * Controls the scale bias of the parallax mode.
  47195. */
  47196. parallaxScaleBias: number;
  47197. /**
  47198. * If sets to true, disables all the lights affecting the material.
  47199. */
  47200. disableLighting: boolean;
  47201. /**
  47202. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47203. */
  47204. forceIrradianceInFragment: boolean;
  47205. /**
  47206. * Number of Simultaneous lights allowed on the material.
  47207. */
  47208. maxSimultaneousLights: number;
  47209. /**
  47210. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47211. */
  47212. invertNormalMapX: boolean;
  47213. /**
  47214. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47215. */
  47216. invertNormalMapY: boolean;
  47217. /**
  47218. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47219. */
  47220. twoSidedLighting: boolean;
  47221. /**
  47222. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47223. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47224. */
  47225. useAlphaFresnel: boolean;
  47226. /**
  47227. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47228. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47229. */
  47230. useLinearAlphaFresnel: boolean;
  47231. /**
  47232. * Let user defines the brdf lookup texture used for IBL.
  47233. * A default 8bit version is embedded but you could point at :
  47234. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  47235. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47236. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  47237. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47238. */
  47239. environmentBRDFTexture: Nullable<BaseTexture>;
  47240. /**
  47241. * Force normal to face away from face.
  47242. */
  47243. forceNormalForward: boolean;
  47244. /**
  47245. * Enables specular anti aliasing in the PBR shader.
  47246. * It will both interacts on the Geometry for analytical and IBL lighting.
  47247. * It also prefilter the roughness map based on the bump values.
  47248. */
  47249. enableSpecularAntiAliasing: boolean;
  47250. /**
  47251. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47252. * makes the reflect vector face the model (under horizon).
  47253. */
  47254. useHorizonOcclusion: boolean;
  47255. /**
  47256. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47257. * too much the area relying on ambient texture to define their ambient occlusion.
  47258. */
  47259. useRadianceOcclusion: boolean;
  47260. /**
  47261. * If set to true, no lighting calculations will be applied.
  47262. */
  47263. unlit: boolean;
  47264. /**
  47265. * Gets the image processing configuration used either in this material.
  47266. */
  47267. /**
  47268. * Sets the Default image processing configuration used either in the this material.
  47269. *
  47270. * If sets to null, the scene one is in use.
  47271. */
  47272. imageProcessingConfiguration: ImageProcessingConfiguration;
  47273. /**
  47274. * Gets wether the color curves effect is enabled.
  47275. */
  47276. /**
  47277. * Sets wether the color curves effect is enabled.
  47278. */
  47279. cameraColorCurvesEnabled: boolean;
  47280. /**
  47281. * Gets wether the color grading effect is enabled.
  47282. */
  47283. /**
  47284. * Gets wether the color grading effect is enabled.
  47285. */
  47286. cameraColorGradingEnabled: boolean;
  47287. /**
  47288. * Gets wether tonemapping is enabled or not.
  47289. */
  47290. /**
  47291. * Sets wether tonemapping is enabled or not
  47292. */
  47293. cameraToneMappingEnabled: boolean;
  47294. /**
  47295. * The camera exposure used on this material.
  47296. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47297. * This corresponds to a photographic exposure.
  47298. */
  47299. /**
  47300. * The camera exposure used on this material.
  47301. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47302. * This corresponds to a photographic exposure.
  47303. */
  47304. cameraExposure: number;
  47305. /**
  47306. * Gets The camera contrast used on this material.
  47307. */
  47308. /**
  47309. * Sets The camera contrast used on this material.
  47310. */
  47311. cameraContrast: number;
  47312. /**
  47313. * Gets the Color Grading 2D Lookup Texture.
  47314. */
  47315. /**
  47316. * Sets the Color Grading 2D Lookup Texture.
  47317. */
  47318. cameraColorGradingTexture: Nullable<BaseTexture>;
  47319. /**
  47320. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47321. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47322. * 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;
  47323. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47324. */
  47325. /**
  47326. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47327. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47328. * 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;
  47329. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47330. */
  47331. cameraColorCurves: Nullable<ColorCurves>;
  47332. /**
  47333. * Instantiates a new PBRMaterial instance.
  47334. *
  47335. * @param name The material name
  47336. * @param scene The scene the material will be use in.
  47337. */
  47338. constructor(name: string, scene: Scene);
  47339. /**
  47340. * Returns the name of this material class.
  47341. */
  47342. getClassName(): string;
  47343. /**
  47344. * Makes a duplicate of the current material.
  47345. * @param name - name to use for the new material.
  47346. */
  47347. clone(name: string): PBRMaterial;
  47348. /**
  47349. * Serializes this PBR Material.
  47350. * @returns - An object with the serialized material.
  47351. */
  47352. serialize(): any;
  47353. /**
  47354. * Parses a PBR Material from a serialized object.
  47355. * @param source - Serialized object.
  47356. * @param scene - BJS scene instance.
  47357. * @param rootUrl - url for the scene object
  47358. * @returns - PBRMaterial
  47359. */
  47360. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47361. }
  47362. }
  47363. declare module BABYLON {
  47364. /**
  47365. * Direct draw surface info
  47366. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47367. */
  47368. export interface DDSInfo {
  47369. /**
  47370. * Width of the texture
  47371. */
  47372. width: number;
  47373. /**
  47374. * Width of the texture
  47375. */
  47376. height: number;
  47377. /**
  47378. * Number of Mipmaps for the texture
  47379. * @see https://en.wikipedia.org/wiki/Mipmap
  47380. */
  47381. mipmapCount: number;
  47382. /**
  47383. * If the textures format is a known fourCC format
  47384. * @see https://www.fourcc.org/
  47385. */
  47386. isFourCC: boolean;
  47387. /**
  47388. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47389. */
  47390. isRGB: boolean;
  47391. /**
  47392. * If the texture is a lumincance format
  47393. */
  47394. isLuminance: boolean;
  47395. /**
  47396. * If this is a cube texture
  47397. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47398. */
  47399. isCube: boolean;
  47400. /**
  47401. * If the texture is a compressed format eg. FOURCC_DXT1
  47402. */
  47403. isCompressed: boolean;
  47404. /**
  47405. * The dxgiFormat of the texture
  47406. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47407. */
  47408. dxgiFormat: number;
  47409. /**
  47410. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47411. */
  47412. textureType: number;
  47413. /**
  47414. * Sphericle polynomial created for the dds texture
  47415. */
  47416. sphericalPolynomial?: SphericalPolynomial;
  47417. }
  47418. /**
  47419. * Class used to provide DDS decompression tools
  47420. */
  47421. export class DDSTools {
  47422. /**
  47423. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47424. */
  47425. static StoreLODInAlphaChannel: boolean;
  47426. /**
  47427. * Gets DDS information from an array buffer
  47428. * @param arrayBuffer defines the array buffer to read data from
  47429. * @returns the DDS information
  47430. */
  47431. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47432. private static _FloatView;
  47433. private static _Int32View;
  47434. private static _ToHalfFloat;
  47435. private static _FromHalfFloat;
  47436. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47437. private static _GetHalfFloatRGBAArrayBuffer;
  47438. private static _GetFloatRGBAArrayBuffer;
  47439. private static _GetFloatAsUIntRGBAArrayBuffer;
  47440. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47441. private static _GetRGBAArrayBuffer;
  47442. private static _ExtractLongWordOrder;
  47443. private static _GetRGBArrayBuffer;
  47444. private static _GetLuminanceArrayBuffer;
  47445. /**
  47446. * Uploads DDS Levels to a Babylon Texture
  47447. * @hidden
  47448. */
  47449. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47450. }
  47451. interface Engine {
  47452. /**
  47453. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47454. * @param rootUrl defines the url where the file to load is located
  47455. * @param scene defines the current scene
  47456. * @param lodScale defines scale to apply to the mip map selection
  47457. * @param lodOffset defines offset to apply to the mip map selection
  47458. * @param onLoad defines an optional callback raised when the texture is loaded
  47459. * @param onError defines an optional callback raised if there is an issue to load the texture
  47460. * @param format defines the format of the data
  47461. * @param forcedExtension defines the extension to use to pick the right loader
  47462. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47463. * @returns the cube texture as an InternalTexture
  47464. */
  47465. 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;
  47466. }
  47467. }
  47468. declare module BABYLON {
  47469. /**
  47470. * Implementation of the DDS Texture Loader.
  47471. * @hidden
  47472. */
  47473. export class _DDSTextureLoader implements IInternalTextureLoader {
  47474. /**
  47475. * Defines wether the loader supports cascade loading the different faces.
  47476. */
  47477. readonly supportCascades: boolean;
  47478. /**
  47479. * This returns if the loader support the current file information.
  47480. * @param extension defines the file extension of the file being loaded
  47481. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47482. * @param fallback defines the fallback internal texture if any
  47483. * @param isBase64 defines whether the texture is encoded as a base64
  47484. * @param isBuffer defines whether the texture data are stored as a buffer
  47485. * @returns true if the loader can load the specified file
  47486. */
  47487. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47488. /**
  47489. * Transform the url before loading if required.
  47490. * @param rootUrl the url of the texture
  47491. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47492. * @returns the transformed texture
  47493. */
  47494. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47495. /**
  47496. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47497. * @param rootUrl the url of the texture
  47498. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47499. * @returns the fallback texture
  47500. */
  47501. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47502. /**
  47503. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47504. * @param data contains the texture data
  47505. * @param texture defines the BabylonJS internal texture
  47506. * @param createPolynomials will be true if polynomials have been requested
  47507. * @param onLoad defines the callback to trigger once the texture is ready
  47508. * @param onError defines the callback to trigger in case of error
  47509. */
  47510. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47511. /**
  47512. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47513. * @param data contains the texture data
  47514. * @param texture defines the BabylonJS internal texture
  47515. * @param callback defines the method to call once ready to upload
  47516. */
  47517. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47518. }
  47519. }
  47520. declare module BABYLON {
  47521. /** @hidden */
  47522. export var rgbdEncodePixelShader: {
  47523. name: string;
  47524. shader: string;
  47525. };
  47526. }
  47527. declare module BABYLON {
  47528. /**
  47529. * Raw texture data and descriptor sufficient for WebGL texture upload
  47530. */
  47531. export interface EnvironmentTextureInfo {
  47532. /**
  47533. * Version of the environment map
  47534. */
  47535. version: number;
  47536. /**
  47537. * Width of image
  47538. */
  47539. width: number;
  47540. /**
  47541. * Irradiance information stored in the file.
  47542. */
  47543. irradiance: any;
  47544. /**
  47545. * Specular information stored in the file.
  47546. */
  47547. specular: any;
  47548. }
  47549. /**
  47550. * Sets of helpers addressing the serialization and deserialization of environment texture
  47551. * stored in a BabylonJS env file.
  47552. * Those files are usually stored as .env files.
  47553. */
  47554. export class EnvironmentTextureTools {
  47555. /**
  47556. * Magic number identifying the env file.
  47557. */
  47558. private static _MagicBytes;
  47559. /**
  47560. * Gets the environment info from an env file.
  47561. * @param data The array buffer containing the .env bytes.
  47562. * @returns the environment file info (the json header) if successfully parsed.
  47563. */
  47564. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47565. /**
  47566. * Creates an environment texture from a loaded cube texture.
  47567. * @param texture defines the cube texture to convert in env file
  47568. * @return a promise containing the environment data if succesfull.
  47569. */
  47570. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47571. /**
  47572. * Creates a JSON representation of the spherical data.
  47573. * @param texture defines the texture containing the polynomials
  47574. * @return the JSON representation of the spherical info
  47575. */
  47576. private static _CreateEnvTextureIrradiance;
  47577. /**
  47578. * Uploads the texture info contained in the env file to the GPU.
  47579. * @param texture defines the internal texture to upload to
  47580. * @param arrayBuffer defines the buffer cotaining the data to load
  47581. * @param info defines the texture info retrieved through the GetEnvInfo method
  47582. * @returns a promise
  47583. */
  47584. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47585. /**
  47586. * Uploads the levels of image data to the GPU.
  47587. * @param texture defines the internal texture to upload to
  47588. * @param imageData defines the array buffer views of image data [mipmap][face]
  47589. * @returns a promise
  47590. */
  47591. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47592. /**
  47593. * Uploads spherical polynomials information to the texture.
  47594. * @param texture defines the texture we are trying to upload the information to
  47595. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47596. */
  47597. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47598. /** @hidden */
  47599. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47600. }
  47601. }
  47602. declare module BABYLON {
  47603. /**
  47604. * Implementation of the ENV Texture Loader.
  47605. * @hidden
  47606. */
  47607. export class _ENVTextureLoader implements IInternalTextureLoader {
  47608. /**
  47609. * Defines wether the loader supports cascade loading the different faces.
  47610. */
  47611. readonly supportCascades: boolean;
  47612. /**
  47613. * This returns if the loader support the current file information.
  47614. * @param extension defines the file extension of the file being loaded
  47615. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47616. * @param fallback defines the fallback internal texture if any
  47617. * @param isBase64 defines whether the texture is encoded as a base64
  47618. * @param isBuffer defines whether the texture data are stored as a buffer
  47619. * @returns true if the loader can load the specified file
  47620. */
  47621. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47622. /**
  47623. * Transform the url before loading if required.
  47624. * @param rootUrl the url of the texture
  47625. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47626. * @returns the transformed texture
  47627. */
  47628. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47629. /**
  47630. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47631. * @param rootUrl the url of the texture
  47632. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47633. * @returns the fallback texture
  47634. */
  47635. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47636. /**
  47637. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47638. * @param data contains the texture data
  47639. * @param texture defines the BabylonJS internal texture
  47640. * @param createPolynomials will be true if polynomials have been requested
  47641. * @param onLoad defines the callback to trigger once the texture is ready
  47642. * @param onError defines the callback to trigger in case of error
  47643. */
  47644. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47645. /**
  47646. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47647. * @param data contains the texture data
  47648. * @param texture defines the BabylonJS internal texture
  47649. * @param callback defines the method to call once ready to upload
  47650. */
  47651. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47652. }
  47653. }
  47654. declare module BABYLON {
  47655. /**
  47656. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47657. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47658. */
  47659. export class KhronosTextureContainer {
  47660. /** contents of the KTX container file */
  47661. arrayBuffer: any;
  47662. private static HEADER_LEN;
  47663. private static COMPRESSED_2D;
  47664. private static COMPRESSED_3D;
  47665. private static TEX_2D;
  47666. private static TEX_3D;
  47667. /**
  47668. * Gets the openGL type
  47669. */
  47670. glType: number;
  47671. /**
  47672. * Gets the openGL type size
  47673. */
  47674. glTypeSize: number;
  47675. /**
  47676. * Gets the openGL format
  47677. */
  47678. glFormat: number;
  47679. /**
  47680. * Gets the openGL internal format
  47681. */
  47682. glInternalFormat: number;
  47683. /**
  47684. * Gets the base internal format
  47685. */
  47686. glBaseInternalFormat: number;
  47687. /**
  47688. * Gets image width in pixel
  47689. */
  47690. pixelWidth: number;
  47691. /**
  47692. * Gets image height in pixel
  47693. */
  47694. pixelHeight: number;
  47695. /**
  47696. * Gets image depth in pixels
  47697. */
  47698. pixelDepth: number;
  47699. /**
  47700. * Gets the number of array elements
  47701. */
  47702. numberOfArrayElements: number;
  47703. /**
  47704. * Gets the number of faces
  47705. */
  47706. numberOfFaces: number;
  47707. /**
  47708. * Gets the number of mipmap levels
  47709. */
  47710. numberOfMipmapLevels: number;
  47711. /**
  47712. * Gets the bytes of key value data
  47713. */
  47714. bytesOfKeyValueData: number;
  47715. /**
  47716. * Gets the load type
  47717. */
  47718. loadType: number;
  47719. /**
  47720. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47721. */
  47722. isInvalid: boolean;
  47723. /**
  47724. * Creates a new KhronosTextureContainer
  47725. * @param arrayBuffer contents of the KTX container file
  47726. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47727. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47728. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47729. */
  47730. constructor(
  47731. /** contents of the KTX container file */
  47732. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47733. /**
  47734. * Uploads KTX content to a Babylon Texture.
  47735. * It is assumed that the texture has already been created & is currently bound
  47736. * @hidden
  47737. */
  47738. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47739. private _upload2DCompressedLevels;
  47740. }
  47741. }
  47742. declare module BABYLON {
  47743. /**
  47744. * Implementation of the KTX Texture Loader.
  47745. * @hidden
  47746. */
  47747. export class _KTXTextureLoader implements IInternalTextureLoader {
  47748. /**
  47749. * Defines wether the loader supports cascade loading the different faces.
  47750. */
  47751. readonly supportCascades: boolean;
  47752. /**
  47753. * This returns if the loader support the current file information.
  47754. * @param extension defines the file extension of the file being loaded
  47755. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47756. * @param fallback defines the fallback internal texture if any
  47757. * @param isBase64 defines whether the texture is encoded as a base64
  47758. * @param isBuffer defines whether the texture data are stored as a buffer
  47759. * @returns true if the loader can load the specified file
  47760. */
  47761. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47762. /**
  47763. * Transform the url before loading if required.
  47764. * @param rootUrl the url of the texture
  47765. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47766. * @returns the transformed texture
  47767. */
  47768. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47769. /**
  47770. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47771. * @param rootUrl the url of the texture
  47772. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47773. * @returns the fallback texture
  47774. */
  47775. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47776. /**
  47777. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47778. * @param data contains the texture data
  47779. * @param texture defines the BabylonJS internal texture
  47780. * @param createPolynomials will be true if polynomials have been requested
  47781. * @param onLoad defines the callback to trigger once the texture is ready
  47782. * @param onError defines the callback to trigger in case of error
  47783. */
  47784. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47785. /**
  47786. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47787. * @param data contains the texture data
  47788. * @param texture defines the BabylonJS internal texture
  47789. * @param callback defines the method to call once ready to upload
  47790. */
  47791. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47792. }
  47793. }
  47794. declare module BABYLON {
  47795. /**
  47796. * Options for the default xr helper
  47797. */
  47798. export class WebXRDefaultExperienceOptions {
  47799. /**
  47800. * Floor meshes that should be used for teleporting
  47801. */
  47802. floorMeshes: Array<AbstractMesh>;
  47803. }
  47804. /**
  47805. * Default experience which provides a similar setup to the previous webVRExperience
  47806. */
  47807. export class WebXRDefaultExperience {
  47808. /**
  47809. * Base experience
  47810. */
  47811. baseExperience: WebXRExperienceHelper;
  47812. /**
  47813. * Input experience extension
  47814. */
  47815. input: WebXRInput;
  47816. /**
  47817. * Loads the controller models
  47818. */
  47819. controllerModelLoader: WebXRControllerModelLoader;
  47820. /**
  47821. * Enables laser pointer and selection
  47822. */
  47823. pointerSelection: WebXRControllerPointerSelection;
  47824. /**
  47825. * Enables teleportation
  47826. */
  47827. teleportation: WebXRControllerTeleportation;
  47828. /**
  47829. * Enables ui for enetering/exiting xr
  47830. */
  47831. enterExitUI: WebXREnterExitUI;
  47832. /**
  47833. * Default output canvas xr should render to
  47834. */
  47835. outputCanvas: WebXRManagedOutputCanvas;
  47836. /**
  47837. * Creates the default xr experience
  47838. * @param scene scene
  47839. * @param options options for basic configuration
  47840. * @returns resulting WebXRDefaultExperience
  47841. */
  47842. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47843. private constructor();
  47844. /**
  47845. * DIsposes of the experience helper
  47846. */
  47847. dispose(): void;
  47848. }
  47849. }
  47850. declare module BABYLON {
  47851. /** @hidden */
  47852. export var _forceSceneHelpersToBundle: boolean;
  47853. interface Scene {
  47854. /**
  47855. * Creates a default light for the scene.
  47856. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47857. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47858. */
  47859. createDefaultLight(replace?: boolean): void;
  47860. /**
  47861. * Creates a default camera for the scene.
  47862. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47863. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47864. * @param replace has default false, when true replaces the active camera in the scene
  47865. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47866. */
  47867. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47868. /**
  47869. * Creates a default camera and a default light.
  47870. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47871. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47872. * @param replace has the default false, when true replaces the active camera/light in the scene
  47873. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47874. */
  47875. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47876. /**
  47877. * Creates a new sky box
  47878. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47879. * @param environmentTexture defines the texture to use as environment texture
  47880. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47881. * @param scale defines the overall scale of the skybox
  47882. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47883. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47884. * @returns a new mesh holding the sky box
  47885. */
  47886. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47887. /**
  47888. * Creates a new environment
  47889. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47890. * @param options defines the options you can use to configure the environment
  47891. * @returns the new EnvironmentHelper
  47892. */
  47893. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47894. /**
  47895. * Creates a new VREXperienceHelper
  47896. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47897. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47898. * @returns a new VREXperienceHelper
  47899. */
  47900. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47901. /**
  47902. * Creates a new WebXRDefaultExperience
  47903. * @see http://doc.babylonjs.com/how_to/webxr
  47904. * @param options experience options
  47905. * @returns a promise for a new WebXRDefaultExperience
  47906. */
  47907. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47908. }
  47909. }
  47910. declare module BABYLON {
  47911. /**
  47912. * Contains position and normal vectors for a vertex
  47913. */
  47914. export class PositionNormalVertex {
  47915. /** the position of the vertex (defaut: 0,0,0) */
  47916. position: Vector3;
  47917. /** the normal of the vertex (defaut: 0,1,0) */
  47918. normal: Vector3;
  47919. /**
  47920. * Creates a PositionNormalVertex
  47921. * @param position the position of the vertex (defaut: 0,0,0)
  47922. * @param normal the normal of the vertex (defaut: 0,1,0)
  47923. */
  47924. constructor(
  47925. /** the position of the vertex (defaut: 0,0,0) */
  47926. position?: Vector3,
  47927. /** the normal of the vertex (defaut: 0,1,0) */
  47928. normal?: Vector3);
  47929. /**
  47930. * Clones the PositionNormalVertex
  47931. * @returns the cloned PositionNormalVertex
  47932. */
  47933. clone(): PositionNormalVertex;
  47934. }
  47935. /**
  47936. * Contains position, normal and uv vectors for a vertex
  47937. */
  47938. export class PositionNormalTextureVertex {
  47939. /** the position of the vertex (defaut: 0,0,0) */
  47940. position: Vector3;
  47941. /** the normal of the vertex (defaut: 0,1,0) */
  47942. normal: Vector3;
  47943. /** the uv of the vertex (default: 0,0) */
  47944. uv: Vector2;
  47945. /**
  47946. * Creates a PositionNormalTextureVertex
  47947. * @param position the position of the vertex (defaut: 0,0,0)
  47948. * @param normal the normal of the vertex (defaut: 0,1,0)
  47949. * @param uv the uv of the vertex (default: 0,0)
  47950. */
  47951. constructor(
  47952. /** the position of the vertex (defaut: 0,0,0) */
  47953. position?: Vector3,
  47954. /** the normal of the vertex (defaut: 0,1,0) */
  47955. normal?: Vector3,
  47956. /** the uv of the vertex (default: 0,0) */
  47957. uv?: Vector2);
  47958. /**
  47959. * Clones the PositionNormalTextureVertex
  47960. * @returns the cloned PositionNormalTextureVertex
  47961. */
  47962. clone(): PositionNormalTextureVertex;
  47963. }
  47964. }
  47965. declare module BABYLON {
  47966. /**
  47967. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  47968. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  47969. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  47970. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47971. */
  47972. export class VideoDome extends TransformNode {
  47973. /**
  47974. * Define the video source as a Monoscopic panoramic 360 video.
  47975. */
  47976. static readonly MODE_MONOSCOPIC: number;
  47977. /**
  47978. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47979. */
  47980. static readonly MODE_TOPBOTTOM: number;
  47981. /**
  47982. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47983. */
  47984. static readonly MODE_SIDEBYSIDE: number;
  47985. private _halfDome;
  47986. private _useDirectMapping;
  47987. /**
  47988. * The video texture being displayed on the sphere
  47989. */
  47990. protected _videoTexture: VideoTexture;
  47991. /**
  47992. * Gets the video texture being displayed on the sphere
  47993. */
  47994. readonly videoTexture: VideoTexture;
  47995. /**
  47996. * The skybox material
  47997. */
  47998. protected _material: BackgroundMaterial;
  47999. /**
  48000. * The surface used for the skybox
  48001. */
  48002. protected _mesh: Mesh;
  48003. /**
  48004. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  48005. */
  48006. private _halfDomeMask;
  48007. /**
  48008. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48009. * Also see the options.resolution property.
  48010. */
  48011. fovMultiplier: number;
  48012. private _videoMode;
  48013. /**
  48014. * Gets or set the current video mode for the video. It can be:
  48015. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48016. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48017. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48018. */
  48019. videoMode: number;
  48020. /**
  48021. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  48022. *
  48023. */
  48024. /**
  48025. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  48026. */
  48027. halfDome: boolean;
  48028. /**
  48029. * Oberserver used in Stereoscopic VR Mode.
  48030. */
  48031. private _onBeforeCameraRenderObserver;
  48032. /**
  48033. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48034. * @param name Element's name, child elements will append suffixes for their own names.
  48035. * @param urlsOrVideo defines the url(s) or the video element to use
  48036. * @param options An object containing optional or exposed sub element properties
  48037. */
  48038. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48039. resolution?: number;
  48040. clickToPlay?: boolean;
  48041. autoPlay?: boolean;
  48042. loop?: boolean;
  48043. size?: number;
  48044. poster?: string;
  48045. faceForward?: boolean;
  48046. useDirectMapping?: boolean;
  48047. halfDomeMode?: boolean;
  48048. }, scene: Scene);
  48049. private _changeVideoMode;
  48050. /**
  48051. * Releases resources associated with this node.
  48052. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48053. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48054. */
  48055. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48056. }
  48057. }
  48058. declare module BABYLON {
  48059. /**
  48060. * This class can be used to get instrumentation data from a Babylon engine
  48061. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48062. */
  48063. export class EngineInstrumentation implements IDisposable {
  48064. /**
  48065. * Define the instrumented engine.
  48066. */
  48067. engine: Engine;
  48068. private _captureGPUFrameTime;
  48069. private _gpuFrameTimeToken;
  48070. private _gpuFrameTime;
  48071. private _captureShaderCompilationTime;
  48072. private _shaderCompilationTime;
  48073. private _onBeginFrameObserver;
  48074. private _onEndFrameObserver;
  48075. private _onBeforeShaderCompilationObserver;
  48076. private _onAfterShaderCompilationObserver;
  48077. /**
  48078. * Gets the perf counter used for GPU frame time
  48079. */
  48080. readonly gpuFrameTimeCounter: PerfCounter;
  48081. /**
  48082. * Gets the GPU frame time capture status
  48083. */
  48084. /**
  48085. * Enable or disable the GPU frame time capture
  48086. */
  48087. captureGPUFrameTime: boolean;
  48088. /**
  48089. * Gets the perf counter used for shader compilation time
  48090. */
  48091. readonly shaderCompilationTimeCounter: PerfCounter;
  48092. /**
  48093. * Gets the shader compilation time capture status
  48094. */
  48095. /**
  48096. * Enable or disable the shader compilation time capture
  48097. */
  48098. captureShaderCompilationTime: boolean;
  48099. /**
  48100. * Instantiates a new engine instrumentation.
  48101. * This class can be used to get instrumentation data from a Babylon engine
  48102. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48103. * @param engine Defines the engine to instrument
  48104. */
  48105. constructor(
  48106. /**
  48107. * Define the instrumented engine.
  48108. */
  48109. engine: Engine);
  48110. /**
  48111. * Dispose and release associated resources.
  48112. */
  48113. dispose(): void;
  48114. }
  48115. }
  48116. declare module BABYLON {
  48117. /**
  48118. * This class can be used to get instrumentation data from a Babylon engine
  48119. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48120. */
  48121. export class SceneInstrumentation implements IDisposable {
  48122. /**
  48123. * Defines the scene to instrument
  48124. */
  48125. scene: Scene;
  48126. private _captureActiveMeshesEvaluationTime;
  48127. private _activeMeshesEvaluationTime;
  48128. private _captureRenderTargetsRenderTime;
  48129. private _renderTargetsRenderTime;
  48130. private _captureFrameTime;
  48131. private _frameTime;
  48132. private _captureRenderTime;
  48133. private _renderTime;
  48134. private _captureInterFrameTime;
  48135. private _interFrameTime;
  48136. private _captureParticlesRenderTime;
  48137. private _particlesRenderTime;
  48138. private _captureSpritesRenderTime;
  48139. private _spritesRenderTime;
  48140. private _capturePhysicsTime;
  48141. private _physicsTime;
  48142. private _captureAnimationsTime;
  48143. private _animationsTime;
  48144. private _captureCameraRenderTime;
  48145. private _cameraRenderTime;
  48146. private _onBeforeActiveMeshesEvaluationObserver;
  48147. private _onAfterActiveMeshesEvaluationObserver;
  48148. private _onBeforeRenderTargetsRenderObserver;
  48149. private _onAfterRenderTargetsRenderObserver;
  48150. private _onAfterRenderObserver;
  48151. private _onBeforeDrawPhaseObserver;
  48152. private _onAfterDrawPhaseObserver;
  48153. private _onBeforeAnimationsObserver;
  48154. private _onBeforeParticlesRenderingObserver;
  48155. private _onAfterParticlesRenderingObserver;
  48156. private _onBeforeSpritesRenderingObserver;
  48157. private _onAfterSpritesRenderingObserver;
  48158. private _onBeforePhysicsObserver;
  48159. private _onAfterPhysicsObserver;
  48160. private _onAfterAnimationsObserver;
  48161. private _onBeforeCameraRenderObserver;
  48162. private _onAfterCameraRenderObserver;
  48163. /**
  48164. * Gets the perf counter used for active meshes evaluation time
  48165. */
  48166. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48167. /**
  48168. * Gets the active meshes evaluation time capture status
  48169. */
  48170. /**
  48171. * Enable or disable the active meshes evaluation time capture
  48172. */
  48173. captureActiveMeshesEvaluationTime: boolean;
  48174. /**
  48175. * Gets the perf counter used for render targets render time
  48176. */
  48177. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48178. /**
  48179. * Gets the render targets render time capture status
  48180. */
  48181. /**
  48182. * Enable or disable the render targets render time capture
  48183. */
  48184. captureRenderTargetsRenderTime: boolean;
  48185. /**
  48186. * Gets the perf counter used for particles render time
  48187. */
  48188. readonly particlesRenderTimeCounter: PerfCounter;
  48189. /**
  48190. * Gets the particles render time capture status
  48191. */
  48192. /**
  48193. * Enable or disable the particles render time capture
  48194. */
  48195. captureParticlesRenderTime: boolean;
  48196. /**
  48197. * Gets the perf counter used for sprites render time
  48198. */
  48199. readonly spritesRenderTimeCounter: PerfCounter;
  48200. /**
  48201. * Gets the sprites render time capture status
  48202. */
  48203. /**
  48204. * Enable or disable the sprites render time capture
  48205. */
  48206. captureSpritesRenderTime: boolean;
  48207. /**
  48208. * Gets the perf counter used for physics time
  48209. */
  48210. readonly physicsTimeCounter: PerfCounter;
  48211. /**
  48212. * Gets the physics time capture status
  48213. */
  48214. /**
  48215. * Enable or disable the physics time capture
  48216. */
  48217. capturePhysicsTime: boolean;
  48218. /**
  48219. * Gets the perf counter used for animations time
  48220. */
  48221. readonly animationsTimeCounter: PerfCounter;
  48222. /**
  48223. * Gets the animations time capture status
  48224. */
  48225. /**
  48226. * Enable or disable the animations time capture
  48227. */
  48228. captureAnimationsTime: boolean;
  48229. /**
  48230. * Gets the perf counter used for frame time capture
  48231. */
  48232. readonly frameTimeCounter: PerfCounter;
  48233. /**
  48234. * Gets the frame time capture status
  48235. */
  48236. /**
  48237. * Enable or disable the frame time capture
  48238. */
  48239. captureFrameTime: boolean;
  48240. /**
  48241. * Gets the perf counter used for inter-frames time capture
  48242. */
  48243. readonly interFrameTimeCounter: PerfCounter;
  48244. /**
  48245. * Gets the inter-frames time capture status
  48246. */
  48247. /**
  48248. * Enable or disable the inter-frames time capture
  48249. */
  48250. captureInterFrameTime: boolean;
  48251. /**
  48252. * Gets the perf counter used for render time capture
  48253. */
  48254. readonly renderTimeCounter: PerfCounter;
  48255. /**
  48256. * Gets the render time capture status
  48257. */
  48258. /**
  48259. * Enable or disable the render time capture
  48260. */
  48261. captureRenderTime: boolean;
  48262. /**
  48263. * Gets the perf counter used for camera render time capture
  48264. */
  48265. readonly cameraRenderTimeCounter: PerfCounter;
  48266. /**
  48267. * Gets the camera render time capture status
  48268. */
  48269. /**
  48270. * Enable or disable the camera render time capture
  48271. */
  48272. captureCameraRenderTime: boolean;
  48273. /**
  48274. * Gets the perf counter used for draw calls
  48275. */
  48276. readonly drawCallsCounter: PerfCounter;
  48277. /**
  48278. * Instantiates a new scene instrumentation.
  48279. * This class can be used to get instrumentation data from a Babylon engine
  48280. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48281. * @param scene Defines the scene to instrument
  48282. */
  48283. constructor(
  48284. /**
  48285. * Defines the scene to instrument
  48286. */
  48287. scene: Scene);
  48288. /**
  48289. * Dispose and release associated resources.
  48290. */
  48291. dispose(): void;
  48292. }
  48293. }
  48294. declare module BABYLON {
  48295. /** @hidden */
  48296. export var glowMapGenerationPixelShader: {
  48297. name: string;
  48298. shader: string;
  48299. };
  48300. }
  48301. declare module BABYLON {
  48302. /** @hidden */
  48303. export var glowMapGenerationVertexShader: {
  48304. name: string;
  48305. shader: string;
  48306. };
  48307. }
  48308. declare module BABYLON {
  48309. /**
  48310. * Effect layer options. This helps customizing the behaviour
  48311. * of the effect layer.
  48312. */
  48313. export interface IEffectLayerOptions {
  48314. /**
  48315. * Multiplication factor apply to the canvas size to compute the render target size
  48316. * used to generated the objects (the smaller the faster).
  48317. */
  48318. mainTextureRatio: number;
  48319. /**
  48320. * Enforces a fixed size texture to ensure effect stability across devices.
  48321. */
  48322. mainTextureFixedSize?: number;
  48323. /**
  48324. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48325. */
  48326. alphaBlendingMode: number;
  48327. /**
  48328. * The camera attached to the layer.
  48329. */
  48330. camera: Nullable<Camera>;
  48331. /**
  48332. * The rendering group to draw the layer in.
  48333. */
  48334. renderingGroupId: number;
  48335. }
  48336. /**
  48337. * The effect layer Helps adding post process effect blended with the main pass.
  48338. *
  48339. * This can be for instance use to generate glow or higlight effects on the scene.
  48340. *
  48341. * The effect layer class can not be used directly and is intented to inherited from to be
  48342. * customized per effects.
  48343. */
  48344. export abstract class EffectLayer {
  48345. private _vertexBuffers;
  48346. private _indexBuffer;
  48347. private _cachedDefines;
  48348. private _effectLayerMapGenerationEffect;
  48349. private _effectLayerOptions;
  48350. private _mergeEffect;
  48351. protected _scene: Scene;
  48352. protected _engine: Engine;
  48353. protected _maxSize: number;
  48354. protected _mainTextureDesiredSize: ISize;
  48355. protected _mainTexture: RenderTargetTexture;
  48356. protected _shouldRender: boolean;
  48357. protected _postProcesses: PostProcess[];
  48358. protected _textures: BaseTexture[];
  48359. protected _emissiveTextureAndColor: {
  48360. texture: Nullable<BaseTexture>;
  48361. color: Color4;
  48362. };
  48363. /**
  48364. * The name of the layer
  48365. */
  48366. name: string;
  48367. /**
  48368. * The clear color of the texture used to generate the glow map.
  48369. */
  48370. neutralColor: Color4;
  48371. /**
  48372. * Specifies wether the highlight layer is enabled or not.
  48373. */
  48374. isEnabled: boolean;
  48375. /**
  48376. * Gets the camera attached to the layer.
  48377. */
  48378. readonly camera: Nullable<Camera>;
  48379. /**
  48380. * Gets the rendering group id the layer should render in.
  48381. */
  48382. renderingGroupId: number;
  48383. /**
  48384. * An event triggered when the effect layer has been disposed.
  48385. */
  48386. onDisposeObservable: Observable<EffectLayer>;
  48387. /**
  48388. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48389. */
  48390. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48391. /**
  48392. * An event triggered when the generated texture is being merged in the scene.
  48393. */
  48394. onBeforeComposeObservable: Observable<EffectLayer>;
  48395. /**
  48396. * An event triggered when the generated texture has been merged in the scene.
  48397. */
  48398. onAfterComposeObservable: Observable<EffectLayer>;
  48399. /**
  48400. * An event triggered when the efffect layer changes its size.
  48401. */
  48402. onSizeChangedObservable: Observable<EffectLayer>;
  48403. /** @hidden */
  48404. static _SceneComponentInitialization: (scene: Scene) => void;
  48405. /**
  48406. * Instantiates a new effect Layer and references it in the scene.
  48407. * @param name The name of the layer
  48408. * @param scene The scene to use the layer in
  48409. */
  48410. constructor(
  48411. /** The Friendly of the effect in the scene */
  48412. name: string, scene: Scene);
  48413. /**
  48414. * Get the effect name of the layer.
  48415. * @return The effect name
  48416. */
  48417. abstract getEffectName(): string;
  48418. /**
  48419. * Checks for the readiness of the element composing the layer.
  48420. * @param subMesh the mesh to check for
  48421. * @param useInstances specify wether or not to use instances to render the mesh
  48422. * @return true if ready otherwise, false
  48423. */
  48424. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48425. /**
  48426. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48427. * @returns true if the effect requires stencil during the main canvas render pass.
  48428. */
  48429. abstract needStencil(): boolean;
  48430. /**
  48431. * Create the merge effect. This is the shader use to blit the information back
  48432. * to the main canvas at the end of the scene rendering.
  48433. * @returns The effect containing the shader used to merge the effect on the main canvas
  48434. */
  48435. protected abstract _createMergeEffect(): Effect;
  48436. /**
  48437. * Creates the render target textures and post processes used in the effect layer.
  48438. */
  48439. protected abstract _createTextureAndPostProcesses(): void;
  48440. /**
  48441. * Implementation specific of rendering the generating effect on the main canvas.
  48442. * @param effect The effect used to render through
  48443. */
  48444. protected abstract _internalRender(effect: Effect): void;
  48445. /**
  48446. * Sets the required values for both the emissive texture and and the main color.
  48447. */
  48448. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48449. /**
  48450. * Free any resources and references associated to a mesh.
  48451. * Internal use
  48452. * @param mesh The mesh to free.
  48453. */
  48454. abstract _disposeMesh(mesh: Mesh): void;
  48455. /**
  48456. * Serializes this layer (Glow or Highlight for example)
  48457. * @returns a serialized layer object
  48458. */
  48459. abstract serialize?(): any;
  48460. /**
  48461. * Initializes the effect layer with the required options.
  48462. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48463. */
  48464. protected _init(options: Partial<IEffectLayerOptions>): void;
  48465. /**
  48466. * Generates the index buffer of the full screen quad blending to the main canvas.
  48467. */
  48468. private _generateIndexBuffer;
  48469. /**
  48470. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48471. */
  48472. private _generateVertexBuffer;
  48473. /**
  48474. * Sets the main texture desired size which is the closest power of two
  48475. * of the engine canvas size.
  48476. */
  48477. private _setMainTextureSize;
  48478. /**
  48479. * Creates the main texture for the effect layer.
  48480. */
  48481. protected _createMainTexture(): void;
  48482. /**
  48483. * Adds specific effects defines.
  48484. * @param defines The defines to add specifics to.
  48485. */
  48486. protected _addCustomEffectDefines(defines: string[]): void;
  48487. /**
  48488. * Checks for the readiness of the element composing the layer.
  48489. * @param subMesh the mesh to check for
  48490. * @param useInstances specify wether or not to use instances to render the mesh
  48491. * @param emissiveTexture the associated emissive texture used to generate the glow
  48492. * @return true if ready otherwise, false
  48493. */
  48494. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48495. /**
  48496. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48497. */
  48498. render(): void;
  48499. /**
  48500. * Determine if a given mesh will be used in the current effect.
  48501. * @param mesh mesh to test
  48502. * @returns true if the mesh will be used
  48503. */
  48504. hasMesh(mesh: AbstractMesh): boolean;
  48505. /**
  48506. * Returns true if the layer contains information to display, otherwise false.
  48507. * @returns true if the glow layer should be rendered
  48508. */
  48509. shouldRender(): boolean;
  48510. /**
  48511. * Returns true if the mesh should render, otherwise false.
  48512. * @param mesh The mesh to render
  48513. * @returns true if it should render otherwise false
  48514. */
  48515. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48516. /**
  48517. * Returns true if the mesh can be rendered, otherwise false.
  48518. * @param mesh The mesh to render
  48519. * @param material The material used on the mesh
  48520. * @returns true if it can be rendered otherwise false
  48521. */
  48522. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48523. /**
  48524. * Returns true if the mesh should render, otherwise false.
  48525. * @param mesh The mesh to render
  48526. * @returns true if it should render otherwise false
  48527. */
  48528. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48529. /**
  48530. * Renders the submesh passed in parameter to the generation map.
  48531. */
  48532. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  48533. /**
  48534. * Rebuild the required buffers.
  48535. * @hidden Internal use only.
  48536. */
  48537. _rebuild(): void;
  48538. /**
  48539. * Dispose only the render target textures and post process.
  48540. */
  48541. private _disposeTextureAndPostProcesses;
  48542. /**
  48543. * Dispose the highlight layer and free resources.
  48544. */
  48545. dispose(): void;
  48546. /**
  48547. * Gets the class name of the effect layer
  48548. * @returns the string with the class name of the effect layer
  48549. */
  48550. getClassName(): string;
  48551. /**
  48552. * Creates an effect layer from parsed effect layer data
  48553. * @param parsedEffectLayer defines effect layer data
  48554. * @param scene defines the current scene
  48555. * @param rootUrl defines the root URL containing the effect layer information
  48556. * @returns a parsed effect Layer
  48557. */
  48558. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48559. }
  48560. }
  48561. declare module BABYLON {
  48562. interface AbstractScene {
  48563. /**
  48564. * The list of effect layers (highlights/glow) added to the scene
  48565. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48566. * @see http://doc.babylonjs.com/how_to/glow_layer
  48567. */
  48568. effectLayers: Array<EffectLayer>;
  48569. /**
  48570. * Removes the given effect layer from this scene.
  48571. * @param toRemove defines the effect layer to remove
  48572. * @returns the index of the removed effect layer
  48573. */
  48574. removeEffectLayer(toRemove: EffectLayer): number;
  48575. /**
  48576. * Adds the given effect layer to this scene
  48577. * @param newEffectLayer defines the effect layer to add
  48578. */
  48579. addEffectLayer(newEffectLayer: EffectLayer): void;
  48580. }
  48581. /**
  48582. * Defines the layer scene component responsible to manage any effect layers
  48583. * in a given scene.
  48584. */
  48585. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48586. /**
  48587. * The component name helpfull to identify the component in the list of scene components.
  48588. */
  48589. readonly name: string;
  48590. /**
  48591. * The scene the component belongs to.
  48592. */
  48593. scene: Scene;
  48594. private _engine;
  48595. private _renderEffects;
  48596. private _needStencil;
  48597. private _previousStencilState;
  48598. /**
  48599. * Creates a new instance of the component for the given scene
  48600. * @param scene Defines the scene to register the component in
  48601. */
  48602. constructor(scene: Scene);
  48603. /**
  48604. * Registers the component in a given scene
  48605. */
  48606. register(): void;
  48607. /**
  48608. * Rebuilds the elements related to this component in case of
  48609. * context lost for instance.
  48610. */
  48611. rebuild(): void;
  48612. /**
  48613. * Serializes the component data to the specified json object
  48614. * @param serializationObject The object to serialize to
  48615. */
  48616. serialize(serializationObject: any): void;
  48617. /**
  48618. * Adds all the elements from the container to the scene
  48619. * @param container the container holding the elements
  48620. */
  48621. addFromContainer(container: AbstractScene): void;
  48622. /**
  48623. * Removes all the elements in the container from the scene
  48624. * @param container contains the elements to remove
  48625. * @param dispose if the removed element should be disposed (default: false)
  48626. */
  48627. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48628. /**
  48629. * Disposes the component and the associated ressources.
  48630. */
  48631. dispose(): void;
  48632. private _isReadyForMesh;
  48633. private _renderMainTexture;
  48634. private _setStencil;
  48635. private _setStencilBack;
  48636. private _draw;
  48637. private _drawCamera;
  48638. private _drawRenderingGroup;
  48639. }
  48640. }
  48641. declare module BABYLON {
  48642. /** @hidden */
  48643. export var glowMapMergePixelShader: {
  48644. name: string;
  48645. shader: string;
  48646. };
  48647. }
  48648. declare module BABYLON {
  48649. /** @hidden */
  48650. export var glowMapMergeVertexShader: {
  48651. name: string;
  48652. shader: string;
  48653. };
  48654. }
  48655. declare module BABYLON {
  48656. interface AbstractScene {
  48657. /**
  48658. * Return a the first highlight layer of the scene with a given name.
  48659. * @param name The name of the highlight layer to look for.
  48660. * @return The highlight layer if found otherwise null.
  48661. */
  48662. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  48663. }
  48664. /**
  48665. * Glow layer options. This helps customizing the behaviour
  48666. * of the glow layer.
  48667. */
  48668. export interface IGlowLayerOptions {
  48669. /**
  48670. * Multiplication factor apply to the canvas size to compute the render target size
  48671. * used to generated the glowing objects (the smaller the faster).
  48672. */
  48673. mainTextureRatio: number;
  48674. /**
  48675. * Enforces a fixed size texture to ensure resize independant blur.
  48676. */
  48677. mainTextureFixedSize?: number;
  48678. /**
  48679. * How big is the kernel of the blur texture.
  48680. */
  48681. blurKernelSize: number;
  48682. /**
  48683. * The camera attached to the layer.
  48684. */
  48685. camera: Nullable<Camera>;
  48686. /**
  48687. * Enable MSAA by chosing the number of samples.
  48688. */
  48689. mainTextureSamples?: number;
  48690. /**
  48691. * The rendering group to draw the layer in.
  48692. */
  48693. renderingGroupId: number;
  48694. }
  48695. /**
  48696. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  48697. *
  48698. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48699. * glowy meshes to your scene.
  48700. *
  48701. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  48702. */
  48703. export class GlowLayer extends EffectLayer {
  48704. /**
  48705. * Effect Name of the layer.
  48706. */
  48707. static readonly EffectName: string;
  48708. /**
  48709. * The default blur kernel size used for the glow.
  48710. */
  48711. static DefaultBlurKernelSize: number;
  48712. /**
  48713. * The default texture size ratio used for the glow.
  48714. */
  48715. static DefaultTextureRatio: number;
  48716. /**
  48717. * Sets the kernel size of the blur.
  48718. */
  48719. /**
  48720. * Gets the kernel size of the blur.
  48721. */
  48722. blurKernelSize: number;
  48723. /**
  48724. * Sets the glow intensity.
  48725. */
  48726. /**
  48727. * Gets the glow intensity.
  48728. */
  48729. intensity: number;
  48730. private _options;
  48731. private _intensity;
  48732. private _horizontalBlurPostprocess1;
  48733. private _verticalBlurPostprocess1;
  48734. private _horizontalBlurPostprocess2;
  48735. private _verticalBlurPostprocess2;
  48736. private _blurTexture1;
  48737. private _blurTexture2;
  48738. private _postProcesses1;
  48739. private _postProcesses2;
  48740. private _includedOnlyMeshes;
  48741. private _excludedMeshes;
  48742. /**
  48743. * Callback used to let the user override the color selection on a per mesh basis
  48744. */
  48745. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  48746. /**
  48747. * Callback used to let the user override the texture selection on a per mesh basis
  48748. */
  48749. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  48750. /**
  48751. * Instantiates a new glow Layer and references it to the scene.
  48752. * @param name The name of the layer
  48753. * @param scene The scene to use the layer in
  48754. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  48755. */
  48756. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  48757. /**
  48758. * Get the effect name of the layer.
  48759. * @return The effect name
  48760. */
  48761. getEffectName(): string;
  48762. /**
  48763. * Create the merge effect. This is the shader use to blit the information back
  48764. * to the main canvas at the end of the scene rendering.
  48765. */
  48766. protected _createMergeEffect(): Effect;
  48767. /**
  48768. * Creates the render target textures and post processes used in the glow layer.
  48769. */
  48770. protected _createTextureAndPostProcesses(): void;
  48771. /**
  48772. * Checks for the readiness of the element composing the layer.
  48773. * @param subMesh the mesh to check for
  48774. * @param useInstances specify wether or not to use instances to render the mesh
  48775. * @param emissiveTexture the associated emissive texture used to generate the glow
  48776. * @return true if ready otherwise, false
  48777. */
  48778. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48779. /**
  48780. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48781. */
  48782. needStencil(): boolean;
  48783. /**
  48784. * Returns true if the mesh can be rendered, otherwise false.
  48785. * @param mesh The mesh to render
  48786. * @param material The material used on the mesh
  48787. * @returns true if it can be rendered otherwise false
  48788. */
  48789. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48790. /**
  48791. * Implementation specific of rendering the generating effect on the main canvas.
  48792. * @param effect The effect used to render through
  48793. */
  48794. protected _internalRender(effect: Effect): void;
  48795. /**
  48796. * Sets the required values for both the emissive texture and and the main color.
  48797. */
  48798. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48799. /**
  48800. * Returns true if the mesh should render, otherwise false.
  48801. * @param mesh The mesh to render
  48802. * @returns true if it should render otherwise false
  48803. */
  48804. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48805. /**
  48806. * Adds specific effects defines.
  48807. * @param defines The defines to add specifics to.
  48808. */
  48809. protected _addCustomEffectDefines(defines: string[]): void;
  48810. /**
  48811. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  48812. * @param mesh The mesh to exclude from the glow layer
  48813. */
  48814. addExcludedMesh(mesh: Mesh): void;
  48815. /**
  48816. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  48817. * @param mesh The mesh to remove
  48818. */
  48819. removeExcludedMesh(mesh: Mesh): void;
  48820. /**
  48821. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  48822. * @param mesh The mesh to include in the glow layer
  48823. */
  48824. addIncludedOnlyMesh(mesh: Mesh): void;
  48825. /**
  48826. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  48827. * @param mesh The mesh to remove
  48828. */
  48829. removeIncludedOnlyMesh(mesh: Mesh): void;
  48830. /**
  48831. * Determine if a given mesh will be used in the glow layer
  48832. * @param mesh The mesh to test
  48833. * @returns true if the mesh will be highlighted by the current glow layer
  48834. */
  48835. hasMesh(mesh: AbstractMesh): boolean;
  48836. /**
  48837. * Free any resources and references associated to a mesh.
  48838. * Internal use
  48839. * @param mesh The mesh to free.
  48840. * @hidden
  48841. */
  48842. _disposeMesh(mesh: Mesh): void;
  48843. /**
  48844. * Gets the class name of the effect layer
  48845. * @returns the string with the class name of the effect layer
  48846. */
  48847. getClassName(): string;
  48848. /**
  48849. * Serializes this glow layer
  48850. * @returns a serialized glow layer object
  48851. */
  48852. serialize(): any;
  48853. /**
  48854. * Creates a Glow Layer from parsed glow layer data
  48855. * @param parsedGlowLayer defines glow layer data
  48856. * @param scene defines the current scene
  48857. * @param rootUrl defines the root URL containing the glow layer information
  48858. * @returns a parsed Glow Layer
  48859. */
  48860. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48861. }
  48862. }
  48863. declare module BABYLON {
  48864. /** @hidden */
  48865. export var glowBlurPostProcessPixelShader: {
  48866. name: string;
  48867. shader: string;
  48868. };
  48869. }
  48870. declare module BABYLON {
  48871. interface AbstractScene {
  48872. /**
  48873. * Return a the first highlight layer of the scene with a given name.
  48874. * @param name The name of the highlight layer to look for.
  48875. * @return The highlight layer if found otherwise null.
  48876. */
  48877. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48878. }
  48879. /**
  48880. * Highlight layer options. This helps customizing the behaviour
  48881. * of the highlight layer.
  48882. */
  48883. export interface IHighlightLayerOptions {
  48884. /**
  48885. * Multiplication factor apply to the canvas size to compute the render target size
  48886. * used to generated the glowing objects (the smaller the faster).
  48887. */
  48888. mainTextureRatio: number;
  48889. /**
  48890. * Enforces a fixed size texture to ensure resize independant blur.
  48891. */
  48892. mainTextureFixedSize?: number;
  48893. /**
  48894. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48895. * of the picture to blur (the smaller the faster).
  48896. */
  48897. blurTextureSizeRatio: number;
  48898. /**
  48899. * How big in texel of the blur texture is the vertical blur.
  48900. */
  48901. blurVerticalSize: number;
  48902. /**
  48903. * How big in texel of the blur texture is the horizontal blur.
  48904. */
  48905. blurHorizontalSize: number;
  48906. /**
  48907. * Alpha blending mode used to apply the blur. Default is combine.
  48908. */
  48909. alphaBlendingMode: number;
  48910. /**
  48911. * The camera attached to the layer.
  48912. */
  48913. camera: Nullable<Camera>;
  48914. /**
  48915. * Should we display highlight as a solid stroke?
  48916. */
  48917. isStroke?: boolean;
  48918. /**
  48919. * The rendering group to draw the layer in.
  48920. */
  48921. renderingGroupId: number;
  48922. }
  48923. /**
  48924. * The highlight layer Helps adding a glow effect around a mesh.
  48925. *
  48926. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48927. * glowy meshes to your scene.
  48928. *
  48929. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48930. */
  48931. export class HighlightLayer extends EffectLayer {
  48932. name: string;
  48933. /**
  48934. * Effect Name of the highlight layer.
  48935. */
  48936. static readonly EffectName: string;
  48937. /**
  48938. * The neutral color used during the preparation of the glow effect.
  48939. * This is black by default as the blend operation is a blend operation.
  48940. */
  48941. static NeutralColor: Color4;
  48942. /**
  48943. * Stencil value used for glowing meshes.
  48944. */
  48945. static GlowingMeshStencilReference: number;
  48946. /**
  48947. * Stencil value used for the other meshes in the scene.
  48948. */
  48949. static NormalMeshStencilReference: number;
  48950. /**
  48951. * Specifies whether or not the inner glow is ACTIVE in the layer.
  48952. */
  48953. innerGlow: boolean;
  48954. /**
  48955. * Specifies whether or not the outer glow is ACTIVE in the layer.
  48956. */
  48957. outerGlow: boolean;
  48958. /**
  48959. * Specifies the horizontal size of the blur.
  48960. */
  48961. /**
  48962. * Gets the horizontal size of the blur.
  48963. */
  48964. blurHorizontalSize: number;
  48965. /**
  48966. * Specifies the vertical size of the blur.
  48967. */
  48968. /**
  48969. * Gets the vertical size of the blur.
  48970. */
  48971. blurVerticalSize: number;
  48972. /**
  48973. * An event triggered when the highlight layer is being blurred.
  48974. */
  48975. onBeforeBlurObservable: Observable<HighlightLayer>;
  48976. /**
  48977. * An event triggered when the highlight layer has been blurred.
  48978. */
  48979. onAfterBlurObservable: Observable<HighlightLayer>;
  48980. private _instanceGlowingMeshStencilReference;
  48981. private _options;
  48982. private _downSamplePostprocess;
  48983. private _horizontalBlurPostprocess;
  48984. private _verticalBlurPostprocess;
  48985. private _blurTexture;
  48986. private _meshes;
  48987. private _excludedMeshes;
  48988. /**
  48989. * Instantiates a new highlight Layer and references it to the scene..
  48990. * @param name The name of the layer
  48991. * @param scene The scene to use the layer in
  48992. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  48993. */
  48994. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  48995. /**
  48996. * Get the effect name of the layer.
  48997. * @return The effect name
  48998. */
  48999. getEffectName(): string;
  49000. /**
  49001. * Create the merge effect. This is the shader use to blit the information back
  49002. * to the main canvas at the end of the scene rendering.
  49003. */
  49004. protected _createMergeEffect(): Effect;
  49005. /**
  49006. * Creates the render target textures and post processes used in the highlight layer.
  49007. */
  49008. protected _createTextureAndPostProcesses(): void;
  49009. /**
  49010. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49011. */
  49012. needStencil(): boolean;
  49013. /**
  49014. * Checks for the readiness of the element composing the layer.
  49015. * @param subMesh the mesh to check for
  49016. * @param useInstances specify wether or not to use instances to render the mesh
  49017. * @param emissiveTexture the associated emissive texture used to generate the glow
  49018. * @return true if ready otherwise, false
  49019. */
  49020. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49021. /**
  49022. * Implementation specific of rendering the generating effect on the main canvas.
  49023. * @param effect The effect used to render through
  49024. */
  49025. protected _internalRender(effect: Effect): void;
  49026. /**
  49027. * Returns true if the layer contains information to display, otherwise false.
  49028. */
  49029. shouldRender(): boolean;
  49030. /**
  49031. * Returns true if the mesh should render, otherwise false.
  49032. * @param mesh The mesh to render
  49033. * @returns true if it should render otherwise false
  49034. */
  49035. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49036. /**
  49037. * Sets the required values for both the emissive texture and and the main color.
  49038. */
  49039. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49040. /**
  49041. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49042. * @param mesh The mesh to exclude from the highlight layer
  49043. */
  49044. addExcludedMesh(mesh: Mesh): void;
  49045. /**
  49046. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49047. * @param mesh The mesh to highlight
  49048. */
  49049. removeExcludedMesh(mesh: Mesh): void;
  49050. /**
  49051. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49052. * @param mesh mesh to test
  49053. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49054. */
  49055. hasMesh(mesh: AbstractMesh): boolean;
  49056. /**
  49057. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49058. * @param mesh The mesh to highlight
  49059. * @param color The color of the highlight
  49060. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49061. */
  49062. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49063. /**
  49064. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49065. * @param mesh The mesh to highlight
  49066. */
  49067. removeMesh(mesh: Mesh): void;
  49068. /**
  49069. * Force the stencil to the normal expected value for none glowing parts
  49070. */
  49071. private _defaultStencilReference;
  49072. /**
  49073. * Free any resources and references associated to a mesh.
  49074. * Internal use
  49075. * @param mesh The mesh to free.
  49076. * @hidden
  49077. */
  49078. _disposeMesh(mesh: Mesh): void;
  49079. /**
  49080. * Dispose the highlight layer and free resources.
  49081. */
  49082. dispose(): void;
  49083. /**
  49084. * Gets the class name of the effect layer
  49085. * @returns the string with the class name of the effect layer
  49086. */
  49087. getClassName(): string;
  49088. /**
  49089. * Serializes this Highlight layer
  49090. * @returns a serialized Highlight layer object
  49091. */
  49092. serialize(): any;
  49093. /**
  49094. * Creates a Highlight layer from parsed Highlight layer data
  49095. * @param parsedHightlightLayer defines the Highlight layer data
  49096. * @param scene defines the current scene
  49097. * @param rootUrl defines the root URL containing the Highlight layer information
  49098. * @returns a parsed Highlight layer
  49099. */
  49100. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49101. }
  49102. }
  49103. declare module BABYLON {
  49104. interface AbstractScene {
  49105. /**
  49106. * The list of layers (background and foreground) of the scene
  49107. */
  49108. layers: Array<Layer>;
  49109. }
  49110. /**
  49111. * Defines the layer scene component responsible to manage any layers
  49112. * in a given scene.
  49113. */
  49114. export class LayerSceneComponent implements ISceneComponent {
  49115. /**
  49116. * The component name helpfull to identify the component in the list of scene components.
  49117. */
  49118. readonly name: string;
  49119. /**
  49120. * The scene the component belongs to.
  49121. */
  49122. scene: Scene;
  49123. private _engine;
  49124. /**
  49125. * Creates a new instance of the component for the given scene
  49126. * @param scene Defines the scene to register the component in
  49127. */
  49128. constructor(scene: Scene);
  49129. /**
  49130. * Registers the component in a given scene
  49131. */
  49132. register(): void;
  49133. /**
  49134. * Rebuilds the elements related to this component in case of
  49135. * context lost for instance.
  49136. */
  49137. rebuild(): void;
  49138. /**
  49139. * Disposes the component and the associated ressources.
  49140. */
  49141. dispose(): void;
  49142. private _draw;
  49143. private _drawCameraPredicate;
  49144. private _drawCameraBackground;
  49145. private _drawCameraForeground;
  49146. private _drawRenderTargetPredicate;
  49147. private _drawRenderTargetBackground;
  49148. private _drawRenderTargetForeground;
  49149. /**
  49150. * Adds all the elements from the container to the scene
  49151. * @param container the container holding the elements
  49152. */
  49153. addFromContainer(container: AbstractScene): void;
  49154. /**
  49155. * Removes all the elements in the container from the scene
  49156. * @param container contains the elements to remove
  49157. * @param dispose if the removed element should be disposed (default: false)
  49158. */
  49159. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49160. }
  49161. }
  49162. declare module BABYLON {
  49163. /** @hidden */
  49164. export var layerPixelShader: {
  49165. name: string;
  49166. shader: string;
  49167. };
  49168. }
  49169. declare module BABYLON {
  49170. /** @hidden */
  49171. export var layerVertexShader: {
  49172. name: string;
  49173. shader: string;
  49174. };
  49175. }
  49176. declare module BABYLON {
  49177. /**
  49178. * This represents a full screen 2d layer.
  49179. * This can be useful to display a picture in the background of your scene for instance.
  49180. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49181. */
  49182. export class Layer {
  49183. /**
  49184. * Define the name of the layer.
  49185. */
  49186. name: string;
  49187. /**
  49188. * Define the texture the layer should display.
  49189. */
  49190. texture: Nullable<Texture>;
  49191. /**
  49192. * Is the layer in background or foreground.
  49193. */
  49194. isBackground: boolean;
  49195. /**
  49196. * Define the color of the layer (instead of texture).
  49197. */
  49198. color: Color4;
  49199. /**
  49200. * Define the scale of the layer in order to zoom in out of the texture.
  49201. */
  49202. scale: Vector2;
  49203. /**
  49204. * Define an offset for the layer in order to shift the texture.
  49205. */
  49206. offset: Vector2;
  49207. /**
  49208. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  49209. */
  49210. alphaBlendingMode: number;
  49211. /**
  49212. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  49213. * Alpha test will not mix with the background color in case of transparency.
  49214. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  49215. */
  49216. alphaTest: boolean;
  49217. /**
  49218. * Define a mask to restrict the layer to only some of the scene cameras.
  49219. */
  49220. layerMask: number;
  49221. /**
  49222. * Define the list of render target the layer is visible into.
  49223. */
  49224. renderTargetTextures: RenderTargetTexture[];
  49225. /**
  49226. * Define if the layer is only used in renderTarget or if it also
  49227. * renders in the main frame buffer of the canvas.
  49228. */
  49229. renderOnlyInRenderTargetTextures: boolean;
  49230. private _scene;
  49231. private _vertexBuffers;
  49232. private _indexBuffer;
  49233. private _effect;
  49234. private _alphaTestEffect;
  49235. /**
  49236. * An event triggered when the layer is disposed.
  49237. */
  49238. onDisposeObservable: Observable<Layer>;
  49239. private _onDisposeObserver;
  49240. /**
  49241. * Back compatibility with callback before the onDisposeObservable existed.
  49242. * The set callback will be triggered when the layer has been disposed.
  49243. */
  49244. onDispose: () => void;
  49245. /**
  49246. * An event triggered before rendering the scene
  49247. */
  49248. onBeforeRenderObservable: Observable<Layer>;
  49249. private _onBeforeRenderObserver;
  49250. /**
  49251. * Back compatibility with callback before the onBeforeRenderObservable existed.
  49252. * The set callback will be triggered just before rendering the layer.
  49253. */
  49254. onBeforeRender: () => void;
  49255. /**
  49256. * An event triggered after rendering the scene
  49257. */
  49258. onAfterRenderObservable: Observable<Layer>;
  49259. private _onAfterRenderObserver;
  49260. /**
  49261. * Back compatibility with callback before the onAfterRenderObservable existed.
  49262. * The set callback will be triggered just after rendering the layer.
  49263. */
  49264. onAfterRender: () => void;
  49265. /**
  49266. * Instantiates a new layer.
  49267. * This represents a full screen 2d layer.
  49268. * This can be useful to display a picture in the background of your scene for instance.
  49269. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49270. * @param name Define the name of the layer in the scene
  49271. * @param imgUrl Define the url of the texture to display in the layer
  49272. * @param scene Define the scene the layer belongs to
  49273. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  49274. * @param color Defines a color for the layer
  49275. */
  49276. constructor(
  49277. /**
  49278. * Define the name of the layer.
  49279. */
  49280. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  49281. private _createIndexBuffer;
  49282. /** @hidden */
  49283. _rebuild(): void;
  49284. /**
  49285. * Renders the layer in the scene.
  49286. */
  49287. render(): void;
  49288. /**
  49289. * Disposes and releases the associated ressources.
  49290. */
  49291. dispose(): void;
  49292. }
  49293. }
  49294. declare module BABYLON {
  49295. /** @hidden */
  49296. export var lensFlarePixelShader: {
  49297. name: string;
  49298. shader: string;
  49299. };
  49300. }
  49301. declare module BABYLON {
  49302. /** @hidden */
  49303. export var lensFlareVertexShader: {
  49304. name: string;
  49305. shader: string;
  49306. };
  49307. }
  49308. declare module BABYLON {
  49309. /**
  49310. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49311. * It is usually composed of several `lensFlare`.
  49312. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49313. */
  49314. export class LensFlareSystem {
  49315. /**
  49316. * Define the name of the lens flare system
  49317. */
  49318. name: string;
  49319. /**
  49320. * List of lens flares used in this system.
  49321. */
  49322. lensFlares: LensFlare[];
  49323. /**
  49324. * Define a limit from the border the lens flare can be visible.
  49325. */
  49326. borderLimit: number;
  49327. /**
  49328. * Define a viewport border we do not want to see the lens flare in.
  49329. */
  49330. viewportBorder: number;
  49331. /**
  49332. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49333. */
  49334. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49335. /**
  49336. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49337. */
  49338. layerMask: number;
  49339. /**
  49340. * Define the id of the lens flare system in the scene.
  49341. * (equal to name by default)
  49342. */
  49343. id: string;
  49344. private _scene;
  49345. private _emitter;
  49346. private _vertexBuffers;
  49347. private _indexBuffer;
  49348. private _effect;
  49349. private _positionX;
  49350. private _positionY;
  49351. private _isEnabled;
  49352. /** @hidden */
  49353. static _SceneComponentInitialization: (scene: Scene) => void;
  49354. /**
  49355. * Instantiates a lens flare system.
  49356. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49357. * It is usually composed of several `lensFlare`.
  49358. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49359. * @param name Define the name of the lens flare system in the scene
  49360. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49361. * @param scene Define the scene the lens flare system belongs to
  49362. */
  49363. constructor(
  49364. /**
  49365. * Define the name of the lens flare system
  49366. */
  49367. name: string, emitter: any, scene: Scene);
  49368. /**
  49369. * Define if the lens flare system is enabled.
  49370. */
  49371. isEnabled: boolean;
  49372. /**
  49373. * Get the scene the effects belongs to.
  49374. * @returns the scene holding the lens flare system
  49375. */
  49376. getScene(): Scene;
  49377. /**
  49378. * Get the emitter of the lens flare system.
  49379. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49380. * @returns the emitter of the lens flare system
  49381. */
  49382. getEmitter(): any;
  49383. /**
  49384. * Set the emitter of the lens flare system.
  49385. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49386. * @param newEmitter Define the new emitter of the system
  49387. */
  49388. setEmitter(newEmitter: any): void;
  49389. /**
  49390. * Get the lens flare system emitter position.
  49391. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49392. * @returns the position
  49393. */
  49394. getEmitterPosition(): Vector3;
  49395. /**
  49396. * @hidden
  49397. */
  49398. computeEffectivePosition(globalViewport: Viewport): boolean;
  49399. /** @hidden */
  49400. _isVisible(): boolean;
  49401. /**
  49402. * @hidden
  49403. */
  49404. render(): boolean;
  49405. /**
  49406. * Dispose and release the lens flare with its associated resources.
  49407. */
  49408. dispose(): void;
  49409. /**
  49410. * Parse a lens flare system from a JSON repressentation
  49411. * @param parsedLensFlareSystem Define the JSON to parse
  49412. * @param scene Define the scene the parsed system should be instantiated in
  49413. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49414. * @returns the parsed system
  49415. */
  49416. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49417. /**
  49418. * Serialize the current Lens Flare System into a JSON representation.
  49419. * @returns the serialized JSON
  49420. */
  49421. serialize(): any;
  49422. }
  49423. }
  49424. declare module BABYLON {
  49425. /**
  49426. * This represents one of the lens effect in a `lensFlareSystem`.
  49427. * It controls one of the indiviual texture used in the effect.
  49428. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49429. */
  49430. export class LensFlare {
  49431. /**
  49432. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49433. */
  49434. size: number;
  49435. /**
  49436. * 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.
  49437. */
  49438. position: number;
  49439. /**
  49440. * Define the lens color.
  49441. */
  49442. color: Color3;
  49443. /**
  49444. * Define the lens texture.
  49445. */
  49446. texture: Nullable<Texture>;
  49447. /**
  49448. * Define the alpha mode to render this particular lens.
  49449. */
  49450. alphaMode: number;
  49451. private _system;
  49452. /**
  49453. * Creates a new Lens Flare.
  49454. * This represents one of the lens effect in a `lensFlareSystem`.
  49455. * It controls one of the indiviual texture used in the effect.
  49456. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49457. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49458. * @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.
  49459. * @param color Define the lens color
  49460. * @param imgUrl Define the lens texture url
  49461. * @param system Define the `lensFlareSystem` this flare is part of
  49462. * @returns The newly created Lens Flare
  49463. */
  49464. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49465. /**
  49466. * Instantiates a new Lens Flare.
  49467. * This represents one of the lens effect in a `lensFlareSystem`.
  49468. * It controls one of the indiviual texture used in the effect.
  49469. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49470. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49471. * @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.
  49472. * @param color Define the lens color
  49473. * @param imgUrl Define the lens texture url
  49474. * @param system Define the `lensFlareSystem` this flare is part of
  49475. */
  49476. constructor(
  49477. /**
  49478. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49479. */
  49480. size: number,
  49481. /**
  49482. * 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.
  49483. */
  49484. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49485. /**
  49486. * Dispose and release the lens flare with its associated resources.
  49487. */
  49488. dispose(): void;
  49489. }
  49490. }
  49491. declare module BABYLON {
  49492. interface AbstractScene {
  49493. /**
  49494. * The list of lens flare system added to the scene
  49495. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49496. */
  49497. lensFlareSystems: Array<LensFlareSystem>;
  49498. /**
  49499. * Removes the given lens flare system from this scene.
  49500. * @param toRemove The lens flare system to remove
  49501. * @returns The index of the removed lens flare system
  49502. */
  49503. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49504. /**
  49505. * Adds the given lens flare system to this scene
  49506. * @param newLensFlareSystem The lens flare system to add
  49507. */
  49508. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49509. /**
  49510. * Gets a lens flare system using its name
  49511. * @param name defines the name to look for
  49512. * @returns the lens flare system or null if not found
  49513. */
  49514. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49515. /**
  49516. * Gets a lens flare system using its id
  49517. * @param id defines the id to look for
  49518. * @returns the lens flare system or null if not found
  49519. */
  49520. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49521. }
  49522. /**
  49523. * Defines the lens flare scene component responsible to manage any lens flares
  49524. * in a given scene.
  49525. */
  49526. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49527. /**
  49528. * The component name helpfull to identify the component in the list of scene components.
  49529. */
  49530. readonly name: string;
  49531. /**
  49532. * The scene the component belongs to.
  49533. */
  49534. scene: Scene;
  49535. /**
  49536. * Creates a new instance of the component for the given scene
  49537. * @param scene Defines the scene to register the component in
  49538. */
  49539. constructor(scene: Scene);
  49540. /**
  49541. * Registers the component in a given scene
  49542. */
  49543. register(): void;
  49544. /**
  49545. * Rebuilds the elements related to this component in case of
  49546. * context lost for instance.
  49547. */
  49548. rebuild(): void;
  49549. /**
  49550. * Adds all the elements from the container to the scene
  49551. * @param container the container holding the elements
  49552. */
  49553. addFromContainer(container: AbstractScene): void;
  49554. /**
  49555. * Removes all the elements in the container from the scene
  49556. * @param container contains the elements to remove
  49557. * @param dispose if the removed element should be disposed (default: false)
  49558. */
  49559. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49560. /**
  49561. * Serializes the component data to the specified json object
  49562. * @param serializationObject The object to serialize to
  49563. */
  49564. serialize(serializationObject: any): void;
  49565. /**
  49566. * Disposes the component and the associated ressources.
  49567. */
  49568. dispose(): void;
  49569. private _draw;
  49570. }
  49571. }
  49572. declare module BABYLON {
  49573. /**
  49574. * Defines the shadow generator component responsible to manage any shadow generators
  49575. * in a given scene.
  49576. */
  49577. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49578. /**
  49579. * The component name helpfull to identify the component in the list of scene components.
  49580. */
  49581. readonly name: string;
  49582. /**
  49583. * The scene the component belongs to.
  49584. */
  49585. scene: Scene;
  49586. /**
  49587. * Creates a new instance of the component for the given scene
  49588. * @param scene Defines the scene to register the component in
  49589. */
  49590. constructor(scene: Scene);
  49591. /**
  49592. * Registers the component in a given scene
  49593. */
  49594. register(): void;
  49595. /**
  49596. * Rebuilds the elements related to this component in case of
  49597. * context lost for instance.
  49598. */
  49599. rebuild(): void;
  49600. /**
  49601. * Serializes the component data to the specified json object
  49602. * @param serializationObject The object to serialize to
  49603. */
  49604. serialize(serializationObject: any): void;
  49605. /**
  49606. * Adds all the elements from the container to the scene
  49607. * @param container the container holding the elements
  49608. */
  49609. addFromContainer(container: AbstractScene): void;
  49610. /**
  49611. * Removes all the elements in the container from the scene
  49612. * @param container contains the elements to remove
  49613. * @param dispose if the removed element should be disposed (default: false)
  49614. */
  49615. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49616. /**
  49617. * Rebuilds the elements related to this component in case of
  49618. * context lost for instance.
  49619. */
  49620. dispose(): void;
  49621. private _gatherRenderTargets;
  49622. }
  49623. }
  49624. declare module BABYLON {
  49625. /**
  49626. * A point light is a light defined by an unique point in world space.
  49627. * The light is emitted in every direction from this point.
  49628. * A good example of a point light is a standard light bulb.
  49629. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49630. */
  49631. export class PointLight extends ShadowLight {
  49632. private _shadowAngle;
  49633. /**
  49634. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49635. * This specifies what angle the shadow will use to be created.
  49636. *
  49637. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49638. */
  49639. /**
  49640. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49641. * This specifies what angle the shadow will use to be created.
  49642. *
  49643. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49644. */
  49645. shadowAngle: number;
  49646. /**
  49647. * Gets the direction if it has been set.
  49648. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49649. */
  49650. /**
  49651. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49652. */
  49653. direction: Vector3;
  49654. /**
  49655. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49656. * A PointLight emits the light in every direction.
  49657. * It can cast shadows.
  49658. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49659. * ```javascript
  49660. * var pointLight = new PointLight("pl", camera.position, scene);
  49661. * ```
  49662. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49663. * @param name The light friendly name
  49664. * @param position The position of the point light in the scene
  49665. * @param scene The scene the lights belongs to
  49666. */
  49667. constructor(name: string, position: Vector3, scene: Scene);
  49668. /**
  49669. * Returns the string "PointLight"
  49670. * @returns the class name
  49671. */
  49672. getClassName(): string;
  49673. /**
  49674. * Returns the integer 0.
  49675. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49676. */
  49677. getTypeID(): number;
  49678. /**
  49679. * Specifies wether or not the shadowmap should be a cube texture.
  49680. * @returns true if the shadowmap needs to be a cube texture.
  49681. */
  49682. needCube(): boolean;
  49683. /**
  49684. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49685. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49686. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49687. */
  49688. getShadowDirection(faceIndex?: number): Vector3;
  49689. /**
  49690. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49691. * - fov = PI / 2
  49692. * - aspect ratio : 1.0
  49693. * - z-near and far equal to the active camera minZ and maxZ.
  49694. * Returns the PointLight.
  49695. */
  49696. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49697. protected _buildUniformLayout(): void;
  49698. /**
  49699. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49700. * @param effect The effect to update
  49701. * @param lightIndex The index of the light in the effect to update
  49702. * @returns The point light
  49703. */
  49704. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  49705. /**
  49706. * Prepares the list of defines specific to the light type.
  49707. * @param defines the list of defines
  49708. * @param lightIndex defines the index of the light for the effect
  49709. */
  49710. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49711. }
  49712. }
  49713. declare module BABYLON {
  49714. /**
  49715. * Header information of HDR texture files.
  49716. */
  49717. export interface HDRInfo {
  49718. /**
  49719. * The height of the texture in pixels.
  49720. */
  49721. height: number;
  49722. /**
  49723. * The width of the texture in pixels.
  49724. */
  49725. width: number;
  49726. /**
  49727. * The index of the beginning of the data in the binary file.
  49728. */
  49729. dataPosition: number;
  49730. }
  49731. /**
  49732. * This groups tools to convert HDR texture to native colors array.
  49733. */
  49734. export class HDRTools {
  49735. private static Ldexp;
  49736. private static Rgbe2float;
  49737. private static readStringLine;
  49738. /**
  49739. * Reads header information from an RGBE texture stored in a native array.
  49740. * More information on this format are available here:
  49741. * https://en.wikipedia.org/wiki/RGBE_image_format
  49742. *
  49743. * @param uint8array The binary file stored in native array.
  49744. * @return The header information.
  49745. */
  49746. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49747. /**
  49748. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49749. * This RGBE texture needs to store the information as a panorama.
  49750. *
  49751. * More information on this format are available here:
  49752. * https://en.wikipedia.org/wiki/RGBE_image_format
  49753. *
  49754. * @param buffer The binary file stored in an array buffer.
  49755. * @param size The expected size of the extracted cubemap.
  49756. * @return The Cube Map information.
  49757. */
  49758. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49759. /**
  49760. * Returns the pixels data extracted from an RGBE texture.
  49761. * This pixels will be stored left to right up to down in the R G B order in one array.
  49762. *
  49763. * More information on this format are available here:
  49764. * https://en.wikipedia.org/wiki/RGBE_image_format
  49765. *
  49766. * @param uint8array The binary file stored in an array buffer.
  49767. * @param hdrInfo The header information of the file.
  49768. * @return The pixels data in RGB right to left up to down order.
  49769. */
  49770. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49771. private static RGBE_ReadPixels_RLE;
  49772. }
  49773. }
  49774. declare module BABYLON {
  49775. /**
  49776. * This represents a texture coming from an HDR input.
  49777. *
  49778. * The only supported format is currently panorama picture stored in RGBE format.
  49779. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49780. */
  49781. export class HDRCubeTexture extends BaseTexture {
  49782. private static _facesMapping;
  49783. private _generateHarmonics;
  49784. private _noMipmap;
  49785. private _textureMatrix;
  49786. private _size;
  49787. private _onLoad;
  49788. private _onError;
  49789. /**
  49790. * The texture URL.
  49791. */
  49792. url: string;
  49793. /**
  49794. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49795. */
  49796. coordinatesMode: number;
  49797. protected _isBlocking: boolean;
  49798. /**
  49799. * Sets wether or not the texture is blocking during loading.
  49800. */
  49801. /**
  49802. * Gets wether or not the texture is blocking during loading.
  49803. */
  49804. isBlocking: boolean;
  49805. protected _rotationY: number;
  49806. /**
  49807. * Sets texture matrix rotation angle around Y axis in radians.
  49808. */
  49809. /**
  49810. * Gets texture matrix rotation angle around Y axis radians.
  49811. */
  49812. rotationY: number;
  49813. /**
  49814. * Gets or sets the center of the bounding box associated with the cube texture
  49815. * It must define where the camera used to render the texture was set
  49816. */
  49817. boundingBoxPosition: Vector3;
  49818. private _boundingBoxSize;
  49819. /**
  49820. * Gets or sets the size of the bounding box associated with the cube texture
  49821. * When defined, the cubemap will switch to local mode
  49822. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49823. * @example https://www.babylonjs-playground.com/#RNASML
  49824. */
  49825. boundingBoxSize: Vector3;
  49826. /**
  49827. * Instantiates an HDRTexture from the following parameters.
  49828. *
  49829. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49830. * @param scene The scene the texture will be used in
  49831. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49832. * @param noMipmap Forces to not generate the mipmap if true
  49833. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49834. * @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)
  49835. * @param reserved Reserved flag for internal use.
  49836. */
  49837. 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>);
  49838. /**
  49839. * Get the current class name of the texture useful for serialization or dynamic coding.
  49840. * @returns "HDRCubeTexture"
  49841. */
  49842. getClassName(): string;
  49843. /**
  49844. * Occurs when the file is raw .hdr file.
  49845. */
  49846. private loadTexture;
  49847. clone(): HDRCubeTexture;
  49848. delayLoad(): void;
  49849. /**
  49850. * Get the texture reflection matrix used to rotate/transform the reflection.
  49851. * @returns the reflection matrix
  49852. */
  49853. getReflectionTextureMatrix(): Matrix;
  49854. /**
  49855. * Set the texture reflection matrix used to rotate/transform the reflection.
  49856. * @param value Define the reflection matrix to set
  49857. */
  49858. setReflectionTextureMatrix(value: Matrix): void;
  49859. /**
  49860. * Parses a JSON representation of an HDR Texture in order to create the texture
  49861. * @param parsedTexture Define the JSON representation
  49862. * @param scene Define the scene the texture should be created in
  49863. * @param rootUrl Define the root url in case we need to load relative dependencies
  49864. * @returns the newly created texture after parsing
  49865. */
  49866. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49867. serialize(): any;
  49868. }
  49869. }
  49870. declare module BABYLON {
  49871. /**
  49872. * Class used to control physics engine
  49873. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49874. */
  49875. export class PhysicsEngine implements IPhysicsEngine {
  49876. private _physicsPlugin;
  49877. /**
  49878. * Global value used to control the smallest number supported by the simulation
  49879. */
  49880. static Epsilon: number;
  49881. private _impostors;
  49882. private _joints;
  49883. /**
  49884. * Gets the gravity vector used by the simulation
  49885. */
  49886. gravity: Vector3;
  49887. /**
  49888. * Factory used to create the default physics plugin.
  49889. * @returns The default physics plugin
  49890. */
  49891. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49892. /**
  49893. * Creates a new Physics Engine
  49894. * @param gravity defines the gravity vector used by the simulation
  49895. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49896. */
  49897. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49898. /**
  49899. * Sets the gravity vector used by the simulation
  49900. * @param gravity defines the gravity vector to use
  49901. */
  49902. setGravity(gravity: Vector3): void;
  49903. /**
  49904. * Set the time step of the physics engine.
  49905. * Default is 1/60.
  49906. * To slow it down, enter 1/600 for example.
  49907. * To speed it up, 1/30
  49908. * @param newTimeStep defines the new timestep to apply to this world.
  49909. */
  49910. setTimeStep(newTimeStep?: number): void;
  49911. /**
  49912. * Get the time step of the physics engine.
  49913. * @returns the current time step
  49914. */
  49915. getTimeStep(): number;
  49916. /**
  49917. * Release all resources
  49918. */
  49919. dispose(): void;
  49920. /**
  49921. * Gets the name of the current physics plugin
  49922. * @returns the name of the plugin
  49923. */
  49924. getPhysicsPluginName(): string;
  49925. /**
  49926. * Adding a new impostor for the impostor tracking.
  49927. * This will be done by the impostor itself.
  49928. * @param impostor the impostor to add
  49929. */
  49930. addImpostor(impostor: PhysicsImpostor): void;
  49931. /**
  49932. * Remove an impostor from the engine.
  49933. * This impostor and its mesh will not longer be updated by the physics engine.
  49934. * @param impostor the impostor to remove
  49935. */
  49936. removeImpostor(impostor: PhysicsImpostor): void;
  49937. /**
  49938. * Add a joint to the physics engine
  49939. * @param mainImpostor defines the main impostor to which the joint is added.
  49940. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49941. * @param joint defines the joint that will connect both impostors.
  49942. */
  49943. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49944. /**
  49945. * Removes a joint from the simulation
  49946. * @param mainImpostor defines the impostor used with the joint
  49947. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49948. * @param joint defines the joint to remove
  49949. */
  49950. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49951. /**
  49952. * Called by the scene. No need to call it.
  49953. * @param delta defines the timespam between frames
  49954. */
  49955. _step(delta: number): void;
  49956. /**
  49957. * Gets the current plugin used to run the simulation
  49958. * @returns current plugin
  49959. */
  49960. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49961. /**
  49962. * Gets the list of physic impostors
  49963. * @returns an array of PhysicsImpostor
  49964. */
  49965. getImpostors(): Array<PhysicsImpostor>;
  49966. /**
  49967. * Gets the impostor for a physics enabled object
  49968. * @param object defines the object impersonated by the impostor
  49969. * @returns the PhysicsImpostor or null if not found
  49970. */
  49971. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49972. /**
  49973. * Gets the impostor for a physics body object
  49974. * @param body defines physics body used by the impostor
  49975. * @returns the PhysicsImpostor or null if not found
  49976. */
  49977. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49978. /**
  49979. * Does a raycast in the physics world
  49980. * @param from when should the ray start?
  49981. * @param to when should the ray end?
  49982. * @returns PhysicsRaycastResult
  49983. */
  49984. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49985. }
  49986. }
  49987. declare module BABYLON {
  49988. /** @hidden */
  49989. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49990. private _useDeltaForWorldStep;
  49991. world: any;
  49992. name: string;
  49993. private _physicsMaterials;
  49994. private _fixedTimeStep;
  49995. private _cannonRaycastResult;
  49996. private _raycastResult;
  49997. private _physicsBodysToRemoveAfterStep;
  49998. BJSCANNON: any;
  49999. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50000. setGravity(gravity: Vector3): void;
  50001. setTimeStep(timeStep: number): void;
  50002. getTimeStep(): number;
  50003. executeStep(delta: number): void;
  50004. private _removeMarkedPhysicsBodiesFromWorld;
  50005. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50006. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50007. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50008. private _processChildMeshes;
  50009. removePhysicsBody(impostor: PhysicsImpostor): void;
  50010. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50011. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50012. private _addMaterial;
  50013. private _checkWithEpsilon;
  50014. private _createShape;
  50015. private _createHeightmap;
  50016. private _minus90X;
  50017. private _plus90X;
  50018. private _tmpPosition;
  50019. private _tmpDeltaPosition;
  50020. private _tmpUnityRotation;
  50021. private _updatePhysicsBodyTransformation;
  50022. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50023. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50024. isSupported(): boolean;
  50025. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50026. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50027. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50028. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50029. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50030. getBodyMass(impostor: PhysicsImpostor): number;
  50031. getBodyFriction(impostor: PhysicsImpostor): number;
  50032. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50033. getBodyRestitution(impostor: PhysicsImpostor): number;
  50034. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50035. sleepBody(impostor: PhysicsImpostor): void;
  50036. wakeUpBody(impostor: PhysicsImpostor): void;
  50037. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50038. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50039. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50040. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50041. getRadius(impostor: PhysicsImpostor): number;
  50042. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50043. dispose(): void;
  50044. private _extendNamespace;
  50045. /**
  50046. * Does a raycast in the physics world
  50047. * @param from when should the ray start?
  50048. * @param to when should the ray end?
  50049. * @returns PhysicsRaycastResult
  50050. */
  50051. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50052. }
  50053. }
  50054. declare module BABYLON {
  50055. /** @hidden */
  50056. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50057. world: any;
  50058. name: string;
  50059. BJSOIMO: any;
  50060. private _raycastResult;
  50061. constructor(iterations?: number, oimoInjection?: any);
  50062. setGravity(gravity: Vector3): void;
  50063. setTimeStep(timeStep: number): void;
  50064. getTimeStep(): number;
  50065. private _tmpImpostorsArray;
  50066. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50067. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50068. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50069. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50070. private _tmpPositionVector;
  50071. removePhysicsBody(impostor: PhysicsImpostor): void;
  50072. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50073. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50074. isSupported(): boolean;
  50075. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50076. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50077. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50078. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50079. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50080. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50081. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50082. getBodyMass(impostor: PhysicsImpostor): number;
  50083. getBodyFriction(impostor: PhysicsImpostor): number;
  50084. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50085. getBodyRestitution(impostor: PhysicsImpostor): number;
  50086. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50087. sleepBody(impostor: PhysicsImpostor): void;
  50088. wakeUpBody(impostor: PhysicsImpostor): void;
  50089. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50090. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50091. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50092. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50093. getRadius(impostor: PhysicsImpostor): number;
  50094. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50095. dispose(): void;
  50096. /**
  50097. * Does a raycast in the physics world
  50098. * @param from when should the ray start?
  50099. * @param to when should the ray end?
  50100. * @returns PhysicsRaycastResult
  50101. */
  50102. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50103. }
  50104. }
  50105. declare module BABYLON {
  50106. /**
  50107. * Class containing static functions to help procedurally build meshes
  50108. */
  50109. export class RibbonBuilder {
  50110. /**
  50111. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50112. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50113. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50114. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50115. * * 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
  50116. * * 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
  50117. * * 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
  50118. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50119. * * 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
  50120. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50121. * * 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
  50122. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50123. * * 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
  50124. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50126. * @param name defines the name of the mesh
  50127. * @param options defines the options used to create the mesh
  50128. * @param scene defines the hosting scene
  50129. * @returns the ribbon mesh
  50130. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50131. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50132. */
  50133. static CreateRibbon(name: string, options: {
  50134. pathArray: Vector3[][];
  50135. closeArray?: boolean;
  50136. closePath?: boolean;
  50137. offset?: number;
  50138. updatable?: boolean;
  50139. sideOrientation?: number;
  50140. frontUVs?: Vector4;
  50141. backUVs?: Vector4;
  50142. instance?: Mesh;
  50143. invertUV?: boolean;
  50144. uvs?: Vector2[];
  50145. colors?: Color4[];
  50146. }, scene?: Nullable<Scene>): Mesh;
  50147. }
  50148. }
  50149. declare module BABYLON {
  50150. /**
  50151. * Class containing static functions to help procedurally build meshes
  50152. */
  50153. export class ShapeBuilder {
  50154. /**
  50155. * 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.
  50156. * * 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.
  50157. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50158. * * 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.
  50159. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50160. * * 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
  50161. * * 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
  50162. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50163. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50164. * * 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
  50165. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50167. * @param name defines the name of the mesh
  50168. * @param options defines the options used to create the mesh
  50169. * @param scene defines the hosting scene
  50170. * @returns the extruded shape mesh
  50171. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50172. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50173. */
  50174. static ExtrudeShape(name: string, options: {
  50175. shape: Vector3[];
  50176. path: Vector3[];
  50177. scale?: number;
  50178. rotation?: number;
  50179. cap?: number;
  50180. updatable?: boolean;
  50181. sideOrientation?: number;
  50182. frontUVs?: Vector4;
  50183. backUVs?: Vector4;
  50184. instance?: Mesh;
  50185. invertUV?: boolean;
  50186. }, scene?: Nullable<Scene>): Mesh;
  50187. /**
  50188. * Creates an custom extruded shape mesh.
  50189. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50190. * * 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.
  50191. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50192. * * 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
  50193. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50194. * * 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
  50195. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50196. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50197. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50198. * * 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
  50199. * * 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
  50200. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50201. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50202. * * 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
  50203. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50205. * @param name defines the name of the mesh
  50206. * @param options defines the options used to create the mesh
  50207. * @param scene defines the hosting scene
  50208. * @returns the custom extruded shape mesh
  50209. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50210. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50211. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50212. */
  50213. static ExtrudeShapeCustom(name: string, options: {
  50214. shape: Vector3[];
  50215. path: Vector3[];
  50216. scaleFunction?: any;
  50217. rotationFunction?: any;
  50218. ribbonCloseArray?: boolean;
  50219. ribbonClosePath?: boolean;
  50220. cap?: number;
  50221. updatable?: boolean;
  50222. sideOrientation?: number;
  50223. frontUVs?: Vector4;
  50224. backUVs?: Vector4;
  50225. instance?: Mesh;
  50226. invertUV?: boolean;
  50227. }, scene?: Nullable<Scene>): Mesh;
  50228. private static _ExtrudeShapeGeneric;
  50229. }
  50230. }
  50231. declare module BABYLON {
  50232. /**
  50233. * AmmoJS Physics plugin
  50234. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50235. * @see https://github.com/kripken/ammo.js/
  50236. */
  50237. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50238. private _useDeltaForWorldStep;
  50239. /**
  50240. * Reference to the Ammo library
  50241. */
  50242. bjsAMMO: any;
  50243. /**
  50244. * Created ammoJS world which physics bodies are added to
  50245. */
  50246. world: any;
  50247. /**
  50248. * Name of the plugin
  50249. */
  50250. name: string;
  50251. private _timeStep;
  50252. private _fixedTimeStep;
  50253. private _maxSteps;
  50254. private _tmpQuaternion;
  50255. private _tmpAmmoTransform;
  50256. private _tmpAmmoQuaternion;
  50257. private _tmpAmmoConcreteContactResultCallback;
  50258. private _collisionConfiguration;
  50259. private _dispatcher;
  50260. private _overlappingPairCache;
  50261. private _solver;
  50262. private _softBodySolver;
  50263. private _tmpAmmoVectorA;
  50264. private _tmpAmmoVectorB;
  50265. private _tmpAmmoVectorC;
  50266. private _tmpAmmoVectorD;
  50267. private _tmpContactCallbackResult;
  50268. private _tmpAmmoVectorRCA;
  50269. private _tmpAmmoVectorRCB;
  50270. private _raycastResult;
  50271. private static readonly DISABLE_COLLISION_FLAG;
  50272. private static readonly KINEMATIC_FLAG;
  50273. private static readonly DISABLE_DEACTIVATION_FLAG;
  50274. /**
  50275. * Initializes the ammoJS plugin
  50276. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50277. * @param ammoInjection can be used to inject your own ammo reference
  50278. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  50279. */
  50280. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  50281. /**
  50282. * Sets the gravity of the physics world (m/(s^2))
  50283. * @param gravity Gravity to set
  50284. */
  50285. setGravity(gravity: Vector3): void;
  50286. /**
  50287. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50288. * @param timeStep timestep to use in seconds
  50289. */
  50290. setTimeStep(timeStep: number): void;
  50291. /**
  50292. * 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)
  50293. * @param fixedTimeStep fixedTimeStep to use in seconds
  50294. */
  50295. setFixedTimeStep(fixedTimeStep: number): void;
  50296. /**
  50297. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50298. * @param maxSteps the maximum number of steps by the physics engine per frame
  50299. */
  50300. setMaxSteps(maxSteps: number): void;
  50301. /**
  50302. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50303. * @returns the current timestep in seconds
  50304. */
  50305. getTimeStep(): number;
  50306. private _isImpostorInContact;
  50307. private _isImpostorPairInContact;
  50308. private _stepSimulation;
  50309. /**
  50310. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50311. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50312. * After the step the babylon meshes are set to the position of the physics imposters
  50313. * @param delta amount of time to step forward
  50314. * @param impostors array of imposters to update before/after the step
  50315. */
  50316. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50317. /**
  50318. * Update babylon mesh to match physics world object
  50319. * @param impostor imposter to match
  50320. */
  50321. private _afterSoftStep;
  50322. /**
  50323. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50324. * @param impostor imposter to match
  50325. */
  50326. private _ropeStep;
  50327. /**
  50328. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50329. * @param impostor imposter to match
  50330. */
  50331. private _softbodyOrClothStep;
  50332. private _tmpVector;
  50333. private _tmpMatrix;
  50334. /**
  50335. * Applies an impulse on the imposter
  50336. * @param impostor imposter to apply impulse to
  50337. * @param force amount of force to be applied to the imposter
  50338. * @param contactPoint the location to apply the impulse on the imposter
  50339. */
  50340. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50341. /**
  50342. * Applies a force on the imposter
  50343. * @param impostor imposter to apply force
  50344. * @param force amount of force to be applied to the imposter
  50345. * @param contactPoint the location to apply the force on the imposter
  50346. */
  50347. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50348. /**
  50349. * Creates a physics body using the plugin
  50350. * @param impostor the imposter to create the physics body on
  50351. */
  50352. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50353. /**
  50354. * Removes the physics body from the imposter and disposes of the body's memory
  50355. * @param impostor imposter to remove the physics body from
  50356. */
  50357. removePhysicsBody(impostor: PhysicsImpostor): void;
  50358. /**
  50359. * Generates a joint
  50360. * @param impostorJoint the imposter joint to create the joint with
  50361. */
  50362. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50363. /**
  50364. * Removes a joint
  50365. * @param impostorJoint the imposter joint to remove the joint from
  50366. */
  50367. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50368. private _addMeshVerts;
  50369. /**
  50370. * Initialise the soft body vertices to match its object's (mesh) vertices
  50371. * Softbody vertices (nodes) are in world space and to match this
  50372. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50373. * @param impostor to create the softbody for
  50374. */
  50375. private _softVertexData;
  50376. /**
  50377. * Create an impostor's soft body
  50378. * @param impostor to create the softbody for
  50379. */
  50380. private _createSoftbody;
  50381. /**
  50382. * Create cloth for an impostor
  50383. * @param impostor to create the softbody for
  50384. */
  50385. private _createCloth;
  50386. /**
  50387. * Create rope for an impostor
  50388. * @param impostor to create the softbody for
  50389. */
  50390. private _createRope;
  50391. private _addHullVerts;
  50392. private _createShape;
  50393. /**
  50394. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50395. * @param impostor imposter containing the physics body and babylon object
  50396. */
  50397. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50398. /**
  50399. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50400. * @param impostor imposter containing the physics body and babylon object
  50401. * @param newPosition new position
  50402. * @param newRotation new rotation
  50403. */
  50404. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50405. /**
  50406. * If this plugin is supported
  50407. * @returns true if its supported
  50408. */
  50409. isSupported(): boolean;
  50410. /**
  50411. * Sets the linear velocity of the physics body
  50412. * @param impostor imposter to set the velocity on
  50413. * @param velocity velocity to set
  50414. */
  50415. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50416. /**
  50417. * Sets the angular velocity of the physics body
  50418. * @param impostor imposter to set the velocity on
  50419. * @param velocity velocity to set
  50420. */
  50421. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50422. /**
  50423. * gets the linear velocity
  50424. * @param impostor imposter to get linear velocity from
  50425. * @returns linear velocity
  50426. */
  50427. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50428. /**
  50429. * gets the angular velocity
  50430. * @param impostor imposter to get angular velocity from
  50431. * @returns angular velocity
  50432. */
  50433. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50434. /**
  50435. * Sets the mass of physics body
  50436. * @param impostor imposter to set the mass on
  50437. * @param mass mass to set
  50438. */
  50439. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50440. /**
  50441. * Gets the mass of the physics body
  50442. * @param impostor imposter to get the mass from
  50443. * @returns mass
  50444. */
  50445. getBodyMass(impostor: PhysicsImpostor): number;
  50446. /**
  50447. * Gets friction of the impostor
  50448. * @param impostor impostor to get friction from
  50449. * @returns friction value
  50450. */
  50451. getBodyFriction(impostor: PhysicsImpostor): number;
  50452. /**
  50453. * Sets friction of the impostor
  50454. * @param impostor impostor to set friction on
  50455. * @param friction friction value
  50456. */
  50457. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50458. /**
  50459. * Gets restitution of the impostor
  50460. * @param impostor impostor to get restitution from
  50461. * @returns restitution value
  50462. */
  50463. getBodyRestitution(impostor: PhysicsImpostor): number;
  50464. /**
  50465. * Sets resitution of the impostor
  50466. * @param impostor impostor to set resitution on
  50467. * @param restitution resitution value
  50468. */
  50469. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50470. /**
  50471. * Gets pressure inside the impostor
  50472. * @param impostor impostor to get pressure from
  50473. * @returns pressure value
  50474. */
  50475. getBodyPressure(impostor: PhysicsImpostor): number;
  50476. /**
  50477. * Sets pressure inside a soft body impostor
  50478. * Cloth and rope must remain 0 pressure
  50479. * @param impostor impostor to set pressure on
  50480. * @param pressure pressure value
  50481. */
  50482. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50483. /**
  50484. * Gets stiffness of the impostor
  50485. * @param impostor impostor to get stiffness from
  50486. * @returns pressure value
  50487. */
  50488. getBodyStiffness(impostor: PhysicsImpostor): number;
  50489. /**
  50490. * Sets stiffness of the impostor
  50491. * @param impostor impostor to set stiffness on
  50492. * @param stiffness stiffness value from 0 to 1
  50493. */
  50494. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50495. /**
  50496. * Gets velocityIterations of the impostor
  50497. * @param impostor impostor to get velocity iterations from
  50498. * @returns velocityIterations value
  50499. */
  50500. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50501. /**
  50502. * Sets velocityIterations of the impostor
  50503. * @param impostor impostor to set velocity iterations on
  50504. * @param velocityIterations velocityIterations value
  50505. */
  50506. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50507. /**
  50508. * Gets positionIterations of the impostor
  50509. * @param impostor impostor to get position iterations from
  50510. * @returns positionIterations value
  50511. */
  50512. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50513. /**
  50514. * Sets positionIterations of the impostor
  50515. * @param impostor impostor to set position on
  50516. * @param positionIterations positionIterations value
  50517. */
  50518. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50519. /**
  50520. * Append an anchor to a cloth object
  50521. * @param impostor is the cloth impostor to add anchor to
  50522. * @param otherImpostor is the rigid impostor to anchor to
  50523. * @param width ratio across width from 0 to 1
  50524. * @param height ratio up height from 0 to 1
  50525. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50526. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50527. */
  50528. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50529. /**
  50530. * Append an hook to a rope object
  50531. * @param impostor is the rope impostor to add hook to
  50532. * @param otherImpostor is the rigid impostor to hook to
  50533. * @param length ratio along the rope from 0 to 1
  50534. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50535. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50536. */
  50537. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50538. /**
  50539. * Sleeps the physics body and stops it from being active
  50540. * @param impostor impostor to sleep
  50541. */
  50542. sleepBody(impostor: PhysicsImpostor): void;
  50543. /**
  50544. * Activates the physics body
  50545. * @param impostor impostor to activate
  50546. */
  50547. wakeUpBody(impostor: PhysicsImpostor): void;
  50548. /**
  50549. * Updates the distance parameters of the joint
  50550. * @param joint joint to update
  50551. * @param maxDistance maximum distance of the joint
  50552. * @param minDistance minimum distance of the joint
  50553. */
  50554. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50555. /**
  50556. * Sets a motor on the joint
  50557. * @param joint joint to set motor on
  50558. * @param speed speed of the motor
  50559. * @param maxForce maximum force of the motor
  50560. * @param motorIndex index of the motor
  50561. */
  50562. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50563. /**
  50564. * Sets the motors limit
  50565. * @param joint joint to set limit on
  50566. * @param upperLimit upper limit
  50567. * @param lowerLimit lower limit
  50568. */
  50569. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50570. /**
  50571. * Syncs the position and rotation of a mesh with the impostor
  50572. * @param mesh mesh to sync
  50573. * @param impostor impostor to update the mesh with
  50574. */
  50575. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50576. /**
  50577. * Gets the radius of the impostor
  50578. * @param impostor impostor to get radius from
  50579. * @returns the radius
  50580. */
  50581. getRadius(impostor: PhysicsImpostor): number;
  50582. /**
  50583. * Gets the box size of the impostor
  50584. * @param impostor impostor to get box size from
  50585. * @param result the resulting box size
  50586. */
  50587. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50588. /**
  50589. * Disposes of the impostor
  50590. */
  50591. dispose(): void;
  50592. /**
  50593. * Does a raycast in the physics world
  50594. * @param from when should the ray start?
  50595. * @param to when should the ray end?
  50596. * @returns PhysicsRaycastResult
  50597. */
  50598. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50599. }
  50600. }
  50601. declare module BABYLON {
  50602. interface AbstractScene {
  50603. /**
  50604. * The list of reflection probes added to the scene
  50605. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50606. */
  50607. reflectionProbes: Array<ReflectionProbe>;
  50608. /**
  50609. * Removes the given reflection probe from this scene.
  50610. * @param toRemove The reflection probe to remove
  50611. * @returns The index of the removed reflection probe
  50612. */
  50613. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50614. /**
  50615. * Adds the given reflection probe to this scene.
  50616. * @param newReflectionProbe The reflection probe to add
  50617. */
  50618. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  50619. }
  50620. /**
  50621. * Class used to generate realtime reflection / refraction cube textures
  50622. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50623. */
  50624. export class ReflectionProbe {
  50625. /** defines the name of the probe */
  50626. name: string;
  50627. private _scene;
  50628. private _renderTargetTexture;
  50629. private _projectionMatrix;
  50630. private _viewMatrix;
  50631. private _target;
  50632. private _add;
  50633. private _attachedMesh;
  50634. private _invertYAxis;
  50635. /** Gets or sets probe position (center of the cube map) */
  50636. position: Vector3;
  50637. /**
  50638. * Creates a new reflection probe
  50639. * @param name defines the name of the probe
  50640. * @param size defines the texture resolution (for each face)
  50641. * @param scene defines the hosting scene
  50642. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  50643. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  50644. */
  50645. constructor(
  50646. /** defines the name of the probe */
  50647. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  50648. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  50649. samples: number;
  50650. /** Gets or sets the refresh rate to use (on every frame by default) */
  50651. refreshRate: number;
  50652. /**
  50653. * Gets the hosting scene
  50654. * @returns a Scene
  50655. */
  50656. getScene(): Scene;
  50657. /** Gets the internal CubeTexture used to render to */
  50658. readonly cubeTexture: RenderTargetTexture;
  50659. /** Gets the list of meshes to render */
  50660. readonly renderList: Nullable<AbstractMesh[]>;
  50661. /**
  50662. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  50663. * @param mesh defines the mesh to attach to
  50664. */
  50665. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50666. /**
  50667. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  50668. * @param renderingGroupId The rendering group id corresponding to its index
  50669. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  50670. */
  50671. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  50672. /**
  50673. * Clean all associated resources
  50674. */
  50675. dispose(): void;
  50676. /**
  50677. * Converts the reflection probe information to a readable string for debug purpose.
  50678. * @param fullDetails Supports for multiple levels of logging within scene loading
  50679. * @returns the human readable reflection probe info
  50680. */
  50681. toString(fullDetails?: boolean): string;
  50682. /**
  50683. * Get the class name of the relfection probe.
  50684. * @returns "ReflectionProbe"
  50685. */
  50686. getClassName(): string;
  50687. /**
  50688. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  50689. * @returns The JSON representation of the texture
  50690. */
  50691. serialize(): any;
  50692. /**
  50693. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  50694. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  50695. * @param scene Define the scene the parsed reflection probe should be instantiated in
  50696. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  50697. * @returns The parsed reflection probe if successful
  50698. */
  50699. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  50700. }
  50701. }
  50702. declare module BABYLON {
  50703. /** @hidden */
  50704. export var _BabylonLoaderRegistered: boolean;
  50705. }
  50706. declare module BABYLON {
  50707. /**
  50708. * The Physically based simple base material of BJS.
  50709. *
  50710. * This enables better naming and convention enforcements on top of the pbrMaterial.
  50711. * It is used as the base class for both the specGloss and metalRough conventions.
  50712. */
  50713. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  50714. /**
  50715. * Number of Simultaneous lights allowed on the material.
  50716. */
  50717. maxSimultaneousLights: number;
  50718. /**
  50719. * If sets to true, disables all the lights affecting the material.
  50720. */
  50721. disableLighting: boolean;
  50722. /**
  50723. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  50724. */
  50725. environmentTexture: BaseTexture;
  50726. /**
  50727. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50728. */
  50729. invertNormalMapX: boolean;
  50730. /**
  50731. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50732. */
  50733. invertNormalMapY: boolean;
  50734. /**
  50735. * Normal map used in the model.
  50736. */
  50737. normalTexture: BaseTexture;
  50738. /**
  50739. * Emissivie color used to self-illuminate the model.
  50740. */
  50741. emissiveColor: Color3;
  50742. /**
  50743. * Emissivie texture used to self-illuminate the model.
  50744. */
  50745. emissiveTexture: BaseTexture;
  50746. /**
  50747. * Occlusion Channel Strenght.
  50748. */
  50749. occlusionStrength: number;
  50750. /**
  50751. * Occlusion Texture of the material (adding extra occlusion effects).
  50752. */
  50753. occlusionTexture: BaseTexture;
  50754. /**
  50755. * Defines the alpha limits in alpha test mode.
  50756. */
  50757. alphaCutOff: number;
  50758. /**
  50759. * Gets the current double sided mode.
  50760. */
  50761. /**
  50762. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50763. */
  50764. doubleSided: boolean;
  50765. /**
  50766. * Stores the pre-calculated light information of a mesh in a texture.
  50767. */
  50768. lightmapTexture: BaseTexture;
  50769. /**
  50770. * If true, the light map contains occlusion information instead of lighting info.
  50771. */
  50772. useLightmapAsShadowmap: boolean;
  50773. /**
  50774. * Instantiates a new PBRMaterial instance.
  50775. *
  50776. * @param name The material name
  50777. * @param scene The scene the material will be use in.
  50778. */
  50779. constructor(name: string, scene: Scene);
  50780. getClassName(): string;
  50781. }
  50782. }
  50783. declare module BABYLON {
  50784. /**
  50785. * The PBR material of BJS following the metal roughness convention.
  50786. *
  50787. * This fits to the PBR convention in the GLTF definition:
  50788. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50789. */
  50790. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50791. /**
  50792. * The base color has two different interpretations depending on the value of metalness.
  50793. * When the material is a metal, the base color is the specific measured reflectance value
  50794. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50795. * of the material.
  50796. */
  50797. baseColor: Color3;
  50798. /**
  50799. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50800. * well as opacity information in the alpha channel.
  50801. */
  50802. baseTexture: BaseTexture;
  50803. /**
  50804. * Specifies the metallic scalar value of the material.
  50805. * Can also be used to scale the metalness values of the metallic texture.
  50806. */
  50807. metallic: number;
  50808. /**
  50809. * Specifies the roughness scalar value of the material.
  50810. * Can also be used to scale the roughness values of the metallic texture.
  50811. */
  50812. roughness: number;
  50813. /**
  50814. * Texture containing both the metallic value in the B channel and the
  50815. * roughness value in the G channel to keep better precision.
  50816. */
  50817. metallicRoughnessTexture: BaseTexture;
  50818. /**
  50819. * Instantiates a new PBRMetalRoughnessMaterial instance.
  50820. *
  50821. * @param name The material name
  50822. * @param scene The scene the material will be use in.
  50823. */
  50824. constructor(name: string, scene: Scene);
  50825. /**
  50826. * Return the currrent class name of the material.
  50827. */
  50828. getClassName(): string;
  50829. /**
  50830. * Makes a duplicate of the current material.
  50831. * @param name - name to use for the new material.
  50832. */
  50833. clone(name: string): PBRMetallicRoughnessMaterial;
  50834. /**
  50835. * Serialize the material to a parsable JSON object.
  50836. */
  50837. serialize(): any;
  50838. /**
  50839. * Parses a JSON object correponding to the serialize function.
  50840. */
  50841. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  50842. }
  50843. }
  50844. declare module BABYLON {
  50845. /**
  50846. * The PBR material of BJS following the specular glossiness convention.
  50847. *
  50848. * This fits to the PBR convention in the GLTF definition:
  50849. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  50850. */
  50851. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  50852. /**
  50853. * Specifies the diffuse color of the material.
  50854. */
  50855. diffuseColor: Color3;
  50856. /**
  50857. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  50858. * channel.
  50859. */
  50860. diffuseTexture: BaseTexture;
  50861. /**
  50862. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  50863. */
  50864. specularColor: Color3;
  50865. /**
  50866. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  50867. */
  50868. glossiness: number;
  50869. /**
  50870. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  50871. */
  50872. specularGlossinessTexture: BaseTexture;
  50873. /**
  50874. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  50875. *
  50876. * @param name The material name
  50877. * @param scene The scene the material will be use in.
  50878. */
  50879. constructor(name: string, scene: Scene);
  50880. /**
  50881. * Return the currrent class name of the material.
  50882. */
  50883. getClassName(): string;
  50884. /**
  50885. * Makes a duplicate of the current material.
  50886. * @param name - name to use for the new material.
  50887. */
  50888. clone(name: string): PBRSpecularGlossinessMaterial;
  50889. /**
  50890. * Serialize the material to a parsable JSON object.
  50891. */
  50892. serialize(): any;
  50893. /**
  50894. * Parses a JSON object correponding to the serialize function.
  50895. */
  50896. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50897. }
  50898. }
  50899. declare module BABYLON {
  50900. /**
  50901. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50902. * It can help converting any input color in a desired output one. This can then be used to create effects
  50903. * from sepia, black and white to sixties or futuristic rendering...
  50904. *
  50905. * The only supported format is currently 3dl.
  50906. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50907. */
  50908. export class ColorGradingTexture extends BaseTexture {
  50909. /**
  50910. * The current texture matrix. (will always be identity in color grading texture)
  50911. */
  50912. private _textureMatrix;
  50913. /**
  50914. * The texture URL.
  50915. */
  50916. url: string;
  50917. /**
  50918. * Empty line regex stored for GC.
  50919. */
  50920. private static _noneEmptyLineRegex;
  50921. private _engine;
  50922. /**
  50923. * Instantiates a ColorGradingTexture from the following parameters.
  50924. *
  50925. * @param url The location of the color gradind data (currently only supporting 3dl)
  50926. * @param scene The scene the texture will be used in
  50927. */
  50928. constructor(url: string, scene: Scene);
  50929. /**
  50930. * Returns the texture matrix used in most of the material.
  50931. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  50932. */
  50933. getTextureMatrix(): Matrix;
  50934. /**
  50935. * Occurs when the file being loaded is a .3dl LUT file.
  50936. */
  50937. private load3dlTexture;
  50938. /**
  50939. * Starts the loading process of the texture.
  50940. */
  50941. private loadTexture;
  50942. /**
  50943. * Clones the color gradind texture.
  50944. */
  50945. clone(): ColorGradingTexture;
  50946. /**
  50947. * Called during delayed load for textures.
  50948. */
  50949. delayLoad(): void;
  50950. /**
  50951. * Parses a color grading texture serialized by Babylon.
  50952. * @param parsedTexture The texture information being parsedTexture
  50953. * @param scene The scene to load the texture in
  50954. * @param rootUrl The root url of the data assets to load
  50955. * @return A color gradind texture
  50956. */
  50957. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  50958. /**
  50959. * Serializes the LUT texture to json format.
  50960. */
  50961. serialize(): any;
  50962. }
  50963. }
  50964. declare module BABYLON {
  50965. /**
  50966. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  50967. */
  50968. export class EquiRectangularCubeTexture extends BaseTexture {
  50969. /** The six faces of the cube. */
  50970. private static _FacesMapping;
  50971. private _noMipmap;
  50972. private _onLoad;
  50973. private _onError;
  50974. /** The size of the cubemap. */
  50975. private _size;
  50976. /** The buffer of the image. */
  50977. private _buffer;
  50978. /** The width of the input image. */
  50979. private _width;
  50980. /** The height of the input image. */
  50981. private _height;
  50982. /** The URL to the image. */
  50983. url: string;
  50984. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  50985. coordinatesMode: number;
  50986. /**
  50987. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  50988. * @param url The location of the image
  50989. * @param scene The scene the texture will be used in
  50990. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50991. * @param noMipmap Forces to not generate the mipmap if true
  50992. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  50993. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  50994. * @param onLoad — defines a callback called when texture is loaded
  50995. * @param onError — defines a callback called if there is an error
  50996. */
  50997. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  50998. /**
  50999. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51000. */
  51001. private loadImage;
  51002. /**
  51003. * Convert the image buffer into a cubemap and create a CubeTexture.
  51004. */
  51005. private loadTexture;
  51006. /**
  51007. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51008. * @param buffer The ArrayBuffer that should be converted.
  51009. * @returns The buffer as Float32Array.
  51010. */
  51011. private getFloat32ArrayFromArrayBuffer;
  51012. /**
  51013. * Get the current class name of the texture useful for serialization or dynamic coding.
  51014. * @returns "EquiRectangularCubeTexture"
  51015. */
  51016. getClassName(): string;
  51017. /**
  51018. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51019. * @returns A clone of the current EquiRectangularCubeTexture.
  51020. */
  51021. clone(): EquiRectangularCubeTexture;
  51022. }
  51023. }
  51024. declare module BABYLON {
  51025. /**
  51026. * Based on jsTGALoader - Javascript loader for TGA file
  51027. * By Vincent Thibault
  51028. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51029. */
  51030. export class TGATools {
  51031. private static _TYPE_INDEXED;
  51032. private static _TYPE_RGB;
  51033. private static _TYPE_GREY;
  51034. private static _TYPE_RLE_INDEXED;
  51035. private static _TYPE_RLE_RGB;
  51036. private static _TYPE_RLE_GREY;
  51037. private static _ORIGIN_MASK;
  51038. private static _ORIGIN_SHIFT;
  51039. private static _ORIGIN_BL;
  51040. private static _ORIGIN_BR;
  51041. private static _ORIGIN_UL;
  51042. private static _ORIGIN_UR;
  51043. /**
  51044. * Gets the header of a TGA file
  51045. * @param data defines the TGA data
  51046. * @returns the header
  51047. */
  51048. static GetTGAHeader(data: Uint8Array): any;
  51049. /**
  51050. * Uploads TGA content to a Babylon Texture
  51051. * @hidden
  51052. */
  51053. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51054. /** @hidden */
  51055. 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;
  51056. /** @hidden */
  51057. 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;
  51058. /** @hidden */
  51059. 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;
  51060. /** @hidden */
  51061. 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;
  51062. /** @hidden */
  51063. 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;
  51064. /** @hidden */
  51065. 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;
  51066. }
  51067. }
  51068. declare module BABYLON {
  51069. /**
  51070. * Implementation of the TGA Texture Loader.
  51071. * @hidden
  51072. */
  51073. export class _TGATextureLoader implements IInternalTextureLoader {
  51074. /**
  51075. * Defines wether the loader supports cascade loading the different faces.
  51076. */
  51077. readonly supportCascades: boolean;
  51078. /**
  51079. * This returns if the loader support the current file information.
  51080. * @param extension defines the file extension of the file being loaded
  51081. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51082. * @param fallback defines the fallback internal texture if any
  51083. * @param isBase64 defines whether the texture is encoded as a base64
  51084. * @param isBuffer defines whether the texture data are stored as a buffer
  51085. * @returns true if the loader can load the specified file
  51086. */
  51087. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51088. /**
  51089. * Transform the url before loading if required.
  51090. * @param rootUrl the url of the texture
  51091. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51092. * @returns the transformed texture
  51093. */
  51094. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51095. /**
  51096. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51097. * @param rootUrl the url of the texture
  51098. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51099. * @returns the fallback texture
  51100. */
  51101. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51102. /**
  51103. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51104. * @param data contains the texture data
  51105. * @param texture defines the BabylonJS internal texture
  51106. * @param createPolynomials will be true if polynomials have been requested
  51107. * @param onLoad defines the callback to trigger once the texture is ready
  51108. * @param onError defines the callback to trigger in case of error
  51109. */
  51110. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51111. /**
  51112. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51113. * @param data contains the texture data
  51114. * @param texture defines the BabylonJS internal texture
  51115. * @param callback defines the method to call once ready to upload
  51116. */
  51117. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51118. }
  51119. }
  51120. declare module BABYLON {
  51121. /**
  51122. * Info about the .basis files
  51123. */
  51124. class BasisFileInfo {
  51125. /**
  51126. * If the file has alpha
  51127. */
  51128. hasAlpha: boolean;
  51129. /**
  51130. * Info about each image of the basis file
  51131. */
  51132. images: Array<{
  51133. levels: Array<{
  51134. width: number;
  51135. height: number;
  51136. transcodedPixels: ArrayBufferView;
  51137. }>;
  51138. }>;
  51139. }
  51140. /**
  51141. * Result of transcoding a basis file
  51142. */
  51143. class TranscodeResult {
  51144. /**
  51145. * Info about the .basis file
  51146. */
  51147. fileInfo: BasisFileInfo;
  51148. /**
  51149. * Format to use when loading the file
  51150. */
  51151. format: number;
  51152. }
  51153. /**
  51154. * Configuration options for the Basis transcoder
  51155. */
  51156. export class BasisTranscodeConfiguration {
  51157. /**
  51158. * Supported compression formats used to determine the supported output format of the transcoder
  51159. */
  51160. supportedCompressionFormats?: {
  51161. /**
  51162. * etc1 compression format
  51163. */
  51164. etc1?: boolean;
  51165. /**
  51166. * s3tc compression format
  51167. */
  51168. s3tc?: boolean;
  51169. /**
  51170. * pvrtc compression format
  51171. */
  51172. pvrtc?: boolean;
  51173. /**
  51174. * etc2 compression format
  51175. */
  51176. etc2?: boolean;
  51177. };
  51178. /**
  51179. * If mipmap levels should be loaded for transcoded images (Default: true)
  51180. */
  51181. loadMipmapLevels?: boolean;
  51182. /**
  51183. * Index of a single image to load (Default: all images)
  51184. */
  51185. loadSingleImage?: number;
  51186. }
  51187. /**
  51188. * Used to load .Basis files
  51189. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  51190. */
  51191. export class BasisTools {
  51192. private static _IgnoreSupportedFormats;
  51193. /**
  51194. * URL to use when loading the basis transcoder
  51195. */
  51196. static JSModuleURL: string;
  51197. /**
  51198. * URL to use when loading the wasm module for the transcoder
  51199. */
  51200. static WasmModuleURL: string;
  51201. /**
  51202. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  51203. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  51204. * @returns internal format corresponding to the Basis format
  51205. */
  51206. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  51207. private static _WorkerPromise;
  51208. private static _Worker;
  51209. private static _actionId;
  51210. private static _CreateWorkerAsync;
  51211. /**
  51212. * Transcodes a loaded image file to compressed pixel data
  51213. * @param imageData image data to transcode
  51214. * @param config configuration options for the transcoding
  51215. * @returns a promise resulting in the transcoded image
  51216. */
  51217. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  51218. /**
  51219. * Loads a texture from the transcode result
  51220. * @param texture texture load to
  51221. * @param transcodeResult the result of transcoding the basis file to load from
  51222. */
  51223. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  51224. }
  51225. }
  51226. declare module BABYLON {
  51227. /**
  51228. * Loader for .basis file format
  51229. */
  51230. export class _BasisTextureLoader implements IInternalTextureLoader {
  51231. /**
  51232. * Defines whether the loader supports cascade loading the different faces.
  51233. */
  51234. readonly supportCascades: boolean;
  51235. /**
  51236. * This returns if the loader support the current file information.
  51237. * @param extension defines the file extension of the file being loaded
  51238. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51239. * @param fallback defines the fallback internal texture if any
  51240. * @param isBase64 defines whether the texture is encoded as a base64
  51241. * @param isBuffer defines whether the texture data are stored as a buffer
  51242. * @returns true if the loader can load the specified file
  51243. */
  51244. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51245. /**
  51246. * Transform the url before loading if required.
  51247. * @param rootUrl the url of the texture
  51248. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51249. * @returns the transformed texture
  51250. */
  51251. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51252. /**
  51253. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51254. * @param rootUrl the url of the texture
  51255. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51256. * @returns the fallback texture
  51257. */
  51258. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51259. /**
  51260. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  51261. * @param data contains the texture data
  51262. * @param texture defines the BabylonJS internal texture
  51263. * @param createPolynomials will be true if polynomials have been requested
  51264. * @param onLoad defines the callback to trigger once the texture is ready
  51265. * @param onError defines the callback to trigger in case of error
  51266. */
  51267. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51268. /**
  51269. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51270. * @param data contains the texture data
  51271. * @param texture defines the BabylonJS internal texture
  51272. * @param callback defines the method to call once ready to upload
  51273. */
  51274. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51275. }
  51276. }
  51277. declare module BABYLON {
  51278. /**
  51279. * 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.
  51280. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51281. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51282. */
  51283. export class CustomProceduralTexture extends ProceduralTexture {
  51284. private _animate;
  51285. private _time;
  51286. private _config;
  51287. private _texturePath;
  51288. /**
  51289. * Instantiates a new Custom Procedural Texture.
  51290. * 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.
  51291. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51292. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51293. * @param name Define the name of the texture
  51294. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51295. * @param size Define the size of the texture to create
  51296. * @param scene Define the scene the texture belongs to
  51297. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51298. * @param generateMipMaps Define if the texture should creates mip maps or not
  51299. */
  51300. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51301. private _loadJson;
  51302. /**
  51303. * Is the texture ready to be used ? (rendered at least once)
  51304. * @returns true if ready, otherwise, false.
  51305. */
  51306. isReady(): boolean;
  51307. /**
  51308. * Render the texture to its associated render target.
  51309. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51310. */
  51311. render(useCameraPostProcess?: boolean): void;
  51312. /**
  51313. * Update the list of dependant textures samplers in the shader.
  51314. */
  51315. updateTextures(): void;
  51316. /**
  51317. * Update the uniform values of the procedural texture in the shader.
  51318. */
  51319. updateShaderUniforms(): void;
  51320. /**
  51321. * Define if the texture animates or not.
  51322. */
  51323. animate: boolean;
  51324. }
  51325. }
  51326. declare module BABYLON {
  51327. /** @hidden */
  51328. export var noisePixelShader: {
  51329. name: string;
  51330. shader: string;
  51331. };
  51332. }
  51333. declare module BABYLON {
  51334. /**
  51335. * Class used to generate noise procedural textures
  51336. */
  51337. export class NoiseProceduralTexture extends ProceduralTexture {
  51338. private _time;
  51339. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51340. brightness: number;
  51341. /** Defines the number of octaves to process */
  51342. octaves: number;
  51343. /** Defines the level of persistence (0.8 by default) */
  51344. persistence: number;
  51345. /** Gets or sets animation speed factor (default is 1) */
  51346. animationSpeedFactor: number;
  51347. /**
  51348. * Creates a new NoiseProceduralTexture
  51349. * @param name defines the name fo the texture
  51350. * @param size defines the size of the texture (default is 256)
  51351. * @param scene defines the hosting scene
  51352. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51353. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51354. */
  51355. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51356. private _updateShaderUniforms;
  51357. protected _getDefines(): string;
  51358. /** Generate the current state of the procedural texture */
  51359. render(useCameraPostProcess?: boolean): void;
  51360. /**
  51361. * Serializes this noise procedural texture
  51362. * @returns a serialized noise procedural texture object
  51363. */
  51364. serialize(): any;
  51365. /**
  51366. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51367. * @param parsedTexture defines parsed texture data
  51368. * @param scene defines the current scene
  51369. * @param rootUrl defines the root URL containing noise procedural texture information
  51370. * @returns a parsed NoiseProceduralTexture
  51371. */
  51372. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51373. }
  51374. }
  51375. declare module BABYLON {
  51376. /**
  51377. * Raw cube texture where the raw buffers are passed in
  51378. */
  51379. export class RawCubeTexture extends CubeTexture {
  51380. /**
  51381. * Creates a cube texture where the raw buffers are passed in.
  51382. * @param scene defines the scene the texture is attached to
  51383. * @param data defines the array of data to use to create each face
  51384. * @param size defines the size of the textures
  51385. * @param format defines the format of the data
  51386. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51387. * @param generateMipMaps defines if the engine should generate the mip levels
  51388. * @param invertY defines if data must be stored with Y axis inverted
  51389. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51390. * @param compression defines the compression used (null by default)
  51391. */
  51392. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51393. /**
  51394. * Updates the raw cube texture.
  51395. * @param data defines the data to store
  51396. * @param format defines the data format
  51397. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51398. * @param invertY defines if data must be stored with Y axis inverted
  51399. * @param compression defines the compression used (null by default)
  51400. * @param level defines which level of the texture to update
  51401. */
  51402. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51403. /**
  51404. * Updates a raw cube texture with RGBD encoded data.
  51405. * @param data defines the array of data [mipmap][face] to use to create each face
  51406. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51407. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51408. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51409. * @returns a promsie that resolves when the operation is complete
  51410. */
  51411. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51412. /**
  51413. * Clones the raw cube texture.
  51414. * @return a new cube texture
  51415. */
  51416. clone(): CubeTexture;
  51417. /** @hidden */
  51418. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51419. }
  51420. }
  51421. declare module BABYLON {
  51422. /**
  51423. * Class used to store 3D textures containing user data
  51424. */
  51425. export class RawTexture3D extends Texture {
  51426. /** Gets or sets the texture format to use */
  51427. format: number;
  51428. private _engine;
  51429. /**
  51430. * Create a new RawTexture3D
  51431. * @param data defines the data of the texture
  51432. * @param width defines the width of the texture
  51433. * @param height defines the height of the texture
  51434. * @param depth defines the depth of the texture
  51435. * @param format defines the texture format to use
  51436. * @param scene defines the hosting scene
  51437. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51438. * @param invertY defines if texture must be stored with Y axis inverted
  51439. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51440. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51441. */
  51442. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51443. /** Gets or sets the texture format to use */
  51444. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51445. /**
  51446. * Update the texture with new data
  51447. * @param data defines the data to store in the texture
  51448. */
  51449. update(data: ArrayBufferView): void;
  51450. }
  51451. }
  51452. declare module BABYLON {
  51453. /**
  51454. * Creates a refraction texture used by refraction channel of the standard material.
  51455. * It is like a mirror but to see through a material.
  51456. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51457. */
  51458. export class RefractionTexture extends RenderTargetTexture {
  51459. /**
  51460. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51461. * 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.
  51462. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51463. */
  51464. refractionPlane: Plane;
  51465. /**
  51466. * Define how deep under the surface we should see.
  51467. */
  51468. depth: number;
  51469. /**
  51470. * Creates a refraction texture used by refraction channel of the standard material.
  51471. * It is like a mirror but to see through a material.
  51472. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51473. * @param name Define the texture name
  51474. * @param size Define the size of the underlying texture
  51475. * @param scene Define the scene the refraction belongs to
  51476. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51477. */
  51478. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51479. /**
  51480. * Clone the refraction texture.
  51481. * @returns the cloned texture
  51482. */
  51483. clone(): RefractionTexture;
  51484. /**
  51485. * Serialize the texture to a JSON representation you could use in Parse later on
  51486. * @returns the serialized JSON representation
  51487. */
  51488. serialize(): any;
  51489. }
  51490. }
  51491. declare module BABYLON {
  51492. /**
  51493. * Defines the options related to the creation of an HtmlElementTexture
  51494. */
  51495. export interface IHtmlElementTextureOptions {
  51496. /**
  51497. * Defines wether mip maps should be created or not.
  51498. */
  51499. generateMipMaps?: boolean;
  51500. /**
  51501. * Defines the sampling mode of the texture.
  51502. */
  51503. samplingMode?: number;
  51504. /**
  51505. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51506. */
  51507. engine: Nullable<Engine>;
  51508. /**
  51509. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51510. */
  51511. scene: Nullable<Scene>;
  51512. }
  51513. /**
  51514. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51515. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51516. * is automatically managed.
  51517. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51518. * in your application.
  51519. *
  51520. * As the update is not automatic, you need to call them manually.
  51521. */
  51522. export class HtmlElementTexture extends BaseTexture {
  51523. /**
  51524. * The texture URL.
  51525. */
  51526. element: HTMLVideoElement | HTMLCanvasElement;
  51527. private static readonly DefaultOptions;
  51528. private _textureMatrix;
  51529. private _engine;
  51530. private _isVideo;
  51531. private _generateMipMaps;
  51532. private _samplingMode;
  51533. /**
  51534. * Instantiates a HtmlElementTexture from the following parameters.
  51535. *
  51536. * @param name Defines the name of the texture
  51537. * @param element Defines the video or canvas the texture is filled with
  51538. * @param options Defines the other none mandatory texture creation options
  51539. */
  51540. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51541. private _createInternalTexture;
  51542. /**
  51543. * Returns the texture matrix used in most of the material.
  51544. */
  51545. getTextureMatrix(): Matrix;
  51546. /**
  51547. * Updates the content of the texture.
  51548. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51549. */
  51550. update(invertY?: Nullable<boolean>): void;
  51551. }
  51552. }
  51553. declare module BABYLON {
  51554. /**
  51555. * Enum used to define the target of a block
  51556. */
  51557. export enum NodeMaterialBlockTargets {
  51558. /** Vertex shader */
  51559. Vertex = 1,
  51560. /** Fragment shader */
  51561. Fragment = 2,
  51562. /** Neutral */
  51563. Neutral = 4,
  51564. /** Vertex and Fragment */
  51565. VertexAndFragment = 3
  51566. }
  51567. }
  51568. declare module BABYLON {
  51569. /**
  51570. * Defines the kind of connection point for node based material
  51571. */
  51572. export enum NodeMaterialBlockConnectionPointTypes {
  51573. /** Float */
  51574. Float = 1,
  51575. /** Int */
  51576. Int = 2,
  51577. /** Vector2 */
  51578. Vector2 = 4,
  51579. /** Vector3 */
  51580. Vector3 = 8,
  51581. /** Vector4 */
  51582. Vector4 = 16,
  51583. /** Color3 */
  51584. Color3 = 32,
  51585. /** Color4 */
  51586. Color4 = 64,
  51587. /** Matrix */
  51588. Matrix = 128,
  51589. /** Detect type based on connection */
  51590. AutoDetect = 1024,
  51591. /** Output type that will be defined by input type */
  51592. BasedOnInput = 2048
  51593. }
  51594. }
  51595. declare module BABYLON {
  51596. /**
  51597. * Root class for all node material optimizers
  51598. */
  51599. export class NodeMaterialOptimizer {
  51600. /**
  51601. * Function used to optimize a NodeMaterial graph
  51602. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  51603. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  51604. */
  51605. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  51606. }
  51607. }
  51608. declare module BABYLON {
  51609. /**
  51610. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  51611. */
  51612. export class TransformBlock extends NodeMaterialBlock {
  51613. /**
  51614. * Defines the value to use to complement W value to transform it to a Vector4
  51615. */
  51616. complementW: number;
  51617. /**
  51618. * Defines the value to use to complement z value to transform it to a Vector4
  51619. */
  51620. complementZ: number;
  51621. /**
  51622. * Creates a new TransformBlock
  51623. * @param name defines the block name
  51624. */
  51625. constructor(name: string);
  51626. /**
  51627. * Gets the current class name
  51628. * @returns the class name
  51629. */
  51630. getClassName(): string;
  51631. /**
  51632. * Gets the vector input
  51633. */
  51634. readonly vector: NodeMaterialConnectionPoint;
  51635. /**
  51636. * Gets the output component
  51637. */
  51638. readonly output: NodeMaterialConnectionPoint;
  51639. /**
  51640. * Gets the matrix transform input
  51641. */
  51642. readonly transform: NodeMaterialConnectionPoint;
  51643. protected _buildBlock(state: NodeMaterialBuildState): this;
  51644. serialize(): any;
  51645. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51646. }
  51647. }
  51648. declare module BABYLON {
  51649. /**
  51650. * Block used to output the vertex position
  51651. */
  51652. export class VertexOutputBlock extends NodeMaterialBlock {
  51653. /**
  51654. * Creates a new VertexOutputBlock
  51655. * @param name defines the block name
  51656. */
  51657. constructor(name: string);
  51658. /**
  51659. * Gets the current class name
  51660. * @returns the class name
  51661. */
  51662. getClassName(): string;
  51663. /**
  51664. * Gets the vector input component
  51665. */
  51666. readonly vector: NodeMaterialConnectionPoint;
  51667. protected _buildBlock(state: NodeMaterialBuildState): this;
  51668. }
  51669. }
  51670. declare module BABYLON {
  51671. /**
  51672. * Block used to output the final color
  51673. */
  51674. export class FragmentOutputBlock extends NodeMaterialBlock {
  51675. /**
  51676. * Create a new FragmentOutputBlock
  51677. * @param name defines the block name
  51678. */
  51679. constructor(name: string);
  51680. /**
  51681. * Gets the current class name
  51682. * @returns the class name
  51683. */
  51684. getClassName(): string;
  51685. /**
  51686. * Gets the rgba input component
  51687. */
  51688. readonly rgba: NodeMaterialConnectionPoint;
  51689. /**
  51690. * Gets the rgb input component
  51691. */
  51692. readonly rgb: NodeMaterialConnectionPoint;
  51693. /**
  51694. * Gets the a input component
  51695. */
  51696. readonly a: NodeMaterialConnectionPoint;
  51697. protected _buildBlock(state: NodeMaterialBuildState): this;
  51698. }
  51699. }
  51700. declare module BABYLON {
  51701. /**
  51702. * Interface used to configure the node material editor
  51703. */
  51704. export interface INodeMaterialEditorOptions {
  51705. /** Define the URl to load node editor script */
  51706. editorURL?: string;
  51707. }
  51708. /** @hidden */
  51709. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  51710. /** BONES */
  51711. NUM_BONE_INFLUENCERS: number;
  51712. BonesPerMesh: number;
  51713. BONETEXTURE: boolean;
  51714. /** MORPH TARGETS */
  51715. MORPHTARGETS: boolean;
  51716. MORPHTARGETS_NORMAL: boolean;
  51717. MORPHTARGETS_TANGENT: boolean;
  51718. MORPHTARGETS_UV: boolean;
  51719. NUM_MORPH_INFLUENCERS: number;
  51720. /** IMAGE PROCESSING */
  51721. IMAGEPROCESSING: boolean;
  51722. VIGNETTE: boolean;
  51723. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51724. VIGNETTEBLENDMODEOPAQUE: boolean;
  51725. TONEMAPPING: boolean;
  51726. TONEMAPPING_ACES: boolean;
  51727. CONTRAST: boolean;
  51728. EXPOSURE: boolean;
  51729. COLORCURVES: boolean;
  51730. COLORGRADING: boolean;
  51731. COLORGRADING3D: boolean;
  51732. SAMPLER3DGREENDEPTH: boolean;
  51733. SAMPLER3DBGRMAP: boolean;
  51734. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51735. constructor();
  51736. setValue(name: string, value: boolean): void;
  51737. }
  51738. /**
  51739. * Class used to configure NodeMaterial
  51740. */
  51741. export interface INodeMaterialOptions {
  51742. /**
  51743. * Defines if blocks should emit comments
  51744. */
  51745. emitComments: boolean;
  51746. }
  51747. /**
  51748. * Class used to create a node based material built by assembling shader blocks
  51749. */
  51750. export class NodeMaterial extends PushMaterial {
  51751. private static _BuildIdGenerator;
  51752. private _options;
  51753. private _vertexCompilationState;
  51754. private _fragmentCompilationState;
  51755. private _sharedData;
  51756. private _buildId;
  51757. private _buildWasSuccessful;
  51758. private _cachedWorldViewMatrix;
  51759. private _cachedWorldViewProjectionMatrix;
  51760. private _optimizers;
  51761. private _animationFrame;
  51762. /** Define the URl to load node editor script */
  51763. static EditorURL: string;
  51764. private BJSNODEMATERIALEDITOR;
  51765. /** Get the inspector from bundle or global */
  51766. private _getGlobalNodeMaterialEditor;
  51767. /**
  51768. * 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)
  51769. */
  51770. ignoreAlpha: boolean;
  51771. /**
  51772. * Defines the maximum number of lights that can be used in the material
  51773. */
  51774. maxSimultaneousLights: number;
  51775. /**
  51776. * Observable raised when the material is built
  51777. */
  51778. onBuildObservable: Observable<NodeMaterial>;
  51779. /**
  51780. * Gets or sets the root nodes of the material vertex shader
  51781. */
  51782. _vertexOutputNodes: NodeMaterialBlock[];
  51783. /**
  51784. * Gets or sets the root nodes of the material fragment (pixel) shader
  51785. */
  51786. _fragmentOutputNodes: NodeMaterialBlock[];
  51787. /** Gets or sets options to control the node material overall behavior */
  51788. options: INodeMaterialOptions;
  51789. /**
  51790. * Default configuration related to image processing available in the standard Material.
  51791. */
  51792. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51793. /**
  51794. * Gets the image processing configuration used either in this material.
  51795. */
  51796. /**
  51797. * Sets the Default image processing configuration used either in the this material.
  51798. *
  51799. * If sets to null, the scene one is in use.
  51800. */
  51801. imageProcessingConfiguration: ImageProcessingConfiguration;
  51802. /**
  51803. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  51804. */
  51805. attachedBlocks: NodeMaterialBlock[];
  51806. /**
  51807. * Create a new node based material
  51808. * @param name defines the material name
  51809. * @param scene defines the hosting scene
  51810. * @param options defines creation option
  51811. */
  51812. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  51813. /**
  51814. * Gets the current class name of the material e.g. "NodeMaterial"
  51815. * @returns the class name
  51816. */
  51817. getClassName(): string;
  51818. /**
  51819. * Keep track of the image processing observer to allow dispose and replace.
  51820. */
  51821. private _imageProcessingObserver;
  51822. /**
  51823. * Attaches a new image processing configuration to the Standard Material.
  51824. * @param configuration
  51825. */
  51826. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51827. /**
  51828. * Adds a new optimizer to the list of optimizers
  51829. * @param optimizer defines the optimizers to add
  51830. * @returns the current material
  51831. */
  51832. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51833. /**
  51834. * Remove an optimizer from the list of optimizers
  51835. * @param optimizer defines the optimizers to remove
  51836. * @returns the current material
  51837. */
  51838. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51839. /**
  51840. * Add a new block to the list of output nodes
  51841. * @param node defines the node to add
  51842. * @returns the current material
  51843. */
  51844. addOutputNode(node: NodeMaterialBlock): this;
  51845. /**
  51846. * Remove a block from the list of root nodes
  51847. * @param node defines the node to remove
  51848. * @returns the current material
  51849. */
  51850. removeOutputNode(node: NodeMaterialBlock): this;
  51851. private _addVertexOutputNode;
  51852. private _removeVertexOutputNode;
  51853. private _addFragmentOutputNode;
  51854. private _removeFragmentOutputNode;
  51855. /**
  51856. * Specifies if the material will require alpha blending
  51857. * @returns a boolean specifying if alpha blending is needed
  51858. */
  51859. needAlphaBlending(): boolean;
  51860. /**
  51861. * Specifies if this material should be rendered in alpha test mode
  51862. * @returns a boolean specifying if an alpha test is needed.
  51863. */
  51864. needAlphaTesting(): boolean;
  51865. private _initializeBlock;
  51866. private _resetDualBlocks;
  51867. /**
  51868. * Build the material and generates the inner effect
  51869. * @param verbose defines if the build should log activity
  51870. */
  51871. build(verbose?: boolean): void;
  51872. /**
  51873. * Runs an otpimization phase to try to improve the shader code
  51874. */
  51875. optimize(): void;
  51876. private _prepareDefinesForAttributes;
  51877. /**
  51878. * Get if the submesh is ready to be used and all its information available.
  51879. * Child classes can use it to update shaders
  51880. * @param mesh defines the mesh to check
  51881. * @param subMesh defines which submesh to check
  51882. * @param useInstances specifies that instances should be used
  51883. * @returns a boolean indicating that the submesh is ready or not
  51884. */
  51885. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51886. /**
  51887. * Get a string representing the shaders built by the current node graph
  51888. */
  51889. readonly compiledShaders: string;
  51890. /**
  51891. * Binds the world matrix to the material
  51892. * @param world defines the world transformation matrix
  51893. */
  51894. bindOnlyWorldMatrix(world: Matrix): void;
  51895. /**
  51896. * Binds the submesh to this material by preparing the effect and shader to draw
  51897. * @param world defines the world transformation matrix
  51898. * @param mesh defines the mesh containing the submesh
  51899. * @param subMesh defines the submesh to bind the material to
  51900. */
  51901. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51902. /**
  51903. * Gets the active textures from the material
  51904. * @returns an array of textures
  51905. */
  51906. getActiveTextures(): BaseTexture[];
  51907. /**
  51908. * Specifies if the material uses a texture
  51909. * @param texture defines the texture to check against the material
  51910. * @returns a boolean specifying if the material uses the texture
  51911. */
  51912. hasTexture(texture: BaseTexture): boolean;
  51913. /**
  51914. * Disposes the material
  51915. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  51916. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  51917. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  51918. */
  51919. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  51920. /** Creates the node editor window. */
  51921. private _createNodeEditor;
  51922. /**
  51923. * Launch the node material editor
  51924. * @param config Define the configuration of the editor
  51925. * @return a promise fulfilled when the node editor is visible
  51926. */
  51927. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  51928. /**
  51929. * Clear the current material
  51930. */
  51931. clear(): void;
  51932. /**
  51933. * Clear the current material and set it to a default state
  51934. */
  51935. setToDefault(): void;
  51936. private _gatherBlocks;
  51937. /**
  51938. * Serializes this material in a JSON representation
  51939. * @returns the serialized material object
  51940. */
  51941. serialize(): any;
  51942. /**
  51943. * Clear the current graph and load a new one from a serialization object
  51944. * @param source defines the JSON representation of the material
  51945. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  51946. */
  51947. loadFromSerialization(source: any, rootUrl?: string): void;
  51948. /**
  51949. * Creates a node material from parsed material data
  51950. * @param source defines the JSON representation of the material
  51951. * @param scene defines the hosting scene
  51952. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  51953. * @returns a new node material
  51954. */
  51955. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  51956. }
  51957. }
  51958. declare module BABYLON {
  51959. /**
  51960. * Block used to read a texture from a sampler
  51961. */
  51962. export class TextureBlock extends NodeMaterialBlock {
  51963. private _defineName;
  51964. private _samplerName;
  51965. private _transformedUVName;
  51966. private _textureTransformName;
  51967. private _textureInfoName;
  51968. private _mainUVName;
  51969. private _mainUVDefineName;
  51970. /**
  51971. * Gets or sets the texture associated with the node
  51972. */
  51973. texture: Nullable<BaseTexture>;
  51974. /**
  51975. * Create a new TextureBlock
  51976. * @param name defines the block name
  51977. */
  51978. constructor(name: string);
  51979. /**
  51980. * Gets the current class name
  51981. * @returns the class name
  51982. */
  51983. getClassName(): string;
  51984. /**
  51985. * Gets the uv input component
  51986. */
  51987. readonly uv: NodeMaterialConnectionPoint;
  51988. /**
  51989. * Gets the rgba output component
  51990. */
  51991. readonly rgba: NodeMaterialConnectionPoint;
  51992. /**
  51993. * Gets the rgb output component
  51994. */
  51995. readonly rgb: NodeMaterialConnectionPoint;
  51996. /**
  51997. * Gets the r output component
  51998. */
  51999. readonly r: NodeMaterialConnectionPoint;
  52000. /**
  52001. * Gets the g output component
  52002. */
  52003. readonly g: NodeMaterialConnectionPoint;
  52004. /**
  52005. * Gets the b output component
  52006. */
  52007. readonly b: NodeMaterialConnectionPoint;
  52008. /**
  52009. * Gets the a output component
  52010. */
  52011. readonly a: NodeMaterialConnectionPoint;
  52012. autoConfigure(): void;
  52013. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52014. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52015. isReady(): boolean;
  52016. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52017. private _injectVertexCode;
  52018. private _writeOutput;
  52019. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52020. serialize(): any;
  52021. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52022. }
  52023. }
  52024. declare module BABYLON {
  52025. /**
  52026. * Enum used to define well known values e.g. values automatically provided by the system
  52027. */
  52028. export enum NodeMaterialWellKnownValues {
  52029. /** World */
  52030. World = 1,
  52031. /** View */
  52032. View = 2,
  52033. /** Projection */
  52034. Projection = 3,
  52035. /** ViewProjection */
  52036. ViewProjection = 4,
  52037. /** WorldView */
  52038. WorldView = 5,
  52039. /** WorldViewProjection */
  52040. WorldViewProjection = 6,
  52041. /** CameraPosition */
  52042. CameraPosition = 7,
  52043. /** Fog Color */
  52044. FogColor = 8
  52045. }
  52046. }
  52047. declare module BABYLON {
  52048. /**
  52049. * Block used to read a reflection texture from a sampler
  52050. */
  52051. export class ReflectionTextureBlock extends NodeMaterialBlock {
  52052. private _define3DName;
  52053. private _defineCubicName;
  52054. private _defineExplicitName;
  52055. private _defineProjectionName;
  52056. private _defineLocalCubicName;
  52057. private _defineSphericalName;
  52058. private _definePlanarName;
  52059. private _defineEquirectangularName;
  52060. private _defineMirroredEquirectangularFixedName;
  52061. private _defineEquirectangularFixedName;
  52062. private _defineSkyboxName;
  52063. private _cubeSamplerName;
  52064. private _2DSamplerName;
  52065. private _positionUVWName;
  52066. private _directionWName;
  52067. private _reflectionCoordsName;
  52068. private _reflection2DCoordsName;
  52069. private _reflectionColorName;
  52070. private _reflectionMatrixName;
  52071. /**
  52072. * Gets or sets the texture associated with the node
  52073. */
  52074. texture: Nullable<BaseTexture>;
  52075. /**
  52076. * Create a new TextureBlock
  52077. * @param name defines the block name
  52078. */
  52079. constructor(name: string);
  52080. /**
  52081. * Gets the current class name
  52082. * @returns the class name
  52083. */
  52084. getClassName(): string;
  52085. /**
  52086. * Gets the world position input component
  52087. */
  52088. readonly position: NodeMaterialConnectionPoint;
  52089. /**
  52090. * Gets the world position input component
  52091. */
  52092. readonly worldPosition: NodeMaterialConnectionPoint;
  52093. /**
  52094. * Gets the world normal input component
  52095. */
  52096. readonly worldNormal: NodeMaterialConnectionPoint;
  52097. /**
  52098. * Gets the world input component
  52099. */
  52100. readonly world: NodeMaterialConnectionPoint;
  52101. /**
  52102. * Gets the camera (or eye) position component
  52103. */
  52104. readonly cameraPosition: NodeMaterialConnectionPoint;
  52105. /**
  52106. * Gets the view input component
  52107. */
  52108. readonly view: NodeMaterialConnectionPoint;
  52109. /**
  52110. * Gets the rgb output component
  52111. */
  52112. readonly rgb: NodeMaterialConnectionPoint;
  52113. /**
  52114. * Gets the r output component
  52115. */
  52116. readonly r: NodeMaterialConnectionPoint;
  52117. /**
  52118. * Gets the g output component
  52119. */
  52120. readonly g: NodeMaterialConnectionPoint;
  52121. /**
  52122. * Gets the b output component
  52123. */
  52124. readonly b: NodeMaterialConnectionPoint;
  52125. autoConfigure(): void;
  52126. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52127. isReady(): boolean;
  52128. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52129. private _injectVertexCode;
  52130. private _writeOutput;
  52131. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52132. serialize(): any;
  52133. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52134. }
  52135. }
  52136. declare module BABYLON {
  52137. /**
  52138. * Class used to store shared data between 2 NodeMaterialBuildState
  52139. */
  52140. export class NodeMaterialBuildStateSharedData {
  52141. /**
  52142. * Gets the list of emitted varyings
  52143. */
  52144. varyings: string[];
  52145. /**
  52146. * Gets the varying declaration string
  52147. */
  52148. varyingDeclaration: string;
  52149. /**
  52150. * Input blocks
  52151. */
  52152. inputBlocks: InputBlock[];
  52153. /**
  52154. * Input blocks
  52155. */
  52156. textureBlocks: (TextureBlock | ReflectionTextureBlock)[];
  52157. /**
  52158. * Bindable blocks (Blocks that need to set data to the effect)
  52159. */
  52160. bindableBlocks: NodeMaterialBlock[];
  52161. /**
  52162. * List of blocks that can provide a compilation fallback
  52163. */
  52164. blocksWithFallbacks: NodeMaterialBlock[];
  52165. /**
  52166. * List of blocks that can provide a define update
  52167. */
  52168. blocksWithDefines: NodeMaterialBlock[];
  52169. /**
  52170. * List of blocks that can provide a repeatable content
  52171. */
  52172. repeatableContentBlocks: NodeMaterialBlock[];
  52173. /**
  52174. * List of blocks that can provide a dynamic list of uniforms
  52175. */
  52176. dynamicUniformBlocks: NodeMaterialBlock[];
  52177. /**
  52178. * List of blocks that can block the isReady function for the material
  52179. */
  52180. blockingBlocks: NodeMaterialBlock[];
  52181. /**
  52182. * Gets the list of animated inputs
  52183. */
  52184. animatedInputs: InputBlock[];
  52185. /**
  52186. * Build Id used to avoid multiple recompilations
  52187. */
  52188. buildId: number;
  52189. /** List of emitted variables */
  52190. variableNames: {
  52191. [key: string]: number;
  52192. };
  52193. /** List of emitted defines */
  52194. defineNames: {
  52195. [key: string]: number;
  52196. };
  52197. /** Should emit comments? */
  52198. emitComments: boolean;
  52199. /** Emit build activity */
  52200. verbose: boolean;
  52201. /**
  52202. * Gets the compilation hints emitted at compilation time
  52203. */
  52204. hints: {
  52205. needWorldViewMatrix: boolean;
  52206. needWorldViewProjectionMatrix: boolean;
  52207. needAlphaBlending: boolean;
  52208. needAlphaTesting: boolean;
  52209. };
  52210. /**
  52211. * List of compilation checks
  52212. */
  52213. checks: {
  52214. emitVertex: boolean;
  52215. emitFragment: boolean;
  52216. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  52217. };
  52218. /** Creates a new shared data */
  52219. constructor();
  52220. /**
  52221. * Emits console errors and exceptions if there is a failing check
  52222. */
  52223. emitErrors(): void;
  52224. }
  52225. }
  52226. declare module BABYLON {
  52227. /**
  52228. * Class used to store node based material build state
  52229. */
  52230. export class NodeMaterialBuildState {
  52231. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  52232. supportUniformBuffers: boolean;
  52233. /**
  52234. * Gets the list of emitted attributes
  52235. */
  52236. attributes: string[];
  52237. /**
  52238. * Gets the list of emitted uniforms
  52239. */
  52240. uniforms: string[];
  52241. /**
  52242. * Gets the list of emitted uniform buffers
  52243. */
  52244. uniformBuffers: string[];
  52245. /**
  52246. * Gets the list of emitted samplers
  52247. */
  52248. samplers: string[];
  52249. /**
  52250. * Gets the list of emitted functions
  52251. */
  52252. functions: {
  52253. [key: string]: string;
  52254. };
  52255. /**
  52256. * Gets the target of the compilation state
  52257. */
  52258. target: NodeMaterialBlockTargets;
  52259. /**
  52260. * Gets the list of emitted counters
  52261. */
  52262. counters: {
  52263. [key: string]: number;
  52264. };
  52265. /**
  52266. * Shared data between multiple NodeMaterialBuildState instances
  52267. */
  52268. sharedData: NodeMaterialBuildStateSharedData;
  52269. /** @hidden */
  52270. _vertexState: NodeMaterialBuildState;
  52271. /** @hidden */
  52272. _attributeDeclaration: string;
  52273. /** @hidden */
  52274. _uniformDeclaration: string;
  52275. /** @hidden */
  52276. _samplerDeclaration: string;
  52277. /** @hidden */
  52278. _varyingTransfer: string;
  52279. private _repeatableContentAnchorIndex;
  52280. /** @hidden */
  52281. _builtCompilationString: string;
  52282. /**
  52283. * Gets the emitted compilation strings
  52284. */
  52285. compilationString: string;
  52286. /**
  52287. * Finalize the compilation strings
  52288. * @param state defines the current compilation state
  52289. */
  52290. finalize(state: NodeMaterialBuildState): void;
  52291. /** @hidden */
  52292. readonly _repeatableContentAnchor: string;
  52293. /** @hidden */
  52294. _getFreeVariableName(prefix: string): string;
  52295. /** @hidden */
  52296. _getFreeDefineName(prefix: string): string;
  52297. /** @hidden */
  52298. _excludeVariableName(name: string): void;
  52299. /** @hidden */
  52300. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  52301. /** @hidden */
  52302. _emitFunction(name: string, code: string, comments: string): void;
  52303. /** @hidden */
  52304. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  52305. replaceStrings?: {
  52306. search: RegExp;
  52307. replace: string;
  52308. }[];
  52309. repeatKey?: string;
  52310. }): string;
  52311. /** @hidden */
  52312. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  52313. repeatKey?: string;
  52314. removeAttributes?: boolean;
  52315. removeUniforms?: boolean;
  52316. removeVaryings?: boolean;
  52317. removeIfDef?: boolean;
  52318. replaceStrings?: {
  52319. search: RegExp;
  52320. replace: string;
  52321. }[];
  52322. }, storeKey?: string): void;
  52323. /** @hidden */
  52324. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  52325. /** @hidden */
  52326. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  52327. }
  52328. }
  52329. declare module BABYLON {
  52330. /**
  52331. * Defines a block that can be used inside a node based material
  52332. */
  52333. export class NodeMaterialBlock {
  52334. private _buildId;
  52335. private _buildTarget;
  52336. private _target;
  52337. private _isFinalMerger;
  52338. private _isInput;
  52339. /** @hidden */
  52340. _inputs: NodeMaterialConnectionPoint[];
  52341. /** @hidden */
  52342. _outputs: NodeMaterialConnectionPoint[];
  52343. /**
  52344. * Gets or sets the name of the block
  52345. */
  52346. name: string;
  52347. /**
  52348. * Gets or sets the unique id of the node
  52349. */
  52350. uniqueId: number;
  52351. /**
  52352. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  52353. */
  52354. readonly isFinalMerger: boolean;
  52355. /**
  52356. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  52357. */
  52358. readonly isInput: boolean;
  52359. /**
  52360. * Gets or sets the build Id
  52361. */
  52362. buildId: number;
  52363. /**
  52364. * Gets or sets the target of the block
  52365. */
  52366. target: NodeMaterialBlockTargets;
  52367. /**
  52368. * Gets the list of input points
  52369. */
  52370. readonly inputs: NodeMaterialConnectionPoint[];
  52371. /** Gets the list of output points */
  52372. readonly outputs: NodeMaterialConnectionPoint[];
  52373. /**
  52374. * Find an input by its name
  52375. * @param name defines the name of the input to look for
  52376. * @returns the input or null if not found
  52377. */
  52378. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52379. /**
  52380. * Find an output by its name
  52381. * @param name defines the name of the outputto look for
  52382. * @returns the output or null if not found
  52383. */
  52384. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52385. /**
  52386. * Creates a new NodeMaterialBlock
  52387. * @param name defines the block name
  52388. * @param target defines the target of that block (Vertex by default)
  52389. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  52390. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  52391. */
  52392. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  52393. /**
  52394. * Initialize the block and prepare the context for build
  52395. * @param state defines the state that will be used for the build
  52396. */
  52397. initialize(state: NodeMaterialBuildState): void;
  52398. /**
  52399. * Bind data to effect. Will only be called for blocks with isBindable === true
  52400. * @param effect defines the effect to bind data to
  52401. * @param nodeMaterial defines the hosting NodeMaterial
  52402. * @param mesh defines the mesh that will be rendered
  52403. */
  52404. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52405. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  52406. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  52407. protected _writeFloat(value: number): string;
  52408. /**
  52409. * Gets the current class name e.g. "NodeMaterialBlock"
  52410. * @returns the class name
  52411. */
  52412. getClassName(): string;
  52413. /**
  52414. * Register a new input. Must be called inside a block constructor
  52415. * @param name defines the connection point name
  52416. * @param type defines the connection point type
  52417. * @param isOptional defines a boolean indicating that this input can be omitted
  52418. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  52419. * @returns the current block
  52420. */
  52421. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  52422. /**
  52423. * Register a new output. Must be called inside a block constructor
  52424. * @param name defines the connection point name
  52425. * @param type defines the connection point type
  52426. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  52427. * @returns the current block
  52428. */
  52429. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  52430. /**
  52431. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  52432. * @param forOutput defines an optional connection point to check compatibility with
  52433. * @returns the first available input or null
  52434. */
  52435. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  52436. /**
  52437. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  52438. * @param forBlock defines an optional block to check compatibility with
  52439. * @returns the first available input or null
  52440. */
  52441. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  52442. /**
  52443. * Gets the sibling of the given output
  52444. * @param current defines the current output
  52445. * @returns the next output in the list or null
  52446. */
  52447. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  52448. /**
  52449. * Connect current block with another block
  52450. * @param other defines the block to connect with
  52451. * @param options define the various options to help pick the right connections
  52452. * @returns the current block
  52453. */
  52454. connectTo(other: NodeMaterialBlock, options?: {
  52455. input?: string;
  52456. output?: string;
  52457. outputSwizzle?: string;
  52458. }): this | undefined;
  52459. protected _buildBlock(state: NodeMaterialBuildState): void;
  52460. /**
  52461. * Add uniforms, samplers and uniform buffers at compilation time
  52462. * @param state defines the state to update
  52463. * @param nodeMaterial defines the node material requesting the update
  52464. * @param defines defines the material defines to update
  52465. */
  52466. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52467. /**
  52468. * Add potential fallbacks if shader compilation fails
  52469. * @param mesh defines the mesh to be rendered
  52470. * @param fallbacks defines the current prioritized list of fallbacks
  52471. */
  52472. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52473. /**
  52474. * Update defines for shader compilation
  52475. * @param mesh defines the mesh to be rendered
  52476. * @param nodeMaterial defines the node material requesting the update
  52477. * @param defines defines the material defines to update
  52478. * @param useInstances specifies that instances should be used
  52479. */
  52480. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52481. /**
  52482. * Initialize defines for shader compilation
  52483. * @param mesh defines the mesh to be rendered
  52484. * @param nodeMaterial defines the node material requesting the update
  52485. * @param defines defines the material defines to be prepared
  52486. * @param useInstances specifies that instances should be used
  52487. */
  52488. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52489. /**
  52490. * Lets the block try to connect some inputs automatically
  52491. */
  52492. autoConfigure(): void;
  52493. /**
  52494. * Function called when a block is declared as repeatable content generator
  52495. * @param vertexShaderState defines the current compilation state for the vertex shader
  52496. * @param fragmentShaderState defines the current compilation state for the fragment shader
  52497. * @param mesh defines the mesh to be rendered
  52498. * @param defines defines the material defines to update
  52499. */
  52500. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52501. /**
  52502. * Checks if the block is ready
  52503. * @param mesh defines the mesh to be rendered
  52504. * @param nodeMaterial defines the node material requesting the update
  52505. * @param defines defines the material defines to update
  52506. * @param useInstances specifies that instances should be used
  52507. * @returns true if the block is ready
  52508. */
  52509. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  52510. private _processBuild;
  52511. /**
  52512. * Compile the current node and generate the shader code
  52513. * @param state defines the current compilation state (uniforms, samplers, current string)
  52514. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  52515. * @returns true if already built
  52516. */
  52517. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  52518. /**
  52519. * Clone the current block to a new identical block
  52520. * @param scene defines the hosting scene
  52521. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52522. * @returns a copy of the current block
  52523. */
  52524. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  52525. /**
  52526. * Serializes this block in a JSON representation
  52527. * @returns the serialized block object
  52528. */
  52529. serialize(): any;
  52530. /** @hidden */
  52531. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52532. }
  52533. }
  52534. declare module BABYLON {
  52535. /**
  52536. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52537. */
  52538. export enum NodeMaterialBlockConnectionPointMode {
  52539. /** Value is an uniform */
  52540. Uniform = 0,
  52541. /** Value is a mesh attribute */
  52542. Attribute = 1,
  52543. /** Value is a varying between vertex and fragment shaders */
  52544. Varying = 2,
  52545. /** Mode is undefined */
  52546. Undefined = 3
  52547. }
  52548. }
  52549. declare module BABYLON {
  52550. /**
  52551. * Enum defining the type of animations supported by InputBlock
  52552. */
  52553. export enum AnimatedInputBlockTypes {
  52554. /** No animation */
  52555. None = 0,
  52556. /** Time based animation. Will only work for floats */
  52557. Time = 1
  52558. }
  52559. }
  52560. declare module BABYLON {
  52561. /**
  52562. * Block used to expose an input value
  52563. */
  52564. export class InputBlock extends NodeMaterialBlock {
  52565. private _mode;
  52566. private _associatedVariableName;
  52567. private _storedValue;
  52568. private _valueCallback;
  52569. private _type;
  52570. private _animationType;
  52571. /** @hidden */
  52572. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  52573. /**
  52574. * Gets or sets the connection point type (default is float)
  52575. */
  52576. readonly type: NodeMaterialBlockConnectionPointTypes;
  52577. /**
  52578. * Creates a new InputBlock
  52579. * @param name defines the block name
  52580. * @param target defines the target of that block (Vertex by default)
  52581. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  52582. */
  52583. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  52584. /**
  52585. * Gets the output component
  52586. */
  52587. readonly output: NodeMaterialConnectionPoint;
  52588. /**
  52589. * Set the source of this connection point to a vertex attribute
  52590. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  52591. * @returns the current connection point
  52592. */
  52593. setAsAttribute(attributeName?: string): InputBlock;
  52594. /**
  52595. * Set the source of this connection point to a well known value
  52596. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  52597. * @returns the current connection point
  52598. */
  52599. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  52600. /**
  52601. * Gets or sets the value of that point.
  52602. * Please note that this value will be ignored if valueCallback is defined
  52603. */
  52604. value: any;
  52605. /**
  52606. * Gets or sets a callback used to get the value of that point.
  52607. * Please note that setting this value will force the connection point to ignore the value property
  52608. */
  52609. valueCallback: () => any;
  52610. /**
  52611. * Gets or sets the associated variable name in the shader
  52612. */
  52613. associatedVariableName: string;
  52614. /** Gets or sets the type of animation applied to the input */
  52615. animationType: AnimatedInputBlockTypes;
  52616. /**
  52617. * Gets a boolean indicating that this connection point not defined yet
  52618. */
  52619. readonly isUndefined: boolean;
  52620. /**
  52621. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  52622. * In this case the connection point name must be the name of the uniform to use.
  52623. * Can only be set on inputs
  52624. */
  52625. isUniform: boolean;
  52626. /**
  52627. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  52628. * In this case the connection point name must be the name of the attribute to use
  52629. * Can only be set on inputs
  52630. */
  52631. isAttribute: boolean;
  52632. /**
  52633. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  52634. * Can only be set on exit points
  52635. */
  52636. isVarying: boolean;
  52637. /**
  52638. * Gets a boolean indicating that the current connection point is a well known value
  52639. */
  52640. readonly isWellKnownValue: boolean;
  52641. /**
  52642. * Gets or sets the current well known value or null if not defined as well know value
  52643. */
  52644. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  52645. /**
  52646. * Gets the current class name
  52647. * @returns the class name
  52648. */
  52649. getClassName(): string;
  52650. /**
  52651. * Animate the input if animationType !== None
  52652. * @param scene defines the rendering scene
  52653. */
  52654. animate(scene: Scene): void;
  52655. private _emitDefine;
  52656. /**
  52657. * Set the input block to its default value (based on its type)
  52658. */
  52659. setDefaultValue(): void;
  52660. private _emit;
  52661. /** @hidden */
  52662. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  52663. /** @hidden */
  52664. _transmit(effect: Effect, scene: Scene): void;
  52665. protected _buildBlock(state: NodeMaterialBuildState): void;
  52666. serialize(): any;
  52667. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52668. }
  52669. }
  52670. declare module BABYLON {
  52671. /**
  52672. * Defines a connection point for a block
  52673. */
  52674. export class NodeMaterialConnectionPoint {
  52675. /** @hidden */
  52676. _ownerBlock: NodeMaterialBlock;
  52677. /** @hidden */
  52678. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52679. private _endpoints;
  52680. private _associatedVariableName;
  52681. /** @hidden */
  52682. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  52683. private _type;
  52684. /** @hidden */
  52685. _enforceAssociatedVariableName: boolean;
  52686. /**
  52687. * Gets or sets the additional types supported byt this connection point
  52688. */
  52689. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  52690. /**
  52691. * Gets or sets the associated variable name in the shader
  52692. */
  52693. associatedVariableName: string;
  52694. /**
  52695. * Gets or sets the connection point type (default is float)
  52696. */
  52697. type: NodeMaterialBlockConnectionPointTypes;
  52698. /**
  52699. * Gets or sets the connection point name
  52700. */
  52701. name: string;
  52702. /**
  52703. * Gets or sets a boolean indicating that this connection point can be omitted
  52704. */
  52705. isOptional: boolean;
  52706. /**
  52707. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  52708. */
  52709. define: string;
  52710. /** Gets or sets the target of that connection point */
  52711. target: NodeMaterialBlockTargets;
  52712. /**
  52713. * Gets a boolean indicating that the current point is connected
  52714. */
  52715. readonly isConnected: boolean;
  52716. /**
  52717. * Gets a boolean indicating that the current point is connected to an input block
  52718. */
  52719. readonly isConnectedToInput: boolean;
  52720. /**
  52721. * Gets a the connected input block (if any)
  52722. */
  52723. readonly connectInputBlock: Nullable<InputBlock>;
  52724. /** Get the other side of the connection (if any) */
  52725. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52726. /** Get the block that owns this connection point */
  52727. readonly ownerBlock: NodeMaterialBlock;
  52728. /** Get the block connected on the other side of this connection (if any) */
  52729. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  52730. /** Get the block connected on the endpoints of this connection (if any) */
  52731. readonly connectedBlocks: Array<NodeMaterialBlock>;
  52732. /** Gets the list of connected endpoints */
  52733. readonly endpoints: NodeMaterialConnectionPoint[];
  52734. /**
  52735. * Creates a new connection point
  52736. * @param name defines the connection point name
  52737. * @param ownerBlock defines the block hosting this connection point
  52738. */
  52739. constructor(name: string, ownerBlock: NodeMaterialBlock);
  52740. /**
  52741. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  52742. * @returns the class name
  52743. */
  52744. getClassName(): string;
  52745. /**
  52746. * Gets an boolean indicating if the current point can be connected to another point
  52747. * @param connectionPoint defines the other connection point
  52748. * @returns true if the connection is possible
  52749. */
  52750. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  52751. /**
  52752. * Connect this point to another connection point
  52753. * @param connectionPoint defines the other connection point
  52754. * @returns the current connection point
  52755. */
  52756. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  52757. /**
  52758. * Disconnect this point from one of his endpoint
  52759. * @param endpoint defines the other connection point
  52760. * @returns the current connection point
  52761. */
  52762. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  52763. /**
  52764. * Serializes this point in a JSON representation
  52765. * @returns the serialized point object
  52766. */
  52767. serialize(): any;
  52768. }
  52769. }
  52770. declare module BABYLON {
  52771. /**
  52772. * Block used to add support for vertex skinning (bones)
  52773. */
  52774. export class BonesBlock extends NodeMaterialBlock {
  52775. /**
  52776. * Creates a new BonesBlock
  52777. * @param name defines the block name
  52778. */
  52779. constructor(name: string);
  52780. /**
  52781. * Initialize the block and prepare the context for build
  52782. * @param state defines the state that will be used for the build
  52783. */
  52784. initialize(state: NodeMaterialBuildState): void;
  52785. /**
  52786. * Gets the current class name
  52787. * @returns the class name
  52788. */
  52789. getClassName(): string;
  52790. /**
  52791. * Gets the matrix indices input component
  52792. */
  52793. readonly matricesIndices: NodeMaterialConnectionPoint;
  52794. /**
  52795. * Gets the matrix weights input component
  52796. */
  52797. readonly matricesWeights: NodeMaterialConnectionPoint;
  52798. /**
  52799. * Gets the extra matrix indices input component
  52800. */
  52801. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  52802. /**
  52803. * Gets the extra matrix weights input component
  52804. */
  52805. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  52806. /**
  52807. * Gets the world input component
  52808. */
  52809. readonly world: NodeMaterialConnectionPoint;
  52810. /**
  52811. * Gets the output component
  52812. */
  52813. readonly output: NodeMaterialConnectionPoint;
  52814. autoConfigure(): void;
  52815. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52816. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52817. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52818. protected _buildBlock(state: NodeMaterialBuildState): this;
  52819. }
  52820. }
  52821. declare module BABYLON {
  52822. /**
  52823. * Block used to add support for instances
  52824. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  52825. */
  52826. export class InstancesBlock extends NodeMaterialBlock {
  52827. /**
  52828. * Creates a new InstancesBlock
  52829. * @param name defines the block name
  52830. */
  52831. constructor(name: string);
  52832. /**
  52833. * Gets the current class name
  52834. * @returns the class name
  52835. */
  52836. getClassName(): string;
  52837. /**
  52838. * Gets the first world row input component
  52839. */
  52840. readonly world0: NodeMaterialConnectionPoint;
  52841. /**
  52842. * Gets the second world row input component
  52843. */
  52844. readonly world1: NodeMaterialConnectionPoint;
  52845. /**
  52846. * Gets the third world row input component
  52847. */
  52848. readonly world2: NodeMaterialConnectionPoint;
  52849. /**
  52850. * Gets the forth world row input component
  52851. */
  52852. readonly world3: NodeMaterialConnectionPoint;
  52853. /**
  52854. * Gets the world input component
  52855. */
  52856. readonly world: NodeMaterialConnectionPoint;
  52857. /**
  52858. * Gets the output component
  52859. */
  52860. readonly output: NodeMaterialConnectionPoint;
  52861. autoConfigure(): void;
  52862. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52863. protected _buildBlock(state: NodeMaterialBuildState): this;
  52864. }
  52865. }
  52866. declare module BABYLON {
  52867. /**
  52868. * Block used to add morph targets support to vertex shader
  52869. */
  52870. export class MorphTargetsBlock extends NodeMaterialBlock {
  52871. private _repeatableContentAnchor;
  52872. private _repeatebleContentGenerated;
  52873. /**
  52874. * Create a new MorphTargetsBlock
  52875. * @param name defines the block name
  52876. */
  52877. constructor(name: string);
  52878. /**
  52879. * Gets the current class name
  52880. * @returns the class name
  52881. */
  52882. getClassName(): string;
  52883. /**
  52884. * Gets the position input component
  52885. */
  52886. readonly position: NodeMaterialConnectionPoint;
  52887. /**
  52888. * Gets the normal input component
  52889. */
  52890. readonly normal: NodeMaterialConnectionPoint;
  52891. /**
  52892. * Gets the tangent input component
  52893. */
  52894. readonly tangent: NodeMaterialConnectionPoint;
  52895. /**
  52896. * Gets the tangent input component
  52897. */
  52898. readonly uv: NodeMaterialConnectionPoint;
  52899. /**
  52900. * Gets the position output component
  52901. */
  52902. readonly positionOutput: NodeMaterialConnectionPoint;
  52903. /**
  52904. * Gets the normal output component
  52905. */
  52906. readonly normalOutput: NodeMaterialConnectionPoint;
  52907. /**
  52908. * Gets the tangent output component
  52909. */
  52910. readonly tangentOutput: NodeMaterialConnectionPoint;
  52911. /**
  52912. * Gets the tangent output component
  52913. */
  52914. readonly uvOutput: NodeMaterialConnectionPoint;
  52915. initialize(state: NodeMaterialBuildState): void;
  52916. autoConfigure(): void;
  52917. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52918. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52919. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52920. protected _buildBlock(state: NodeMaterialBuildState): this;
  52921. }
  52922. }
  52923. declare module BABYLON {
  52924. /**
  52925. * Block used to add an alpha test in the fragment shader
  52926. */
  52927. export class AlphaTestBlock extends NodeMaterialBlock {
  52928. /**
  52929. * Gets or sets the alpha value where alpha testing happens
  52930. */
  52931. alphaCutOff: number;
  52932. /**
  52933. * Create a new AlphaTestBlock
  52934. * @param name defines the block name
  52935. */
  52936. constructor(name: string);
  52937. /**
  52938. * Gets the current class name
  52939. * @returns the class name
  52940. */
  52941. getClassName(): string;
  52942. /**
  52943. * Gets the color input component
  52944. */
  52945. readonly color: NodeMaterialConnectionPoint;
  52946. /**
  52947. * Gets the alpha input component
  52948. */
  52949. readonly alpha: NodeMaterialConnectionPoint;
  52950. protected _buildBlock(state: NodeMaterialBuildState): this;
  52951. }
  52952. }
  52953. declare module BABYLON {
  52954. /**
  52955. * Block used to create a Color3/4 out of individual inputs (one for each component)
  52956. */
  52957. export class ColorMergerBlock extends NodeMaterialBlock {
  52958. /**
  52959. * Create a new ColorMergerBlock
  52960. * @param name defines the block name
  52961. */
  52962. constructor(name: string);
  52963. /**
  52964. * Gets the current class name
  52965. * @returns the class name
  52966. */
  52967. getClassName(): string;
  52968. /**
  52969. * Gets the r component (input)
  52970. */
  52971. readonly r: NodeMaterialConnectionPoint;
  52972. /**
  52973. * Gets the g component (input)
  52974. */
  52975. readonly g: NodeMaterialConnectionPoint;
  52976. /**
  52977. * Gets the b component (input)
  52978. */
  52979. readonly b: NodeMaterialConnectionPoint;
  52980. /**
  52981. * Gets the a component (input)
  52982. */
  52983. readonly a: NodeMaterialConnectionPoint;
  52984. /**
  52985. * Gets the rgba component (output)
  52986. */
  52987. readonly rgba: NodeMaterialConnectionPoint;
  52988. /**
  52989. * Gets the rgb component (output)
  52990. */
  52991. readonly rgb: NodeMaterialConnectionPoint;
  52992. protected _buildBlock(state: NodeMaterialBuildState): this;
  52993. }
  52994. }
  52995. declare module BABYLON {
  52996. /**
  52997. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  52998. */
  52999. export class VectorMergerBlock extends NodeMaterialBlock {
  53000. /**
  53001. * Create a new VectorMergerBlock
  53002. * @param name defines the block name
  53003. */
  53004. constructor(name: string);
  53005. /**
  53006. * Gets the current class name
  53007. * @returns the class name
  53008. */
  53009. getClassName(): string;
  53010. /**
  53011. * Gets the x component (input)
  53012. */
  53013. readonly x: NodeMaterialConnectionPoint;
  53014. /**
  53015. * Gets the y component (input)
  53016. */
  53017. readonly y: NodeMaterialConnectionPoint;
  53018. /**
  53019. * Gets the z component (input)
  53020. */
  53021. readonly z: NodeMaterialConnectionPoint;
  53022. /**
  53023. * Gets the w component (input)
  53024. */
  53025. readonly w: NodeMaterialConnectionPoint;
  53026. /**
  53027. * Gets the xyzw component (output)
  53028. */
  53029. readonly xyzw: NodeMaterialConnectionPoint;
  53030. /**
  53031. * Gets the xyz component (output)
  53032. */
  53033. readonly xyz: NodeMaterialConnectionPoint;
  53034. /**
  53035. * Gets the xy component (output)
  53036. */
  53037. readonly xy: NodeMaterialConnectionPoint;
  53038. protected _buildBlock(state: NodeMaterialBuildState): this;
  53039. }
  53040. }
  53041. declare module BABYLON {
  53042. /**
  53043. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  53044. */
  53045. export class ColorSplitterBlock extends NodeMaterialBlock {
  53046. /**
  53047. * Create a new ColorSplitterBlock
  53048. * @param name defines the block name
  53049. */
  53050. constructor(name: string);
  53051. /**
  53052. * Gets the current class name
  53053. * @returns the class name
  53054. */
  53055. getClassName(): string;
  53056. /**
  53057. * Gets the rgba component (input)
  53058. */
  53059. readonly rgba: NodeMaterialConnectionPoint;
  53060. /**
  53061. * Gets the rgb component (input)
  53062. */
  53063. readonly rgbIn: NodeMaterialConnectionPoint;
  53064. /**
  53065. * Gets the rgb component (output)
  53066. */
  53067. readonly rgbOut: NodeMaterialConnectionPoint;
  53068. /**
  53069. * Gets the r component (output)
  53070. */
  53071. readonly r: NodeMaterialConnectionPoint;
  53072. /**
  53073. * Gets the g component (output)
  53074. */
  53075. readonly g: NodeMaterialConnectionPoint;
  53076. /**
  53077. * Gets the b component (output)
  53078. */
  53079. readonly b: NodeMaterialConnectionPoint;
  53080. /**
  53081. * Gets the a component (output)
  53082. */
  53083. readonly a: NodeMaterialConnectionPoint;
  53084. protected _buildBlock(state: NodeMaterialBuildState): this;
  53085. }
  53086. }
  53087. declare module BABYLON {
  53088. /**
  53089. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  53090. */
  53091. export class VectorSplitterBlock extends NodeMaterialBlock {
  53092. /**
  53093. * Create a new VectorSplitterBlock
  53094. * @param name defines the block name
  53095. */
  53096. constructor(name: string);
  53097. /**
  53098. * Gets the current class name
  53099. * @returns the class name
  53100. */
  53101. getClassName(): string;
  53102. /**
  53103. * Gets the xyzw component (input)
  53104. */
  53105. readonly xyzw: NodeMaterialConnectionPoint;
  53106. /**
  53107. * Gets the xyz component (input)
  53108. */
  53109. readonly xyzIn: NodeMaterialConnectionPoint;
  53110. /**
  53111. * Gets the xy component (input)
  53112. */
  53113. readonly xyIn: NodeMaterialConnectionPoint;
  53114. /**
  53115. * Gets the xyz component (output)
  53116. */
  53117. readonly xyzOut: NodeMaterialConnectionPoint;
  53118. /**
  53119. * Gets the xy component (output)
  53120. */
  53121. readonly xyOut: NodeMaterialConnectionPoint;
  53122. /**
  53123. * Gets the x component (output)
  53124. */
  53125. readonly x: NodeMaterialConnectionPoint;
  53126. /**
  53127. * Gets the y component (output)
  53128. */
  53129. readonly y: NodeMaterialConnectionPoint;
  53130. /**
  53131. * Gets the z component (output)
  53132. */
  53133. readonly z: NodeMaterialConnectionPoint;
  53134. /**
  53135. * Gets the w component (output)
  53136. */
  53137. readonly w: NodeMaterialConnectionPoint;
  53138. protected _buildBlock(state: NodeMaterialBuildState): this;
  53139. }
  53140. }
  53141. declare module BABYLON {
  53142. /**
  53143. * Block used to add image processing support to fragment shader
  53144. */
  53145. export class ImageProcessingBlock extends NodeMaterialBlock {
  53146. /**
  53147. * Create a new ImageProcessingBlock
  53148. * @param name defines the block name
  53149. */
  53150. constructor(name: string);
  53151. /**
  53152. * Gets the current class name
  53153. * @returns the class name
  53154. */
  53155. getClassName(): string;
  53156. /**
  53157. * Gets the color input component
  53158. */
  53159. readonly color: NodeMaterialConnectionPoint;
  53160. /**
  53161. * Gets the output component
  53162. */
  53163. readonly output: NodeMaterialConnectionPoint;
  53164. /**
  53165. * Initialize the block and prepare the context for build
  53166. * @param state defines the state that will be used for the build
  53167. */
  53168. initialize(state: NodeMaterialBuildState): void;
  53169. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  53170. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53171. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53172. protected _buildBlock(state: NodeMaterialBuildState): this;
  53173. }
  53174. }
  53175. declare module BABYLON {
  53176. /**
  53177. * Block used to add support for scene fog
  53178. */
  53179. export class FogBlock extends NodeMaterialBlock {
  53180. private _fogDistanceName;
  53181. private _fogParameters;
  53182. /**
  53183. * Create a new FogBlock
  53184. * @param name defines the block name
  53185. */
  53186. constructor(name: string);
  53187. /**
  53188. * Gets the current class name
  53189. * @returns the class name
  53190. */
  53191. getClassName(): string;
  53192. /**
  53193. * Gets the world position input component
  53194. */
  53195. readonly worldPosition: NodeMaterialConnectionPoint;
  53196. /**
  53197. * Gets the view input component
  53198. */
  53199. readonly view: NodeMaterialConnectionPoint;
  53200. /**
  53201. * Gets the color input component
  53202. */
  53203. readonly color: NodeMaterialConnectionPoint;
  53204. /**
  53205. * Gets the fog color input component
  53206. */
  53207. readonly fogColor: NodeMaterialConnectionPoint;
  53208. /**
  53209. * Gets the output component
  53210. */
  53211. readonly output: NodeMaterialConnectionPoint;
  53212. autoConfigure(): void;
  53213. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53214. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53215. protected _buildBlock(state: NodeMaterialBuildState): this;
  53216. }
  53217. }
  53218. declare module BABYLON {
  53219. /**
  53220. * Block used to add light in the fragment shader
  53221. */
  53222. export class LightBlock extends NodeMaterialBlock {
  53223. private _lightId;
  53224. /**
  53225. * Gets or sets the light associated with this block
  53226. */
  53227. light: Nullable<Light>;
  53228. /**
  53229. * Create a new LightBlock
  53230. * @param name defines the block name
  53231. */
  53232. constructor(name: string);
  53233. /**
  53234. * Gets the current class name
  53235. * @returns the class name
  53236. */
  53237. getClassName(): string;
  53238. /**
  53239. * Gets the world position input component
  53240. */
  53241. readonly worldPosition: NodeMaterialConnectionPoint;
  53242. /**
  53243. * Gets the world normal input component
  53244. */
  53245. readonly worldNormal: NodeMaterialConnectionPoint;
  53246. /**
  53247. * Gets the camera (or eye) position component
  53248. */
  53249. readonly cameraPosition: NodeMaterialConnectionPoint;
  53250. /**
  53251. * Gets the diffuse output component
  53252. */
  53253. readonly diffuseOutput: NodeMaterialConnectionPoint;
  53254. /**
  53255. * Gets the specular output component
  53256. */
  53257. readonly specularOutput: NodeMaterialConnectionPoint;
  53258. autoConfigure(): void;
  53259. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53260. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53261. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53262. private _injectVertexCode;
  53263. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53264. serialize(): any;
  53265. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53266. }
  53267. }
  53268. declare module BABYLON {
  53269. /**
  53270. * Block used to multiply 2 values
  53271. */
  53272. export class MultiplyBlock extends NodeMaterialBlock {
  53273. /**
  53274. * Creates a new MultiplyBlock
  53275. * @param name defines the block name
  53276. */
  53277. constructor(name: string);
  53278. /**
  53279. * Gets the current class name
  53280. * @returns the class name
  53281. */
  53282. getClassName(): string;
  53283. /**
  53284. * Gets the left operand input component
  53285. */
  53286. readonly left: NodeMaterialConnectionPoint;
  53287. /**
  53288. * Gets the right operand input component
  53289. */
  53290. readonly right: NodeMaterialConnectionPoint;
  53291. /**
  53292. * Gets the output component
  53293. */
  53294. readonly output: NodeMaterialConnectionPoint;
  53295. protected _buildBlock(state: NodeMaterialBuildState): this;
  53296. }
  53297. }
  53298. declare module BABYLON {
  53299. /**
  53300. * Block used to add 2 vectors
  53301. */
  53302. export class AddBlock extends NodeMaterialBlock {
  53303. /**
  53304. * Creates a new AddBlock
  53305. * @param name defines the block name
  53306. */
  53307. constructor(name: string);
  53308. /**
  53309. * Gets the current class name
  53310. * @returns the class name
  53311. */
  53312. getClassName(): string;
  53313. /**
  53314. * Gets the left operand input component
  53315. */
  53316. readonly left: NodeMaterialConnectionPoint;
  53317. /**
  53318. * Gets the right operand input component
  53319. */
  53320. readonly right: NodeMaterialConnectionPoint;
  53321. /**
  53322. * Gets the output component
  53323. */
  53324. readonly output: NodeMaterialConnectionPoint;
  53325. protected _buildBlock(state: NodeMaterialBuildState): this;
  53326. }
  53327. }
  53328. declare module BABYLON {
  53329. /**
  53330. * Block used to scale a vector by a float
  53331. */
  53332. export class ScaleBlock extends NodeMaterialBlock {
  53333. /**
  53334. * Creates a new ScaleBlock
  53335. * @param name defines the block name
  53336. */
  53337. constructor(name: string);
  53338. /**
  53339. * Gets the current class name
  53340. * @returns the class name
  53341. */
  53342. getClassName(): string;
  53343. /**
  53344. * Gets the input component
  53345. */
  53346. readonly input: NodeMaterialConnectionPoint;
  53347. /**
  53348. * Gets the factor input component
  53349. */
  53350. readonly factor: NodeMaterialConnectionPoint;
  53351. /**
  53352. * Gets the output component
  53353. */
  53354. readonly output: NodeMaterialConnectionPoint;
  53355. protected _buildBlock(state: NodeMaterialBuildState): this;
  53356. }
  53357. }
  53358. declare module BABYLON {
  53359. /**
  53360. * Block used to clamp a float
  53361. */
  53362. export class ClampBlock extends NodeMaterialBlock {
  53363. /** Gets or sets the minimum range */
  53364. minimum: number;
  53365. /** Gets or sets the maximum range */
  53366. maximum: number;
  53367. /**
  53368. * Creates a new ClampBlock
  53369. * @param name defines the block name
  53370. */
  53371. constructor(name: string);
  53372. /**
  53373. * Gets the current class name
  53374. * @returns the class name
  53375. */
  53376. getClassName(): string;
  53377. /**
  53378. * Gets the value input component
  53379. */
  53380. readonly value: NodeMaterialConnectionPoint;
  53381. /**
  53382. * Gets the output component
  53383. */
  53384. readonly output: NodeMaterialConnectionPoint;
  53385. protected _buildBlock(state: NodeMaterialBuildState): this;
  53386. }
  53387. }
  53388. declare module BABYLON {
  53389. /**
  53390. * Block used to apply a cross product between 2 vectors
  53391. */
  53392. export class CrossBlock extends NodeMaterialBlock {
  53393. /**
  53394. * Creates a new CrossBlock
  53395. * @param name defines the block name
  53396. */
  53397. constructor(name: string);
  53398. /**
  53399. * Gets the current class name
  53400. * @returns the class name
  53401. */
  53402. getClassName(): string;
  53403. /**
  53404. * Gets the left operand input component
  53405. */
  53406. readonly left: NodeMaterialConnectionPoint;
  53407. /**
  53408. * Gets the right operand input component
  53409. */
  53410. readonly right: NodeMaterialConnectionPoint;
  53411. /**
  53412. * Gets the output component
  53413. */
  53414. readonly output: NodeMaterialConnectionPoint;
  53415. protected _buildBlock(state: NodeMaterialBuildState): this;
  53416. }
  53417. }
  53418. declare module BABYLON {
  53419. /**
  53420. * Block used to apply a dot product between 2 vectors
  53421. */
  53422. export class DotBlock extends NodeMaterialBlock {
  53423. /**
  53424. * Creates a new DotBlock
  53425. * @param name defines the block name
  53426. */
  53427. constructor(name: string);
  53428. /**
  53429. * Gets the current class name
  53430. * @returns the class name
  53431. */
  53432. getClassName(): string;
  53433. /**
  53434. * Gets the left operand input component
  53435. */
  53436. readonly left: NodeMaterialConnectionPoint;
  53437. /**
  53438. * Gets the right operand input component
  53439. */
  53440. readonly right: NodeMaterialConnectionPoint;
  53441. /**
  53442. * Gets the output component
  53443. */
  53444. readonly output: NodeMaterialConnectionPoint;
  53445. protected _buildBlock(state: NodeMaterialBuildState): this;
  53446. }
  53447. }
  53448. declare module BABYLON {
  53449. /**
  53450. * Block used to remap a float from a range to a new one
  53451. */
  53452. export class RemapBlock extends NodeMaterialBlock {
  53453. /**
  53454. * Gets or sets the source range
  53455. */
  53456. sourceRange: Vector2;
  53457. /**
  53458. * Gets or sets the target range
  53459. */
  53460. targetRange: Vector2;
  53461. /**
  53462. * Creates a new RemapBlock
  53463. * @param name defines the block name
  53464. */
  53465. constructor(name: string);
  53466. /**
  53467. * Gets the current class name
  53468. * @returns the class name
  53469. */
  53470. getClassName(): string;
  53471. /**
  53472. * Gets the input component
  53473. */
  53474. readonly input: NodeMaterialConnectionPoint;
  53475. /**
  53476. * Gets the output component
  53477. */
  53478. readonly output: NodeMaterialConnectionPoint;
  53479. protected _buildBlock(state: NodeMaterialBuildState): this;
  53480. }
  53481. }
  53482. declare module BABYLON {
  53483. /**
  53484. * Block used to normalize a vector
  53485. */
  53486. export class NormalizeBlock extends NodeMaterialBlock {
  53487. /**
  53488. * Creates a new NormalizeBlock
  53489. * @param name defines the block name
  53490. */
  53491. constructor(name: string);
  53492. /**
  53493. * Gets the current class name
  53494. * @returns the class name
  53495. */
  53496. getClassName(): string;
  53497. /**
  53498. * Gets the input component
  53499. */
  53500. readonly input: NodeMaterialConnectionPoint;
  53501. /**
  53502. * Gets the output component
  53503. */
  53504. readonly output: NodeMaterialConnectionPoint;
  53505. protected _buildBlock(state: NodeMaterialBuildState): this;
  53506. }
  53507. }
  53508. declare module BABYLON {
  53509. /**
  53510. * Operations supported by the Trigonometry block
  53511. */
  53512. export enum TrigonometryBlockOperations {
  53513. /** Cos */
  53514. Cos = 0,
  53515. /** Sin */
  53516. Sin = 1,
  53517. /** Abs */
  53518. Abs = 2
  53519. }
  53520. /**
  53521. * Block used to apply trigonometry operation to floats
  53522. */
  53523. export class TrigonometryBlock extends NodeMaterialBlock {
  53524. /**
  53525. * Gets or sets the operation applied by the block
  53526. */
  53527. operation: TrigonometryBlockOperations;
  53528. /**
  53529. * Creates a new TrigonometryBlock
  53530. * @param name defines the block name
  53531. */
  53532. constructor(name: string);
  53533. /**
  53534. * Gets the current class name
  53535. * @returns the class name
  53536. */
  53537. getClassName(): string;
  53538. /**
  53539. * Gets the input component
  53540. */
  53541. readonly input: NodeMaterialConnectionPoint;
  53542. /**
  53543. * Gets the output component
  53544. */
  53545. readonly output: NodeMaterialConnectionPoint;
  53546. protected _buildBlock(state: NodeMaterialBuildState): this;
  53547. }
  53548. }
  53549. declare module BABYLON {
  53550. /**
  53551. * Effect Render Options
  53552. */
  53553. export interface IEffectRendererOptions {
  53554. /**
  53555. * Defines the vertices positions.
  53556. */
  53557. positions?: number[];
  53558. /**
  53559. * Defines the indices.
  53560. */
  53561. indices?: number[];
  53562. }
  53563. /**
  53564. * Helper class to render one or more effects
  53565. */
  53566. export class EffectRenderer {
  53567. private engine;
  53568. private static _DefaultOptions;
  53569. private _vertexBuffers;
  53570. private _indexBuffer;
  53571. private _ringBufferIndex;
  53572. private _ringScreenBuffer;
  53573. private _fullscreenViewport;
  53574. private _getNextFrameBuffer;
  53575. /**
  53576. * Creates an effect renderer
  53577. * @param engine the engine to use for rendering
  53578. * @param options defines the options of the effect renderer
  53579. */
  53580. constructor(engine: Engine, options?: IEffectRendererOptions);
  53581. /**
  53582. * Sets the current viewport in normalized coordinates 0-1
  53583. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  53584. */
  53585. setViewport(viewport?: Viewport): void;
  53586. /**
  53587. * Sets the current effect wrapper to use during draw.
  53588. * The effect needs to be ready before calling this api.
  53589. * This also sets the default full screen position attribute.
  53590. * @param effectWrapper Defines the effect to draw with
  53591. */
  53592. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  53593. /**
  53594. * Draws a full screen quad.
  53595. */
  53596. draw(): void;
  53597. /**
  53598. * renders one or more effects to a specified texture
  53599. * @param effectWrappers list of effects to renderer
  53600. * @param outputTexture texture to draw to, if null it will render to the screen
  53601. */
  53602. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  53603. /**
  53604. * Disposes of the effect renderer
  53605. */
  53606. dispose(): void;
  53607. }
  53608. /**
  53609. * Options to create an EffectWrapper
  53610. */
  53611. interface EffectWrapperCreationOptions {
  53612. /**
  53613. * Engine to use to create the effect
  53614. */
  53615. engine: Engine;
  53616. /**
  53617. * Fragment shader for the effect
  53618. */
  53619. fragmentShader: string;
  53620. /**
  53621. * Vertex shader for the effect
  53622. */
  53623. vertexShader?: string;
  53624. /**
  53625. * Attributes to use in the shader
  53626. */
  53627. attributeNames?: Array<string>;
  53628. /**
  53629. * Uniforms to use in the shader
  53630. */
  53631. uniformNames?: Array<string>;
  53632. /**
  53633. * Texture sampler names to use in the shader
  53634. */
  53635. samplerNames?: Array<string>;
  53636. /**
  53637. * The friendly name of the effect displayed in Spector.
  53638. */
  53639. name?: string;
  53640. }
  53641. /**
  53642. * Wraps an effect to be used for rendering
  53643. */
  53644. export class EffectWrapper {
  53645. /**
  53646. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  53647. */
  53648. onApplyObservable: Observable<{}>;
  53649. /**
  53650. * The underlying effect
  53651. */
  53652. effect: Effect;
  53653. /**
  53654. * Creates an effect to be renderer
  53655. * @param creationOptions options to create the effect
  53656. */
  53657. constructor(creationOptions: EffectWrapperCreationOptions);
  53658. /**
  53659. * Disposes of the effect wrapper
  53660. */
  53661. dispose(): void;
  53662. }
  53663. }
  53664. declare module BABYLON {
  53665. /**
  53666. * Helper class to push actions to a pool of workers.
  53667. */
  53668. export class WorkerPool implements IDisposable {
  53669. private _workerInfos;
  53670. private _pendingActions;
  53671. /**
  53672. * Constructor
  53673. * @param workers Array of workers to use for actions
  53674. */
  53675. constructor(workers: Array<Worker>);
  53676. /**
  53677. * Terminates all workers and clears any pending actions.
  53678. */
  53679. dispose(): void;
  53680. /**
  53681. * Pushes an action to the worker pool. If all the workers are active, the action will be
  53682. * pended until a worker has completed its action.
  53683. * @param action The action to perform. Call onComplete when the action is complete.
  53684. */
  53685. push(action: (worker: Worker, onComplete: () => void) => void): void;
  53686. private _execute;
  53687. }
  53688. }
  53689. declare module BABYLON {
  53690. /**
  53691. * Configuration for Draco compression
  53692. */
  53693. export interface IDracoCompressionConfiguration {
  53694. /**
  53695. * Configuration for the decoder.
  53696. */
  53697. decoder: {
  53698. /**
  53699. * The url to the WebAssembly module.
  53700. */
  53701. wasmUrl?: string;
  53702. /**
  53703. * The url to the WebAssembly binary.
  53704. */
  53705. wasmBinaryUrl?: string;
  53706. /**
  53707. * The url to the fallback JavaScript module.
  53708. */
  53709. fallbackUrl?: string;
  53710. };
  53711. }
  53712. /**
  53713. * Draco compression (https://google.github.io/draco/)
  53714. *
  53715. * This class wraps the Draco module.
  53716. *
  53717. * **Encoder**
  53718. *
  53719. * The encoder is not currently implemented.
  53720. *
  53721. * **Decoder**
  53722. *
  53723. * 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.
  53724. *
  53725. * To update the configuration, use the following code:
  53726. * ```javascript
  53727. * DracoCompression.Configuration = {
  53728. * decoder: {
  53729. * wasmUrl: "<url to the WebAssembly library>",
  53730. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  53731. * fallbackUrl: "<url to the fallback JavaScript library>",
  53732. * }
  53733. * };
  53734. * ```
  53735. *
  53736. * 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.
  53737. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  53738. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  53739. *
  53740. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  53741. * ```javascript
  53742. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  53743. * ```
  53744. *
  53745. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  53746. */
  53747. export class DracoCompression implements IDisposable {
  53748. private _workerPoolPromise?;
  53749. private _decoderModulePromise?;
  53750. /**
  53751. * The configuration. Defaults to the following urls:
  53752. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  53753. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  53754. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  53755. */
  53756. static Configuration: IDracoCompressionConfiguration;
  53757. /**
  53758. * Returns true if the decoder configuration is available.
  53759. */
  53760. static readonly DecoderAvailable: boolean;
  53761. /**
  53762. * Default number of workers to create when creating the draco compression object.
  53763. */
  53764. static DefaultNumWorkers: number;
  53765. private static GetDefaultNumWorkers;
  53766. private static _Default;
  53767. /**
  53768. * Default instance for the draco compression object.
  53769. */
  53770. static readonly Default: DracoCompression;
  53771. /**
  53772. * Constructor
  53773. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  53774. */
  53775. constructor(numWorkers?: number);
  53776. /**
  53777. * Stop all async operations and release resources.
  53778. */
  53779. dispose(): void;
  53780. /**
  53781. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  53782. * @returns a promise that resolves when ready
  53783. */
  53784. whenReadyAsync(): Promise<void>;
  53785. /**
  53786. * Decode Draco compressed mesh data to vertex data.
  53787. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  53788. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  53789. * @returns A promise that resolves with the decoded vertex data
  53790. */
  53791. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  53792. [kind: string]: number;
  53793. }): Promise<VertexData>;
  53794. }
  53795. }
  53796. declare module BABYLON {
  53797. /**
  53798. * Class for building Constructive Solid Geometry
  53799. */
  53800. export class CSG {
  53801. private polygons;
  53802. /**
  53803. * The world matrix
  53804. */
  53805. matrix: Matrix;
  53806. /**
  53807. * Stores the position
  53808. */
  53809. position: Vector3;
  53810. /**
  53811. * Stores the rotation
  53812. */
  53813. rotation: Vector3;
  53814. /**
  53815. * Stores the rotation quaternion
  53816. */
  53817. rotationQuaternion: Nullable<Quaternion>;
  53818. /**
  53819. * Stores the scaling vector
  53820. */
  53821. scaling: Vector3;
  53822. /**
  53823. * Convert the Mesh to CSG
  53824. * @param mesh The Mesh to convert to CSG
  53825. * @returns A new CSG from the Mesh
  53826. */
  53827. static FromMesh(mesh: Mesh): CSG;
  53828. /**
  53829. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  53830. * @param polygons Polygons used to construct a CSG solid
  53831. */
  53832. private static FromPolygons;
  53833. /**
  53834. * Clones, or makes a deep copy, of the CSG
  53835. * @returns A new CSG
  53836. */
  53837. clone(): CSG;
  53838. /**
  53839. * Unions this CSG with another CSG
  53840. * @param csg The CSG to union against this CSG
  53841. * @returns The unioned CSG
  53842. */
  53843. union(csg: CSG): CSG;
  53844. /**
  53845. * Unions this CSG with another CSG in place
  53846. * @param csg The CSG to union against this CSG
  53847. */
  53848. unionInPlace(csg: CSG): void;
  53849. /**
  53850. * Subtracts this CSG with another CSG
  53851. * @param csg The CSG to subtract against this CSG
  53852. * @returns A new CSG
  53853. */
  53854. subtract(csg: CSG): CSG;
  53855. /**
  53856. * Subtracts this CSG with another CSG in place
  53857. * @param csg The CSG to subtact against this CSG
  53858. */
  53859. subtractInPlace(csg: CSG): void;
  53860. /**
  53861. * Intersect this CSG with another CSG
  53862. * @param csg The CSG to intersect against this CSG
  53863. * @returns A new CSG
  53864. */
  53865. intersect(csg: CSG): CSG;
  53866. /**
  53867. * Intersects this CSG with another CSG in place
  53868. * @param csg The CSG to intersect against this CSG
  53869. */
  53870. intersectInPlace(csg: CSG): void;
  53871. /**
  53872. * Return a new CSG solid with solid and empty space switched. This solid is
  53873. * not modified.
  53874. * @returns A new CSG solid with solid and empty space switched
  53875. */
  53876. inverse(): CSG;
  53877. /**
  53878. * Inverses the CSG in place
  53879. */
  53880. inverseInPlace(): void;
  53881. /**
  53882. * This is used to keep meshes transformations so they can be restored
  53883. * when we build back a Babylon Mesh
  53884. * NB : All CSG operations are performed in world coordinates
  53885. * @param csg The CSG to copy the transform attributes from
  53886. * @returns This CSG
  53887. */
  53888. copyTransformAttributes(csg: CSG): CSG;
  53889. /**
  53890. * Build Raw mesh from CSG
  53891. * Coordinates here are in world space
  53892. * @param name The name of the mesh geometry
  53893. * @param scene The Scene
  53894. * @param keepSubMeshes Specifies if the submeshes should be kept
  53895. * @returns A new Mesh
  53896. */
  53897. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  53898. /**
  53899. * Build Mesh from CSG taking material and transforms into account
  53900. * @param name The name of the Mesh
  53901. * @param material The material of the Mesh
  53902. * @param scene The Scene
  53903. * @param keepSubMeshes Specifies if submeshes should be kept
  53904. * @returns The new Mesh
  53905. */
  53906. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  53907. }
  53908. }
  53909. declare module BABYLON {
  53910. /**
  53911. * Class used to create a trail following a mesh
  53912. */
  53913. export class TrailMesh extends Mesh {
  53914. private _generator;
  53915. private _autoStart;
  53916. private _running;
  53917. private _diameter;
  53918. private _length;
  53919. private _sectionPolygonPointsCount;
  53920. private _sectionVectors;
  53921. private _sectionNormalVectors;
  53922. private _beforeRenderObserver;
  53923. /**
  53924. * @constructor
  53925. * @param name The value used by scene.getMeshByName() to do a lookup.
  53926. * @param generator The mesh to generate a trail.
  53927. * @param scene The scene to add this mesh to.
  53928. * @param diameter Diameter of trailing mesh. Default is 1.
  53929. * @param length Length of trailing mesh. Default is 60.
  53930. * @param autoStart Automatically start trailing mesh. Default true.
  53931. */
  53932. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  53933. /**
  53934. * "TrailMesh"
  53935. * @returns "TrailMesh"
  53936. */
  53937. getClassName(): string;
  53938. private _createMesh;
  53939. /**
  53940. * Start trailing mesh.
  53941. */
  53942. start(): void;
  53943. /**
  53944. * Stop trailing mesh.
  53945. */
  53946. stop(): void;
  53947. /**
  53948. * Update trailing mesh geometry.
  53949. */
  53950. update(): void;
  53951. /**
  53952. * Returns a new TrailMesh object.
  53953. * @param name is a string, the name given to the new mesh
  53954. * @param newGenerator use new generator object for cloned trail mesh
  53955. * @returns a new mesh
  53956. */
  53957. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  53958. /**
  53959. * Serializes this trail mesh
  53960. * @param serializationObject object to write serialization to
  53961. */
  53962. serialize(serializationObject: any): void;
  53963. /**
  53964. * Parses a serialized trail mesh
  53965. * @param parsedMesh the serialized mesh
  53966. * @param scene the scene to create the trail mesh in
  53967. * @returns the created trail mesh
  53968. */
  53969. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  53970. }
  53971. }
  53972. declare module BABYLON {
  53973. /**
  53974. * Class containing static functions to help procedurally build meshes
  53975. */
  53976. export class TiledBoxBuilder {
  53977. /**
  53978. * Creates a box mesh
  53979. * 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)
  53980. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53981. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53982. * * 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
  53983. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53984. * @param name defines the name of the mesh
  53985. * @param options defines the options used to create the mesh
  53986. * @param scene defines the hosting scene
  53987. * @returns the box mesh
  53988. */
  53989. static CreateTiledBox(name: string, options: {
  53990. pattern?: number;
  53991. width?: number;
  53992. height?: number;
  53993. depth?: number;
  53994. tileSize?: number;
  53995. tileWidth?: number;
  53996. tileHeight?: number;
  53997. alignHorizontal?: number;
  53998. alignVertical?: number;
  53999. faceUV?: Vector4[];
  54000. faceColors?: Color4[];
  54001. sideOrientation?: number;
  54002. updatable?: boolean;
  54003. }, scene?: Nullable<Scene>): Mesh;
  54004. }
  54005. }
  54006. declare module BABYLON {
  54007. /**
  54008. * Class containing static functions to help procedurally build meshes
  54009. */
  54010. export class TorusKnotBuilder {
  54011. /**
  54012. * Creates a torus knot mesh
  54013. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  54014. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  54015. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  54016. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  54017. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54018. * * 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
  54019. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54020. * @param name defines the name of the mesh
  54021. * @param options defines the options used to create the mesh
  54022. * @param scene defines the hosting scene
  54023. * @returns the torus knot mesh
  54024. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54025. */
  54026. static CreateTorusKnot(name: string, options: {
  54027. radius?: number;
  54028. tube?: number;
  54029. radialSegments?: number;
  54030. tubularSegments?: number;
  54031. p?: number;
  54032. q?: number;
  54033. updatable?: boolean;
  54034. sideOrientation?: number;
  54035. frontUVs?: Vector4;
  54036. backUVs?: Vector4;
  54037. }, scene: any): Mesh;
  54038. }
  54039. }
  54040. declare module BABYLON {
  54041. /**
  54042. * Polygon
  54043. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  54044. */
  54045. export class Polygon {
  54046. /**
  54047. * Creates a rectangle
  54048. * @param xmin bottom X coord
  54049. * @param ymin bottom Y coord
  54050. * @param xmax top X coord
  54051. * @param ymax top Y coord
  54052. * @returns points that make the resulting rectation
  54053. */
  54054. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  54055. /**
  54056. * Creates a circle
  54057. * @param radius radius of circle
  54058. * @param cx scale in x
  54059. * @param cy scale in y
  54060. * @param numberOfSides number of sides that make up the circle
  54061. * @returns points that make the resulting circle
  54062. */
  54063. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  54064. /**
  54065. * Creates a polygon from input string
  54066. * @param input Input polygon data
  54067. * @returns the parsed points
  54068. */
  54069. static Parse(input: string): Vector2[];
  54070. /**
  54071. * Starts building a polygon from x and y coordinates
  54072. * @param x x coordinate
  54073. * @param y y coordinate
  54074. * @returns the started path2
  54075. */
  54076. static StartingAt(x: number, y: number): Path2;
  54077. }
  54078. /**
  54079. * Builds a polygon
  54080. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  54081. */
  54082. export class PolygonMeshBuilder {
  54083. private _points;
  54084. private _outlinepoints;
  54085. private _holes;
  54086. private _name;
  54087. private _scene;
  54088. private _epoints;
  54089. private _eholes;
  54090. private _addToepoint;
  54091. /**
  54092. * Babylon reference to the earcut plugin.
  54093. */
  54094. bjsEarcut: any;
  54095. /**
  54096. * Creates a PolygonMeshBuilder
  54097. * @param name name of the builder
  54098. * @param contours Path of the polygon
  54099. * @param scene scene to add to when creating the mesh
  54100. * @param earcutInjection can be used to inject your own earcut reference
  54101. */
  54102. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  54103. /**
  54104. * Adds a whole within the polygon
  54105. * @param hole Array of points defining the hole
  54106. * @returns this
  54107. */
  54108. addHole(hole: Vector2[]): PolygonMeshBuilder;
  54109. /**
  54110. * Creates the polygon
  54111. * @param updatable If the mesh should be updatable
  54112. * @param depth The depth of the mesh created
  54113. * @returns the created mesh
  54114. */
  54115. build(updatable?: boolean, depth?: number): Mesh;
  54116. /**
  54117. * Creates the polygon
  54118. * @param depth The depth of the mesh created
  54119. * @returns the created VertexData
  54120. */
  54121. buildVertexData(depth?: number): VertexData;
  54122. /**
  54123. * Adds a side to the polygon
  54124. * @param positions points that make the polygon
  54125. * @param normals normals of the polygon
  54126. * @param uvs uvs of the polygon
  54127. * @param indices indices of the polygon
  54128. * @param bounds bounds of the polygon
  54129. * @param points points of the polygon
  54130. * @param depth depth of the polygon
  54131. * @param flip flip of the polygon
  54132. */
  54133. private addSide;
  54134. }
  54135. }
  54136. declare module BABYLON {
  54137. /**
  54138. * Class containing static functions to help procedurally build meshes
  54139. */
  54140. export class PolygonBuilder {
  54141. /**
  54142. * Creates a polygon mesh
  54143. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  54144. * * 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
  54145. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54147. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  54148. * * Remember you can only change the shape positions, not their number when updating a polygon
  54149. * @param name defines the name of the mesh
  54150. * @param options defines the options used to create the mesh
  54151. * @param scene defines the hosting scene
  54152. * @param earcutInjection can be used to inject your own earcut reference
  54153. * @returns the polygon mesh
  54154. */
  54155. static CreatePolygon(name: string, options: {
  54156. shape: Vector3[];
  54157. holes?: Vector3[][];
  54158. depth?: number;
  54159. faceUV?: Vector4[];
  54160. faceColors?: Color4[];
  54161. updatable?: boolean;
  54162. sideOrientation?: number;
  54163. frontUVs?: Vector4;
  54164. backUVs?: Vector4;
  54165. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54166. /**
  54167. * Creates an extruded polygon mesh, with depth in the Y direction.
  54168. * * 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)
  54169. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54170. * @param name defines the name of the mesh
  54171. * @param options defines the options used to create the mesh
  54172. * @param scene defines the hosting scene
  54173. * @param earcutInjection can be used to inject your own earcut reference
  54174. * @returns the polygon mesh
  54175. */
  54176. static ExtrudePolygon(name: string, options: {
  54177. shape: Vector3[];
  54178. holes?: Vector3[][];
  54179. depth?: number;
  54180. faceUV?: Vector4[];
  54181. faceColors?: Color4[];
  54182. updatable?: boolean;
  54183. sideOrientation?: number;
  54184. frontUVs?: Vector4;
  54185. backUVs?: Vector4;
  54186. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54187. }
  54188. }
  54189. declare module BABYLON {
  54190. /**
  54191. * Class containing static functions to help procedurally build meshes
  54192. */
  54193. export class LatheBuilder {
  54194. /**
  54195. * Creates lathe mesh.
  54196. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  54197. * * 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
  54198. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  54199. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  54200. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  54201. * * 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
  54202. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  54203. * * 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
  54204. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54205. * * 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
  54206. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54208. * @param name defines the name of the mesh
  54209. * @param options defines the options used to create the mesh
  54210. * @param scene defines the hosting scene
  54211. * @returns the lathe mesh
  54212. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  54213. */
  54214. static CreateLathe(name: string, options: {
  54215. shape: Vector3[];
  54216. radius?: number;
  54217. tessellation?: number;
  54218. clip?: number;
  54219. arc?: number;
  54220. closed?: boolean;
  54221. updatable?: boolean;
  54222. sideOrientation?: number;
  54223. frontUVs?: Vector4;
  54224. backUVs?: Vector4;
  54225. cap?: number;
  54226. invertUV?: boolean;
  54227. }, scene?: Nullable<Scene>): Mesh;
  54228. }
  54229. }
  54230. declare module BABYLON {
  54231. /**
  54232. * Class containing static functions to help procedurally build meshes
  54233. */
  54234. export class TiledPlaneBuilder {
  54235. /**
  54236. * Creates a tiled plane mesh
  54237. * * The parameter `pattern` will, depending on value, do nothing or
  54238. * * * flip (reflect about central vertical) alternate tiles across and up
  54239. * * * flip every tile on alternate rows
  54240. * * * rotate (180 degs) alternate tiles across and up
  54241. * * * rotate every tile on alternate rows
  54242. * * * flip and rotate alternate tiles across and up
  54243. * * * flip and rotate every tile on alternate rows
  54244. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  54245. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  54246. * * 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
  54247. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54248. * * 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)
  54249. * * 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)
  54250. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54251. * @param name defines the name of the mesh
  54252. * @param options defines the options used to create the mesh
  54253. * @param scene defines the hosting scene
  54254. * @returns the box mesh
  54255. */
  54256. static CreateTiledPlane(name: string, options: {
  54257. pattern?: number;
  54258. tileSize?: number;
  54259. tileWidth?: number;
  54260. tileHeight?: number;
  54261. size?: number;
  54262. width?: number;
  54263. height?: number;
  54264. alignHorizontal?: number;
  54265. alignVertical?: number;
  54266. sideOrientation?: number;
  54267. frontUVs?: Vector4;
  54268. backUVs?: Vector4;
  54269. updatable?: boolean;
  54270. }, scene?: Nullable<Scene>): Mesh;
  54271. }
  54272. }
  54273. declare module BABYLON {
  54274. /**
  54275. * Class containing static functions to help procedurally build meshes
  54276. */
  54277. export class TubeBuilder {
  54278. /**
  54279. * Creates a tube mesh.
  54280. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54281. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  54282. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  54283. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  54284. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  54285. * * 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)
  54286. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  54287. * * 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
  54288. * * 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
  54289. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54290. * * 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
  54291. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54293. * @param name defines the name of the mesh
  54294. * @param options defines the options used to create the mesh
  54295. * @param scene defines the hosting scene
  54296. * @returns the tube mesh
  54297. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54298. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  54299. */
  54300. static CreateTube(name: string, options: {
  54301. path: Vector3[];
  54302. radius?: number;
  54303. tessellation?: number;
  54304. radiusFunction?: {
  54305. (i: number, distance: number): number;
  54306. };
  54307. cap?: number;
  54308. arc?: number;
  54309. updatable?: boolean;
  54310. sideOrientation?: number;
  54311. frontUVs?: Vector4;
  54312. backUVs?: Vector4;
  54313. instance?: Mesh;
  54314. invertUV?: boolean;
  54315. }, scene?: Nullable<Scene>): Mesh;
  54316. }
  54317. }
  54318. declare module BABYLON {
  54319. /**
  54320. * Class containing static functions to help procedurally build meshes
  54321. */
  54322. export class IcoSphereBuilder {
  54323. /**
  54324. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  54325. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  54326. * * 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`)
  54327. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  54328. * * 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
  54329. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54330. * * 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
  54331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54332. * @param name defines the name of the mesh
  54333. * @param options defines the options used to create the mesh
  54334. * @param scene defines the hosting scene
  54335. * @returns the icosahedron mesh
  54336. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  54337. */
  54338. static CreateIcoSphere(name: string, options: {
  54339. radius?: number;
  54340. radiusX?: number;
  54341. radiusY?: number;
  54342. radiusZ?: number;
  54343. flat?: boolean;
  54344. subdivisions?: number;
  54345. sideOrientation?: number;
  54346. frontUVs?: Vector4;
  54347. backUVs?: Vector4;
  54348. updatable?: boolean;
  54349. }, scene?: Nullable<Scene>): Mesh;
  54350. }
  54351. }
  54352. declare module BABYLON {
  54353. /**
  54354. * Class containing static functions to help procedurally build meshes
  54355. */
  54356. export class DecalBuilder {
  54357. /**
  54358. * Creates a decal mesh.
  54359. * 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
  54360. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  54361. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  54362. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  54363. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  54364. * @param name defines the name of the mesh
  54365. * @param sourceMesh defines the mesh where the decal must be applied
  54366. * @param options defines the options used to create the mesh
  54367. * @param scene defines the hosting scene
  54368. * @returns the decal mesh
  54369. * @see https://doc.babylonjs.com/how_to/decals
  54370. */
  54371. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  54372. position?: Vector3;
  54373. normal?: Vector3;
  54374. size?: Vector3;
  54375. angle?: number;
  54376. }): Mesh;
  54377. }
  54378. }
  54379. declare module BABYLON {
  54380. /**
  54381. * Class containing static functions to help procedurally build meshes
  54382. */
  54383. export class MeshBuilder {
  54384. /**
  54385. * Creates a box mesh
  54386. * * The parameter `size` sets the size (float) of each box side (default 1)
  54387. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54388. * * 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)
  54389. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54390. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54391. * * 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
  54392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54393. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54394. * @param name defines the name of the mesh
  54395. * @param options defines the options used to create the mesh
  54396. * @param scene defines the hosting scene
  54397. * @returns the box mesh
  54398. */
  54399. static CreateBox(name: string, options: {
  54400. size?: number;
  54401. width?: number;
  54402. height?: number;
  54403. depth?: number;
  54404. faceUV?: Vector4[];
  54405. faceColors?: Color4[];
  54406. sideOrientation?: number;
  54407. frontUVs?: Vector4;
  54408. backUVs?: Vector4;
  54409. updatable?: boolean;
  54410. }, scene?: Nullable<Scene>): Mesh;
  54411. /**
  54412. * Creates a tiled box mesh
  54413. * * faceTiles sets the pattern, tile size and number of tiles for a face
  54414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54415. * @param name defines the name of the mesh
  54416. * @param options defines the options used to create the mesh
  54417. * @param scene defines the hosting scene
  54418. * @returns the tiled box mesh
  54419. */
  54420. static CreateTiledBox(name: string, options: {
  54421. pattern?: number;
  54422. size?: number;
  54423. width?: number;
  54424. height?: number;
  54425. depth: number;
  54426. tileSize?: number;
  54427. tileWidth?: number;
  54428. tileHeight?: number;
  54429. faceUV?: Vector4[];
  54430. faceColors?: Color4[];
  54431. alignHorizontal?: number;
  54432. alignVertical?: number;
  54433. sideOrientation?: number;
  54434. updatable?: boolean;
  54435. }, scene?: Nullable<Scene>): Mesh;
  54436. /**
  54437. * Creates a sphere mesh
  54438. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  54439. * * 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`)
  54440. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  54441. * * 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
  54442. * * 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)
  54443. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54444. * * 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
  54445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54446. * @param name defines the name of the mesh
  54447. * @param options defines the options used to create the mesh
  54448. * @param scene defines the hosting scene
  54449. * @returns the sphere mesh
  54450. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  54451. */
  54452. static CreateSphere(name: string, options: {
  54453. segments?: number;
  54454. diameter?: number;
  54455. diameterX?: number;
  54456. diameterY?: number;
  54457. diameterZ?: number;
  54458. arc?: number;
  54459. slice?: number;
  54460. sideOrientation?: number;
  54461. frontUVs?: Vector4;
  54462. backUVs?: Vector4;
  54463. updatable?: boolean;
  54464. }, scene?: Nullable<Scene>): Mesh;
  54465. /**
  54466. * Creates a plane polygonal mesh. By default, this is a disc
  54467. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  54468. * * 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
  54469. * * 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
  54470. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54471. * * 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
  54472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54473. * @param name defines the name of the mesh
  54474. * @param options defines the options used to create the mesh
  54475. * @param scene defines the hosting scene
  54476. * @returns the plane polygonal mesh
  54477. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  54478. */
  54479. static CreateDisc(name: string, options: {
  54480. radius?: number;
  54481. tessellation?: number;
  54482. arc?: number;
  54483. updatable?: boolean;
  54484. sideOrientation?: number;
  54485. frontUVs?: Vector4;
  54486. backUVs?: Vector4;
  54487. }, scene?: Nullable<Scene>): Mesh;
  54488. /**
  54489. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  54490. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  54491. * * 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`)
  54492. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  54493. * * 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
  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. * @param name defines the name of the mesh
  54498. * @param options defines the options used to create the mesh
  54499. * @param scene defines the hosting scene
  54500. * @returns the icosahedron mesh
  54501. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  54502. */
  54503. static CreateIcoSphere(name: string, options: {
  54504. radius?: number;
  54505. radiusX?: number;
  54506. radiusY?: number;
  54507. radiusZ?: number;
  54508. flat?: boolean;
  54509. subdivisions?: number;
  54510. sideOrientation?: number;
  54511. frontUVs?: Vector4;
  54512. backUVs?: Vector4;
  54513. updatable?: boolean;
  54514. }, scene?: Nullable<Scene>): Mesh;
  54515. /**
  54516. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54517. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54518. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54519. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54520. * * 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
  54521. * * 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
  54522. * * 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
  54523. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54524. * * 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
  54525. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54526. * * 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
  54527. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54528. * * 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
  54529. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54531. * @param name defines the name of the mesh
  54532. * @param options defines the options used to create the mesh
  54533. * @param scene defines the hosting scene
  54534. * @returns the ribbon mesh
  54535. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54536. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54537. */
  54538. static CreateRibbon(name: string, options: {
  54539. pathArray: Vector3[][];
  54540. closeArray?: boolean;
  54541. closePath?: boolean;
  54542. offset?: number;
  54543. updatable?: boolean;
  54544. sideOrientation?: number;
  54545. frontUVs?: Vector4;
  54546. backUVs?: Vector4;
  54547. instance?: Mesh;
  54548. invertUV?: boolean;
  54549. uvs?: Vector2[];
  54550. colors?: Color4[];
  54551. }, scene?: Nullable<Scene>): Mesh;
  54552. /**
  54553. * Creates a cylinder or a cone mesh
  54554. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  54555. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  54556. * * 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.
  54557. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  54558. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  54559. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  54560. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  54561. * * 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).
  54562. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  54563. * * 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).
  54564. * * 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
  54565. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  54566. * * 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
  54567. * * 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.
  54568. * * If `enclose` is false, a ring surface is one element.
  54569. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  54570. * * 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
  54571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54572. * * 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
  54573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54574. * @param name defines the name of the mesh
  54575. * @param options defines the options used to create the mesh
  54576. * @param scene defines the hosting scene
  54577. * @returns the cylinder mesh
  54578. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  54579. */
  54580. static CreateCylinder(name: string, options: {
  54581. height?: number;
  54582. diameterTop?: number;
  54583. diameterBottom?: number;
  54584. diameter?: number;
  54585. tessellation?: number;
  54586. subdivisions?: number;
  54587. arc?: number;
  54588. faceColors?: Color4[];
  54589. faceUV?: Vector4[];
  54590. updatable?: boolean;
  54591. hasRings?: boolean;
  54592. enclose?: boolean;
  54593. cap?: number;
  54594. sideOrientation?: number;
  54595. frontUVs?: Vector4;
  54596. backUVs?: Vector4;
  54597. }, scene?: Nullable<Scene>): Mesh;
  54598. /**
  54599. * Creates a torus mesh
  54600. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  54601. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  54602. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  54603. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54604. * * 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
  54605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54606. * @param name defines the name of the mesh
  54607. * @param options defines the options used to create the mesh
  54608. * @param scene defines the hosting scene
  54609. * @returns the torus mesh
  54610. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  54611. */
  54612. static CreateTorus(name: string, options: {
  54613. diameter?: number;
  54614. thickness?: number;
  54615. tessellation?: number;
  54616. updatable?: boolean;
  54617. sideOrientation?: number;
  54618. frontUVs?: Vector4;
  54619. backUVs?: Vector4;
  54620. }, scene?: Nullable<Scene>): Mesh;
  54621. /**
  54622. * Creates a torus knot mesh
  54623. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  54624. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  54625. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  54626. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  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 mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54630. * @param name defines the name of the mesh
  54631. * @param options defines the options used to create the mesh
  54632. * @param scene defines the hosting scene
  54633. * @returns the torus knot mesh
  54634. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54635. */
  54636. static CreateTorusKnot(name: string, options: {
  54637. radius?: number;
  54638. tube?: number;
  54639. radialSegments?: number;
  54640. tubularSegments?: number;
  54641. p?: number;
  54642. q?: number;
  54643. updatable?: boolean;
  54644. sideOrientation?: number;
  54645. frontUVs?: Vector4;
  54646. backUVs?: Vector4;
  54647. }, scene?: Nullable<Scene>): Mesh;
  54648. /**
  54649. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  54650. * * 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
  54651. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  54652. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  54653. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  54654. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  54655. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54656. * * 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
  54657. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  54658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54659. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  54660. * @param name defines the name of the new line system
  54661. * @param options defines the options used to create the line system
  54662. * @param scene defines the hosting scene
  54663. * @returns a new line system mesh
  54664. */
  54665. static CreateLineSystem(name: string, options: {
  54666. lines: Vector3[][];
  54667. updatable?: boolean;
  54668. instance?: Nullable<LinesMesh>;
  54669. colors?: Nullable<Color4[][]>;
  54670. useVertexAlpha?: boolean;
  54671. }, scene: Nullable<Scene>): LinesMesh;
  54672. /**
  54673. * Creates a line mesh
  54674. * 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
  54675. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54676. * * The parameter `points` is an array successive Vector3
  54677. * * 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
  54678. * * The optional parameter `colors` is an array of successive Color4, one per line point
  54679. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  54680. * * When updating an instance, remember that only point positions can change, not the number of points
  54681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54682. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  54683. * @param name defines the name of the new line system
  54684. * @param options defines the options used to create the line system
  54685. * @param scene defines the hosting scene
  54686. * @returns a new line mesh
  54687. */
  54688. static CreateLines(name: string, options: {
  54689. points: Vector3[];
  54690. updatable?: boolean;
  54691. instance?: Nullable<LinesMesh>;
  54692. colors?: Color4[];
  54693. useVertexAlpha?: boolean;
  54694. }, scene?: Nullable<Scene>): LinesMesh;
  54695. /**
  54696. * Creates a dashed line mesh
  54697. * * 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
  54698. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54699. * * The parameter `points` is an array successive Vector3
  54700. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  54701. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  54702. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  54703. * * 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
  54704. * * When updating an instance, remember that only point positions can change, not the number of points
  54705. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54706. * @param name defines the name of the mesh
  54707. * @param options defines the options used to create the mesh
  54708. * @param scene defines the hosting scene
  54709. * @returns the dashed line mesh
  54710. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  54711. */
  54712. static CreateDashedLines(name: string, options: {
  54713. points: Vector3[];
  54714. dashSize?: number;
  54715. gapSize?: number;
  54716. dashNb?: number;
  54717. updatable?: boolean;
  54718. instance?: LinesMesh;
  54719. }, scene?: Nullable<Scene>): LinesMesh;
  54720. /**
  54721. * 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.
  54722. * * 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.
  54723. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54724. * * 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.
  54725. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54726. * * 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
  54727. * * 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
  54728. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54729. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54730. * * 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
  54731. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54733. * @param name defines the name of the mesh
  54734. * @param options defines the options used to create the mesh
  54735. * @param scene defines the hosting scene
  54736. * @returns the extruded shape mesh
  54737. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54738. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54739. */
  54740. static ExtrudeShape(name: string, options: {
  54741. shape: Vector3[];
  54742. path: Vector3[];
  54743. scale?: number;
  54744. rotation?: number;
  54745. cap?: number;
  54746. updatable?: boolean;
  54747. sideOrientation?: number;
  54748. frontUVs?: Vector4;
  54749. backUVs?: Vector4;
  54750. instance?: Mesh;
  54751. invertUV?: boolean;
  54752. }, scene?: Nullable<Scene>): Mesh;
  54753. /**
  54754. * Creates an custom extruded shape mesh.
  54755. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54756. * * 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.
  54757. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54758. * * 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
  54759. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54760. * * 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
  54761. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54762. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54763. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54764. * * 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
  54765. * * 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
  54766. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54767. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54768. * * 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
  54769. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54771. * @param name defines the name of the mesh
  54772. * @param options defines the options used to create the mesh
  54773. * @param scene defines the hosting scene
  54774. * @returns the custom extruded shape mesh
  54775. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54776. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54777. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54778. */
  54779. static ExtrudeShapeCustom(name: string, options: {
  54780. shape: Vector3[];
  54781. path: Vector3[];
  54782. scaleFunction?: any;
  54783. rotationFunction?: any;
  54784. ribbonCloseArray?: boolean;
  54785. ribbonClosePath?: boolean;
  54786. cap?: number;
  54787. updatable?: boolean;
  54788. sideOrientation?: number;
  54789. frontUVs?: Vector4;
  54790. backUVs?: Vector4;
  54791. instance?: Mesh;
  54792. invertUV?: boolean;
  54793. }, scene?: Nullable<Scene>): Mesh;
  54794. /**
  54795. * Creates lathe mesh.
  54796. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  54797. * * 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
  54798. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  54799. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  54800. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  54801. * * 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
  54802. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  54803. * * 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
  54804. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54805. * * 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
  54806. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54808. * @param name defines the name of the mesh
  54809. * @param options defines the options used to create the mesh
  54810. * @param scene defines the hosting scene
  54811. * @returns the lathe mesh
  54812. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  54813. */
  54814. static CreateLathe(name: string, options: {
  54815. shape: Vector3[];
  54816. radius?: number;
  54817. tessellation?: number;
  54818. clip?: number;
  54819. arc?: number;
  54820. closed?: boolean;
  54821. updatable?: boolean;
  54822. sideOrientation?: number;
  54823. frontUVs?: Vector4;
  54824. backUVs?: Vector4;
  54825. cap?: number;
  54826. invertUV?: boolean;
  54827. }, scene?: Nullable<Scene>): Mesh;
  54828. /**
  54829. * Creates a tiled plane mesh
  54830. * * You can set a limited pattern arrangement with the tiles
  54831. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54832. * * 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
  54833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54834. * @param name defines the name of the mesh
  54835. * @param options defines the options used to create the mesh
  54836. * @param scene defines the hosting scene
  54837. * @returns the plane mesh
  54838. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  54839. */
  54840. static CreateTiledPlane(name: string, options: {
  54841. pattern?: number;
  54842. tileSize?: number;
  54843. tileWidth?: number;
  54844. tileHeight?: number;
  54845. size?: number;
  54846. width?: number;
  54847. height?: number;
  54848. alignHorizontal?: number;
  54849. alignVertical?: number;
  54850. sideOrientation?: number;
  54851. frontUVs?: Vector4;
  54852. backUVs?: Vector4;
  54853. updatable?: boolean;
  54854. }, scene?: Nullable<Scene>): Mesh;
  54855. /**
  54856. * Creates a plane mesh
  54857. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  54858. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  54859. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  54860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54861. * * 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
  54862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54863. * @param name defines the name of the mesh
  54864. * @param options defines the options used to create the mesh
  54865. * @param scene defines the hosting scene
  54866. * @returns the plane mesh
  54867. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  54868. */
  54869. static CreatePlane(name: string, options: {
  54870. size?: number;
  54871. width?: number;
  54872. height?: number;
  54873. sideOrientation?: number;
  54874. frontUVs?: Vector4;
  54875. backUVs?: Vector4;
  54876. updatable?: boolean;
  54877. sourcePlane?: Plane;
  54878. }, scene?: Nullable<Scene>): Mesh;
  54879. /**
  54880. * Creates a ground mesh
  54881. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  54882. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  54883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54884. * @param name defines the name of the mesh
  54885. * @param options defines the options used to create the mesh
  54886. * @param scene defines the hosting scene
  54887. * @returns the ground mesh
  54888. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  54889. */
  54890. static CreateGround(name: string, options: {
  54891. width?: number;
  54892. height?: number;
  54893. subdivisions?: number;
  54894. subdivisionsX?: number;
  54895. subdivisionsY?: number;
  54896. updatable?: boolean;
  54897. }, scene?: Nullable<Scene>): Mesh;
  54898. /**
  54899. * Creates a tiled ground mesh
  54900. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  54901. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  54902. * * 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
  54903. * * 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
  54904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54905. * @param name defines the name of the mesh
  54906. * @param options defines the options used to create the mesh
  54907. * @param scene defines the hosting scene
  54908. * @returns the tiled ground mesh
  54909. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  54910. */
  54911. static CreateTiledGround(name: string, options: {
  54912. xmin: number;
  54913. zmin: number;
  54914. xmax: number;
  54915. zmax: number;
  54916. subdivisions?: {
  54917. w: number;
  54918. h: number;
  54919. };
  54920. precision?: {
  54921. w: number;
  54922. h: number;
  54923. };
  54924. updatable?: boolean;
  54925. }, scene?: Nullable<Scene>): Mesh;
  54926. /**
  54927. * Creates a ground mesh from a height map
  54928. * * The parameter `url` sets the URL of the height map image resource.
  54929. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  54930. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  54931. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  54932. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  54933. * * 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.
  54934. * * 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).
  54935. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  54936. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54937. * @param name defines the name of the mesh
  54938. * @param url defines the url to the height map
  54939. * @param options defines the options used to create the mesh
  54940. * @param scene defines the hosting scene
  54941. * @returns the ground mesh
  54942. * @see https://doc.babylonjs.com/babylon101/height_map
  54943. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  54944. */
  54945. static CreateGroundFromHeightMap(name: string, url: string, options: {
  54946. width?: number;
  54947. height?: number;
  54948. subdivisions?: number;
  54949. minHeight?: number;
  54950. maxHeight?: number;
  54951. colorFilter?: Color3;
  54952. alphaFilter?: number;
  54953. updatable?: boolean;
  54954. onReady?: (mesh: GroundMesh) => void;
  54955. }, scene?: Nullable<Scene>): GroundMesh;
  54956. /**
  54957. * Creates a polygon mesh
  54958. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  54959. * * 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
  54960. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54962. * * 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)
  54963. * * Remember you can only change the shape positions, not their number when updating a polygon
  54964. * @param name defines the name of the mesh
  54965. * @param options defines the options used to create the mesh
  54966. * @param scene defines the hosting scene
  54967. * @param earcutInjection can be used to inject your own earcut reference
  54968. * @returns the polygon mesh
  54969. */
  54970. static CreatePolygon(name: string, options: {
  54971. shape: Vector3[];
  54972. holes?: Vector3[][];
  54973. depth?: number;
  54974. faceUV?: Vector4[];
  54975. faceColors?: Color4[];
  54976. updatable?: boolean;
  54977. sideOrientation?: number;
  54978. frontUVs?: Vector4;
  54979. backUVs?: Vector4;
  54980. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54981. /**
  54982. * Creates an extruded polygon mesh, with depth in the Y direction.
  54983. * * 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)
  54984. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54985. * @param name defines the name of the mesh
  54986. * @param options defines the options used to create the mesh
  54987. * @param scene defines the hosting scene
  54988. * @param earcutInjection can be used to inject your own earcut reference
  54989. * @returns the polygon mesh
  54990. */
  54991. static ExtrudePolygon(name: string, options: {
  54992. shape: Vector3[];
  54993. holes?: Vector3[][];
  54994. depth?: number;
  54995. faceUV?: Vector4[];
  54996. faceColors?: Color4[];
  54997. updatable?: boolean;
  54998. sideOrientation?: number;
  54999. frontUVs?: Vector4;
  55000. backUVs?: Vector4;
  55001. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55002. /**
  55003. * Creates a tube mesh.
  55004. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55005. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55006. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55007. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55008. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55009. * * 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)
  55010. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55011. * * 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
  55012. * * 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
  55013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55014. * * 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
  55015. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55017. * @param name defines the name of the mesh
  55018. * @param options defines the options used to create the mesh
  55019. * @param scene defines the hosting scene
  55020. * @returns the tube mesh
  55021. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55022. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55023. */
  55024. static CreateTube(name: string, options: {
  55025. path: Vector3[];
  55026. radius?: number;
  55027. tessellation?: number;
  55028. radiusFunction?: {
  55029. (i: number, distance: number): number;
  55030. };
  55031. cap?: number;
  55032. arc?: number;
  55033. updatable?: boolean;
  55034. sideOrientation?: number;
  55035. frontUVs?: Vector4;
  55036. backUVs?: Vector4;
  55037. instance?: Mesh;
  55038. invertUV?: boolean;
  55039. }, scene?: Nullable<Scene>): Mesh;
  55040. /**
  55041. * Creates a polyhedron mesh
  55042. * * 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
  55043. * * The parameter `size` (positive float, default 1) sets the polygon size
  55044. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55045. * * 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`
  55046. * * 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
  55047. * * 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)`)
  55048. * * 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
  55049. * * 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
  55050. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55051. * * 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
  55052. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55053. * @param name defines the name of the mesh
  55054. * @param options defines the options used to create the mesh
  55055. * @param scene defines the hosting scene
  55056. * @returns the polyhedron mesh
  55057. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55058. */
  55059. static CreatePolyhedron(name: string, options: {
  55060. type?: number;
  55061. size?: number;
  55062. sizeX?: number;
  55063. sizeY?: number;
  55064. sizeZ?: number;
  55065. custom?: any;
  55066. faceUV?: Vector4[];
  55067. faceColors?: Color4[];
  55068. flat?: boolean;
  55069. updatable?: boolean;
  55070. sideOrientation?: number;
  55071. frontUVs?: Vector4;
  55072. backUVs?: Vector4;
  55073. }, scene?: Nullable<Scene>): Mesh;
  55074. /**
  55075. * Creates a decal mesh.
  55076. * 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
  55077. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55078. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55079. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55080. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55081. * @param name defines the name of the mesh
  55082. * @param sourceMesh defines the mesh where the decal must be applied
  55083. * @param options defines the options used to create the mesh
  55084. * @param scene defines the hosting scene
  55085. * @returns the decal mesh
  55086. * @see https://doc.babylonjs.com/how_to/decals
  55087. */
  55088. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55089. position?: Vector3;
  55090. normal?: Vector3;
  55091. size?: Vector3;
  55092. angle?: number;
  55093. }): Mesh;
  55094. }
  55095. }
  55096. declare module BABYLON {
  55097. /**
  55098. * A simplifier interface for future simplification implementations
  55099. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55100. */
  55101. export interface ISimplifier {
  55102. /**
  55103. * Simplification of a given mesh according to the given settings.
  55104. * Since this requires computation, it is assumed that the function runs async.
  55105. * @param settings The settings of the simplification, including quality and distance
  55106. * @param successCallback A callback that will be called after the mesh was simplified.
  55107. * @param errorCallback in case of an error, this callback will be called. optional.
  55108. */
  55109. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  55110. }
  55111. /**
  55112. * Expected simplification settings.
  55113. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  55114. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55115. */
  55116. export interface ISimplificationSettings {
  55117. /**
  55118. * Gets or sets the expected quality
  55119. */
  55120. quality: number;
  55121. /**
  55122. * Gets or sets the distance when this optimized version should be used
  55123. */
  55124. distance: number;
  55125. /**
  55126. * Gets an already optimized mesh
  55127. */
  55128. optimizeMesh?: boolean;
  55129. }
  55130. /**
  55131. * Class used to specify simplification options
  55132. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55133. */
  55134. export class SimplificationSettings implements ISimplificationSettings {
  55135. /** expected quality */
  55136. quality: number;
  55137. /** distance when this optimized version should be used */
  55138. distance: number;
  55139. /** already optimized mesh */
  55140. optimizeMesh?: boolean | undefined;
  55141. /**
  55142. * Creates a SimplificationSettings
  55143. * @param quality expected quality
  55144. * @param distance distance when this optimized version should be used
  55145. * @param optimizeMesh already optimized mesh
  55146. */
  55147. constructor(
  55148. /** expected quality */
  55149. quality: number,
  55150. /** distance when this optimized version should be used */
  55151. distance: number,
  55152. /** already optimized mesh */
  55153. optimizeMesh?: boolean | undefined);
  55154. }
  55155. /**
  55156. * Interface used to define a simplification task
  55157. */
  55158. export interface ISimplificationTask {
  55159. /**
  55160. * Array of settings
  55161. */
  55162. settings: Array<ISimplificationSettings>;
  55163. /**
  55164. * Simplification type
  55165. */
  55166. simplificationType: SimplificationType;
  55167. /**
  55168. * Mesh to simplify
  55169. */
  55170. mesh: Mesh;
  55171. /**
  55172. * Callback called on success
  55173. */
  55174. successCallback?: () => void;
  55175. /**
  55176. * Defines if parallel processing can be used
  55177. */
  55178. parallelProcessing: boolean;
  55179. }
  55180. /**
  55181. * Queue used to order the simplification tasks
  55182. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55183. */
  55184. export class SimplificationQueue {
  55185. private _simplificationArray;
  55186. /**
  55187. * Gets a boolean indicating that the process is still running
  55188. */
  55189. running: boolean;
  55190. /**
  55191. * Creates a new queue
  55192. */
  55193. constructor();
  55194. /**
  55195. * Adds a new simplification task
  55196. * @param task defines a task to add
  55197. */
  55198. addTask(task: ISimplificationTask): void;
  55199. /**
  55200. * Execute next task
  55201. */
  55202. executeNext(): void;
  55203. /**
  55204. * Execute a simplification task
  55205. * @param task defines the task to run
  55206. */
  55207. runSimplification(task: ISimplificationTask): void;
  55208. private getSimplifier;
  55209. }
  55210. /**
  55211. * The implemented types of simplification
  55212. * At the moment only Quadratic Error Decimation is implemented
  55213. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55214. */
  55215. export enum SimplificationType {
  55216. /** Quadratic error decimation */
  55217. QUADRATIC = 0
  55218. }
  55219. }
  55220. declare module BABYLON {
  55221. interface Scene {
  55222. /** @hidden (Backing field) */
  55223. _simplificationQueue: SimplificationQueue;
  55224. /**
  55225. * Gets or sets the simplification queue attached to the scene
  55226. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55227. */
  55228. simplificationQueue: SimplificationQueue;
  55229. }
  55230. interface Mesh {
  55231. /**
  55232. * Simplify the mesh according to the given array of settings.
  55233. * Function will return immediately and will simplify async
  55234. * @param settings a collection of simplification settings
  55235. * @param parallelProcessing should all levels calculate parallel or one after the other
  55236. * @param simplificationType the type of simplification to run
  55237. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  55238. * @returns the current mesh
  55239. */
  55240. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  55241. }
  55242. /**
  55243. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  55244. * created in a scene
  55245. */
  55246. export class SimplicationQueueSceneComponent implements ISceneComponent {
  55247. /**
  55248. * The component name helpfull to identify the component in the list of scene components.
  55249. */
  55250. readonly name: string;
  55251. /**
  55252. * The scene the component belongs to.
  55253. */
  55254. scene: Scene;
  55255. /**
  55256. * Creates a new instance of the component for the given scene
  55257. * @param scene Defines the scene to register the component in
  55258. */
  55259. constructor(scene: Scene);
  55260. /**
  55261. * Registers the component in a given scene
  55262. */
  55263. register(): void;
  55264. /**
  55265. * Rebuilds the elements related to this component in case of
  55266. * context lost for instance.
  55267. */
  55268. rebuild(): void;
  55269. /**
  55270. * Disposes the component and the associated ressources
  55271. */
  55272. dispose(): void;
  55273. private _beforeCameraUpdate;
  55274. }
  55275. }
  55276. declare module BABYLON {
  55277. /**
  55278. * Navigation plugin interface to add navigation constrained by a navigation mesh
  55279. */
  55280. export interface INavigationEnginePlugin {
  55281. /**
  55282. * plugin name
  55283. */
  55284. name: string;
  55285. /**
  55286. * Creates a navigation mesh
  55287. * @param meshes array of all the geometry used to compute the navigatio mesh
  55288. * @param parameters bunch of parameters used to filter geometry
  55289. */
  55290. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  55291. /**
  55292. * Create a navigation mesh debug mesh
  55293. * @param scene is where the mesh will be added
  55294. * @returns debug display mesh
  55295. */
  55296. createDebugNavMesh(scene: Scene): Mesh;
  55297. /**
  55298. * Get a navigation mesh constrained position, closest to the parameter position
  55299. * @param position world position
  55300. * @returns the closest point to position constrained by the navigation mesh
  55301. */
  55302. getClosestPoint(position: Vector3): Vector3;
  55303. /**
  55304. * Get a navigation mesh constrained position, within a particular radius
  55305. * @param position world position
  55306. * @param maxRadius the maximum distance to the constrained world position
  55307. * @returns the closest point to position constrained by the navigation mesh
  55308. */
  55309. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  55310. /**
  55311. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  55312. * @param start world position
  55313. * @param end world position
  55314. * @returns array containing world position composing the path
  55315. */
  55316. computePath(start: Vector3, end: Vector3): Vector3[];
  55317. /**
  55318. * If this plugin is supported
  55319. * @returns true if plugin is supported
  55320. */
  55321. isSupported(): boolean;
  55322. /**
  55323. * Create a new Crowd so you can add agents
  55324. * @param maxAgents the maximum agent count in the crowd
  55325. * @param maxAgentRadius the maximum radius an agent can have
  55326. * @param scene to attach the crowd to
  55327. * @returns the crowd you can add agents to
  55328. */
  55329. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  55330. /**
  55331. * Release all resources
  55332. */
  55333. dispose(): void;
  55334. }
  55335. /**
  55336. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  55337. */
  55338. export interface ICrowd {
  55339. /**
  55340. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  55341. * You can attach anything to that node. The node position is updated in the scene update tick.
  55342. * @param pos world position that will be constrained by the navigation mesh
  55343. * @param parameters agent parameters
  55344. * @param transform hooked to the agent that will be update by the scene
  55345. * @returns agent index
  55346. */
  55347. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  55348. /**
  55349. * Returns the agent position in world space
  55350. * @param index agent index returned by addAgent
  55351. * @returns world space position
  55352. */
  55353. getAgentPosition(index: number): Vector3;
  55354. /**
  55355. * Gets the agent velocity in world space
  55356. * @param index agent index returned by addAgent
  55357. * @returns world space velocity
  55358. */
  55359. getAgentVelocity(index: number): Vector3;
  55360. /**
  55361. * remove a particular agent previously created
  55362. * @param index agent index returned by addAgent
  55363. */
  55364. removeAgent(index: number): void;
  55365. /**
  55366. * get the list of all agents attached to this crowd
  55367. * @returns list of agent indices
  55368. */
  55369. getAgents(): number[];
  55370. /**
  55371. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  55372. * @param deltaTime in seconds
  55373. */
  55374. update(deltaTime: number): void;
  55375. /**
  55376. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  55377. * @param index agent index returned by addAgent
  55378. * @param destination targeted world position
  55379. */
  55380. agentGoto(index: number, destination: Vector3): void;
  55381. /**
  55382. * Release all resources
  55383. */
  55384. dispose(): void;
  55385. }
  55386. /**
  55387. * Configures an agent
  55388. */
  55389. export interface IAgentParameters {
  55390. /**
  55391. * Agent radius. [Limit: >= 0]
  55392. */
  55393. radius: number;
  55394. /**
  55395. * Agent height. [Limit: > 0]
  55396. */
  55397. height: number;
  55398. /**
  55399. * Maximum allowed acceleration. [Limit: >= 0]
  55400. */
  55401. maxAcceleration: number;
  55402. /**
  55403. * Maximum allowed speed. [Limit: >= 0]
  55404. */
  55405. maxSpeed: number;
  55406. /**
  55407. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  55408. */
  55409. collisionQueryRange: number;
  55410. /**
  55411. * The path visibility optimization range. [Limit: > 0]
  55412. */
  55413. pathOptimizationRange: number;
  55414. /**
  55415. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  55416. */
  55417. separationWeight: number;
  55418. }
  55419. /**
  55420. * Configures the navigation mesh creation
  55421. */
  55422. export interface INavMeshParameters {
  55423. /**
  55424. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  55425. */
  55426. cs: number;
  55427. /**
  55428. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  55429. */
  55430. ch: number;
  55431. /**
  55432. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  55433. */
  55434. walkableSlopeAngle: number;
  55435. /**
  55436. * Minimum floor to 'ceiling' height that will still allow the floor area to
  55437. * be considered walkable. [Limit: >= 3] [Units: vx]
  55438. */
  55439. walkableHeight: number;
  55440. /**
  55441. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  55442. */
  55443. walkableClimb: number;
  55444. /**
  55445. * The distance to erode/shrink the walkable area of the heightfield away from
  55446. * obstructions. [Limit: >=0] [Units: vx]
  55447. */
  55448. walkableRadius: number;
  55449. /**
  55450. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  55451. */
  55452. maxEdgeLen: number;
  55453. /**
  55454. * The maximum distance a simplfied contour's border edges should deviate
  55455. * the original raw contour. [Limit: >=0] [Units: vx]
  55456. */
  55457. maxSimplificationError: number;
  55458. /**
  55459. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  55460. */
  55461. minRegionArea: number;
  55462. /**
  55463. * Any regions with a span count smaller than this value will, if possible,
  55464. * be merged with larger regions. [Limit: >=0] [Units: vx]
  55465. */
  55466. mergeRegionArea: number;
  55467. /**
  55468. * The maximum number of vertices allowed for polygons generated during the
  55469. * contour to polygon conversion process. [Limit: >= 3]
  55470. */
  55471. maxVertsPerPoly: number;
  55472. /**
  55473. * Sets the sampling distance to use when generating the detail mesh.
  55474. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  55475. */
  55476. detailSampleDist: number;
  55477. /**
  55478. * The maximum distance the detail mesh surface should deviate from heightfield
  55479. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  55480. */
  55481. detailSampleMaxError: number;
  55482. }
  55483. }
  55484. declare module BABYLON {
  55485. /**
  55486. * RecastJS navigation plugin
  55487. */
  55488. export class RecastJSPlugin implements INavigationEnginePlugin {
  55489. /**
  55490. * Reference to the Recast library
  55491. */
  55492. bjsRECAST: any;
  55493. /**
  55494. * plugin name
  55495. */
  55496. name: string;
  55497. /**
  55498. * the first navmesh created. We might extend this to support multiple navmeshes
  55499. */
  55500. navMesh: any;
  55501. /**
  55502. * Initializes the recastJS plugin
  55503. * @param recastInjection can be used to inject your own recast reference
  55504. */
  55505. constructor(recastInjection?: any);
  55506. /**
  55507. * Creates a navigation mesh
  55508. * @param meshes array of all the geometry used to compute the navigatio mesh
  55509. * @param parameters bunch of parameters used to filter geometry
  55510. */
  55511. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  55512. /**
  55513. * Create a navigation mesh debug mesh
  55514. * @param scene is where the mesh will be added
  55515. * @returns debug display mesh
  55516. */
  55517. createDebugNavMesh(scene: Scene): Mesh;
  55518. /**
  55519. * Get a navigation mesh constrained position, closest to the parameter position
  55520. * @param position world position
  55521. * @returns the closest point to position constrained by the navigation mesh
  55522. */
  55523. getClosestPoint(position: Vector3): Vector3;
  55524. /**
  55525. * Get a navigation mesh constrained position, within a particular radius
  55526. * @param position world position
  55527. * @param maxRadius the maximum distance to the constrained world position
  55528. * @returns the closest point to position constrained by the navigation mesh
  55529. */
  55530. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  55531. /**
  55532. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  55533. * @param start world position
  55534. * @param end world position
  55535. * @returns array containing world position composing the path
  55536. */
  55537. computePath(start: Vector3, end: Vector3): Vector3[];
  55538. /**
  55539. * Create a new Crowd so you can add agents
  55540. * @param maxAgents the maximum agent count in the crowd
  55541. * @param maxAgentRadius the maximum radius an agent can have
  55542. * @param scene to attach the crowd to
  55543. * @returns the crowd you can add agents to
  55544. */
  55545. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  55546. /**
  55547. * Disposes
  55548. */
  55549. dispose(): void;
  55550. /**
  55551. * If this plugin is supported
  55552. * @returns true if plugin is supported
  55553. */
  55554. isSupported(): boolean;
  55555. }
  55556. /**
  55557. * Recast detour crowd implementation
  55558. */
  55559. export class RecastJSCrowd implements ICrowd {
  55560. /**
  55561. * Recast/detour plugin
  55562. */
  55563. bjsRECASTPlugin: RecastJSPlugin;
  55564. /**
  55565. * Link to the detour crowd
  55566. */
  55567. recastCrowd: any;
  55568. /**
  55569. * One transform per agent
  55570. */
  55571. transforms: TransformNode[];
  55572. /**
  55573. * All agents created
  55574. */
  55575. agents: number[];
  55576. /**
  55577. * Link to the scene is kept to unregister the crowd from the scene
  55578. */
  55579. private _scene;
  55580. /**
  55581. * Observer for crowd updates
  55582. */
  55583. private _onBeforeAnimationsObserver;
  55584. /**
  55585. * Constructor
  55586. * @param plugin recastJS plugin
  55587. * @param maxAgents the maximum agent count in the crowd
  55588. * @param maxAgentRadius the maximum radius an agent can have
  55589. * @param scene to attach the crowd to
  55590. * @returns the crowd you can add agents to
  55591. */
  55592. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  55593. /**
  55594. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  55595. * You can attach anything to that node. The node position is updated in the scene update tick.
  55596. * @param pos world position that will be constrained by the navigation mesh
  55597. * @param parameters agent parameters
  55598. * @param transform hooked to the agent that will be update by the scene
  55599. * @returns agent index
  55600. */
  55601. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  55602. /**
  55603. * Returns the agent position in world space
  55604. * @param index agent index returned by addAgent
  55605. * @returns world space position
  55606. */
  55607. getAgentPosition(index: number): Vector3;
  55608. /**
  55609. * Returns the agent velocity in world space
  55610. * @param index agent index returned by addAgent
  55611. * @returns world space velocity
  55612. */
  55613. getAgentVelocity(index: number): Vector3;
  55614. /**
  55615. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  55616. * @param index agent index returned by addAgent
  55617. * @param destination targeted world position
  55618. */
  55619. agentGoto(index: number, destination: Vector3): void;
  55620. /**
  55621. * remove a particular agent previously created
  55622. * @param index agent index returned by addAgent
  55623. */
  55624. removeAgent(index: number): void;
  55625. /**
  55626. * get the list of all agents attached to this crowd
  55627. * @returns list of agent indices
  55628. */
  55629. getAgents(): number[];
  55630. /**
  55631. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  55632. * @param deltaTime in seconds
  55633. */
  55634. update(deltaTime: number): void;
  55635. /**
  55636. * Release all resources
  55637. */
  55638. dispose(): void;
  55639. }
  55640. }
  55641. declare module BABYLON {
  55642. /**
  55643. * Class used to enable access to IndexedDB
  55644. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  55645. */
  55646. export class Database implements IOfflineProvider {
  55647. private _callbackManifestChecked;
  55648. private _currentSceneUrl;
  55649. private _db;
  55650. private _enableSceneOffline;
  55651. private _enableTexturesOffline;
  55652. private _manifestVersionFound;
  55653. private _mustUpdateRessources;
  55654. private _hasReachedQuota;
  55655. private _isSupported;
  55656. private _idbFactory;
  55657. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  55658. private static IsUASupportingBlobStorage;
  55659. /**
  55660. * Gets a boolean indicating if Database storate is enabled (off by default)
  55661. */
  55662. static IDBStorageEnabled: boolean;
  55663. /**
  55664. * Gets a boolean indicating if scene must be saved in the database
  55665. */
  55666. readonly enableSceneOffline: boolean;
  55667. /**
  55668. * Gets a boolean indicating if textures must be saved in the database
  55669. */
  55670. readonly enableTexturesOffline: boolean;
  55671. /**
  55672. * Creates a new Database
  55673. * @param urlToScene defines the url to load the scene
  55674. * @param callbackManifestChecked defines the callback to use when manifest is checked
  55675. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  55676. */
  55677. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  55678. private static _ParseURL;
  55679. private static _ReturnFullUrlLocation;
  55680. private _checkManifestFile;
  55681. /**
  55682. * Open the database and make it available
  55683. * @param successCallback defines the callback to call on success
  55684. * @param errorCallback defines the callback to call on error
  55685. */
  55686. open(successCallback: () => void, errorCallback: () => void): void;
  55687. /**
  55688. * Loads an image from the database
  55689. * @param url defines the url to load from
  55690. * @param image defines the target DOM image
  55691. */
  55692. loadImage(url: string, image: HTMLImageElement): void;
  55693. private _loadImageFromDBAsync;
  55694. private _saveImageIntoDBAsync;
  55695. private _checkVersionFromDB;
  55696. private _loadVersionFromDBAsync;
  55697. private _saveVersionIntoDBAsync;
  55698. /**
  55699. * Loads a file from database
  55700. * @param url defines the URL to load from
  55701. * @param sceneLoaded defines a callback to call on success
  55702. * @param progressCallBack defines a callback to call when progress changed
  55703. * @param errorCallback defines a callback to call on error
  55704. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  55705. */
  55706. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  55707. private _loadFileAsync;
  55708. private _saveFileAsync;
  55709. /**
  55710. * Validates if xhr data is correct
  55711. * @param xhr defines the request to validate
  55712. * @param dataType defines the expected data type
  55713. * @returns true if data is correct
  55714. */
  55715. private static _ValidateXHRData;
  55716. }
  55717. }
  55718. declare module BABYLON {
  55719. /** @hidden */
  55720. export var gpuUpdateParticlesPixelShader: {
  55721. name: string;
  55722. shader: string;
  55723. };
  55724. }
  55725. declare module BABYLON {
  55726. /** @hidden */
  55727. export var gpuUpdateParticlesVertexShader: {
  55728. name: string;
  55729. shader: string;
  55730. };
  55731. }
  55732. declare module BABYLON {
  55733. /** @hidden */
  55734. export var clipPlaneFragmentDeclaration2: {
  55735. name: string;
  55736. shader: string;
  55737. };
  55738. }
  55739. declare module BABYLON {
  55740. /** @hidden */
  55741. export var gpuRenderParticlesPixelShader: {
  55742. name: string;
  55743. shader: string;
  55744. };
  55745. }
  55746. declare module BABYLON {
  55747. /** @hidden */
  55748. export var clipPlaneVertexDeclaration2: {
  55749. name: string;
  55750. shader: string;
  55751. };
  55752. }
  55753. declare module BABYLON {
  55754. /** @hidden */
  55755. export var gpuRenderParticlesVertexShader: {
  55756. name: string;
  55757. shader: string;
  55758. };
  55759. }
  55760. declare module BABYLON {
  55761. /**
  55762. * This represents a GPU particle system in Babylon
  55763. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  55764. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  55765. */
  55766. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  55767. /**
  55768. * The layer mask we are rendering the particles through.
  55769. */
  55770. layerMask: number;
  55771. private _capacity;
  55772. private _activeCount;
  55773. private _currentActiveCount;
  55774. private _accumulatedCount;
  55775. private _renderEffect;
  55776. private _updateEffect;
  55777. private _buffer0;
  55778. private _buffer1;
  55779. private _spriteBuffer;
  55780. private _updateVAO;
  55781. private _renderVAO;
  55782. private _targetIndex;
  55783. private _sourceBuffer;
  55784. private _targetBuffer;
  55785. private _engine;
  55786. private _currentRenderId;
  55787. private _started;
  55788. private _stopped;
  55789. private _timeDelta;
  55790. private _randomTexture;
  55791. private _randomTexture2;
  55792. private _attributesStrideSize;
  55793. private _updateEffectOptions;
  55794. private _randomTextureSize;
  55795. private _actualFrame;
  55796. private readonly _rawTextureWidth;
  55797. /**
  55798. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  55799. */
  55800. static readonly IsSupported: boolean;
  55801. /**
  55802. * An event triggered when the system is disposed.
  55803. */
  55804. onDisposeObservable: Observable<GPUParticleSystem>;
  55805. /**
  55806. * Gets the maximum number of particles active at the same time.
  55807. * @returns The max number of active particles.
  55808. */
  55809. getCapacity(): number;
  55810. /**
  55811. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  55812. * to override the particles.
  55813. */
  55814. forceDepthWrite: boolean;
  55815. /**
  55816. * Gets or set the number of active particles
  55817. */
  55818. activeParticleCount: number;
  55819. private _preWarmDone;
  55820. /**
  55821. * Is this system ready to be used/rendered
  55822. * @return true if the system is ready
  55823. */
  55824. isReady(): boolean;
  55825. /**
  55826. * Gets if the system has been started. (Note: this will still be true after stop is called)
  55827. * @returns True if it has been started, otherwise false.
  55828. */
  55829. isStarted(): boolean;
  55830. /**
  55831. * Starts the particle system and begins to emit
  55832. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  55833. */
  55834. start(delay?: number): void;
  55835. /**
  55836. * Stops the particle system.
  55837. */
  55838. stop(): void;
  55839. /**
  55840. * Remove all active particles
  55841. */
  55842. reset(): void;
  55843. /**
  55844. * Returns the string "GPUParticleSystem"
  55845. * @returns a string containing the class name
  55846. */
  55847. getClassName(): string;
  55848. private _colorGradientsTexture;
  55849. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  55850. /**
  55851. * Adds a new color gradient
  55852. * @param gradient defines the gradient to use (between 0 and 1)
  55853. * @param color1 defines the color to affect to the specified gradient
  55854. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  55855. * @returns the current particle system
  55856. */
  55857. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  55858. /**
  55859. * Remove a specific color gradient
  55860. * @param gradient defines the gradient to remove
  55861. * @returns the current particle system
  55862. */
  55863. removeColorGradient(gradient: number): GPUParticleSystem;
  55864. private _angularSpeedGradientsTexture;
  55865. private _sizeGradientsTexture;
  55866. private _velocityGradientsTexture;
  55867. private _limitVelocityGradientsTexture;
  55868. private _dragGradientsTexture;
  55869. private _addFactorGradient;
  55870. /**
  55871. * Adds a new size gradient
  55872. * @param gradient defines the gradient to use (between 0 and 1)
  55873. * @param factor defines the size factor to affect to the specified gradient
  55874. * @returns the current particle system
  55875. */
  55876. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  55877. /**
  55878. * Remove a specific size gradient
  55879. * @param gradient defines the gradient to remove
  55880. * @returns the current particle system
  55881. */
  55882. removeSizeGradient(gradient: number): GPUParticleSystem;
  55883. /**
  55884. * Adds a new angular speed gradient
  55885. * @param gradient defines the gradient to use (between 0 and 1)
  55886. * @param factor defines the angular speed to affect to the specified gradient
  55887. * @returns the current particle system
  55888. */
  55889. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  55890. /**
  55891. * Remove a specific angular speed gradient
  55892. * @param gradient defines the gradient to remove
  55893. * @returns the current particle system
  55894. */
  55895. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  55896. /**
  55897. * Adds a new velocity gradient
  55898. * @param gradient defines the gradient to use (between 0 and 1)
  55899. * @param factor defines the velocity to affect to the specified gradient
  55900. * @returns the current particle system
  55901. */
  55902. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  55903. /**
  55904. * Remove a specific velocity gradient
  55905. * @param gradient defines the gradient to remove
  55906. * @returns the current particle system
  55907. */
  55908. removeVelocityGradient(gradient: number): GPUParticleSystem;
  55909. /**
  55910. * Adds a new limit velocity gradient
  55911. * @param gradient defines the gradient to use (between 0 and 1)
  55912. * @param factor defines the limit velocity value to affect to the specified gradient
  55913. * @returns the current particle system
  55914. */
  55915. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  55916. /**
  55917. * Remove a specific limit velocity gradient
  55918. * @param gradient defines the gradient to remove
  55919. * @returns the current particle system
  55920. */
  55921. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  55922. /**
  55923. * Adds a new drag gradient
  55924. * @param gradient defines the gradient to use (between 0 and 1)
  55925. * @param factor defines the drag value to affect to the specified gradient
  55926. * @returns the current particle system
  55927. */
  55928. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  55929. /**
  55930. * Remove a specific drag gradient
  55931. * @param gradient defines the gradient to remove
  55932. * @returns the current particle system
  55933. */
  55934. removeDragGradient(gradient: number): GPUParticleSystem;
  55935. /**
  55936. * Not supported by GPUParticleSystem
  55937. * @param gradient defines the gradient to use (between 0 and 1)
  55938. * @param factor defines the emit rate value to affect to the specified gradient
  55939. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  55940. * @returns the current particle system
  55941. */
  55942. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  55943. /**
  55944. * Not supported by GPUParticleSystem
  55945. * @param gradient defines the gradient to remove
  55946. * @returns the current particle system
  55947. */
  55948. removeEmitRateGradient(gradient: number): IParticleSystem;
  55949. /**
  55950. * Not supported by GPUParticleSystem
  55951. * @param gradient defines the gradient to use (between 0 and 1)
  55952. * @param factor defines the start size value to affect to the specified gradient
  55953. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  55954. * @returns the current particle system
  55955. */
  55956. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  55957. /**
  55958. * Not supported by GPUParticleSystem
  55959. * @param gradient defines the gradient to remove
  55960. * @returns the current particle system
  55961. */
  55962. removeStartSizeGradient(gradient: number): IParticleSystem;
  55963. /**
  55964. * Not supported by GPUParticleSystem
  55965. * @param gradient defines the gradient to use (between 0 and 1)
  55966. * @param min defines the color remap minimal range
  55967. * @param max defines the color remap maximal range
  55968. * @returns the current particle system
  55969. */
  55970. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  55971. /**
  55972. * Not supported by GPUParticleSystem
  55973. * @param gradient defines the gradient to remove
  55974. * @returns the current particle system
  55975. */
  55976. removeColorRemapGradient(): IParticleSystem;
  55977. /**
  55978. * Not supported by GPUParticleSystem
  55979. * @param gradient defines the gradient to use (between 0 and 1)
  55980. * @param min defines the alpha remap minimal range
  55981. * @param max defines the alpha remap maximal range
  55982. * @returns the current particle system
  55983. */
  55984. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  55985. /**
  55986. * Not supported by GPUParticleSystem
  55987. * @param gradient defines the gradient to remove
  55988. * @returns the current particle system
  55989. */
  55990. removeAlphaRemapGradient(): IParticleSystem;
  55991. /**
  55992. * Not supported by GPUParticleSystem
  55993. * @param gradient defines the gradient to use (between 0 and 1)
  55994. * @param color defines the color to affect to the specified gradient
  55995. * @returns the current particle system
  55996. */
  55997. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  55998. /**
  55999. * Not supported by GPUParticleSystem
  56000. * @param gradient defines the gradient to remove
  56001. * @returns the current particle system
  56002. */
  56003. removeRampGradient(): IParticleSystem;
  56004. /**
  56005. * Not supported by GPUParticleSystem
  56006. * @returns the list of ramp gradients
  56007. */
  56008. getRampGradients(): Nullable<Array<Color3Gradient>>;
  56009. /**
  56010. * Not supported by GPUParticleSystem
  56011. * Gets or sets a boolean indicating that ramp gradients must be used
  56012. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  56013. */
  56014. useRampGradients: boolean;
  56015. /**
  56016. * Not supported by GPUParticleSystem
  56017. * @param gradient defines the gradient to use (between 0 and 1)
  56018. * @param factor defines the life time factor to affect to the specified gradient
  56019. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56020. * @returns the current particle system
  56021. */
  56022. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56023. /**
  56024. * Not supported by GPUParticleSystem
  56025. * @param gradient defines the gradient to remove
  56026. * @returns the current particle system
  56027. */
  56028. removeLifeTimeGradient(gradient: number): IParticleSystem;
  56029. /**
  56030. * Instantiates a GPU particle system.
  56031. * 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.
  56032. * @param name The name of the particle system
  56033. * @param options The options used to create the system
  56034. * @param scene The scene the particle system belongs to
  56035. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  56036. */
  56037. constructor(name: string, options: Partial<{
  56038. capacity: number;
  56039. randomTextureSize: number;
  56040. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  56041. protected _reset(): void;
  56042. private _createUpdateVAO;
  56043. private _createRenderVAO;
  56044. private _initialize;
  56045. /** @hidden */
  56046. _recreateUpdateEffect(): void;
  56047. /** @hidden */
  56048. _recreateRenderEffect(): void;
  56049. /**
  56050. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  56051. * @param preWarm defines if we are in the pre-warmimg phase
  56052. */
  56053. animate(preWarm?: boolean): void;
  56054. private _createFactorGradientTexture;
  56055. private _createSizeGradientTexture;
  56056. private _createAngularSpeedGradientTexture;
  56057. private _createVelocityGradientTexture;
  56058. private _createLimitVelocityGradientTexture;
  56059. private _createDragGradientTexture;
  56060. private _createColorGradientTexture;
  56061. /**
  56062. * Renders the particle system in its current state
  56063. * @param preWarm defines if the system should only update the particles but not render them
  56064. * @returns the current number of particles
  56065. */
  56066. render(preWarm?: boolean): number;
  56067. /**
  56068. * Rebuilds the particle system
  56069. */
  56070. rebuild(): void;
  56071. private _releaseBuffers;
  56072. private _releaseVAOs;
  56073. /**
  56074. * Disposes the particle system and free the associated resources
  56075. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  56076. */
  56077. dispose(disposeTexture?: boolean): void;
  56078. /**
  56079. * Clones the particle system.
  56080. * @param name The name of the cloned object
  56081. * @param newEmitter The new emitter to use
  56082. * @returns the cloned particle system
  56083. */
  56084. clone(name: string, newEmitter: any): GPUParticleSystem;
  56085. /**
  56086. * Serializes the particle system to a JSON object.
  56087. * @returns the JSON object
  56088. */
  56089. serialize(): any;
  56090. /**
  56091. * Parses a JSON object to create a GPU particle system.
  56092. * @param parsedParticleSystem The JSON object to parse
  56093. * @param scene The scene to create the particle system in
  56094. * @param rootUrl The root url to use to load external dependencies like texture
  56095. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  56096. * @returns the parsed GPU particle system
  56097. */
  56098. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  56099. }
  56100. }
  56101. declare module BABYLON {
  56102. /**
  56103. * Represents a set of particle systems working together to create a specific effect
  56104. */
  56105. export class ParticleSystemSet implements IDisposable {
  56106. private _emitterCreationOptions;
  56107. private _emitterNode;
  56108. /**
  56109. * Gets the particle system list
  56110. */
  56111. systems: IParticleSystem[];
  56112. /**
  56113. * Gets the emitter node used with this set
  56114. */
  56115. readonly emitterNode: Nullable<TransformNode>;
  56116. /**
  56117. * Creates a new emitter mesh as a sphere
  56118. * @param options defines the options used to create the sphere
  56119. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  56120. * @param scene defines the hosting scene
  56121. */
  56122. setEmitterAsSphere(options: {
  56123. diameter: number;
  56124. segments: number;
  56125. color: Color3;
  56126. }, renderingGroupId: number, scene: Scene): void;
  56127. /**
  56128. * Starts all particle systems of the set
  56129. * @param emitter defines an optional mesh to use as emitter for the particle systems
  56130. */
  56131. start(emitter?: AbstractMesh): void;
  56132. /**
  56133. * Release all associated resources
  56134. */
  56135. dispose(): void;
  56136. /**
  56137. * Serialize the set into a JSON compatible object
  56138. * @returns a JSON compatible representation of the set
  56139. */
  56140. serialize(): any;
  56141. /**
  56142. * Parse a new ParticleSystemSet from a serialized source
  56143. * @param data defines a JSON compatible representation of the set
  56144. * @param scene defines the hosting scene
  56145. * @param gpu defines if we want GPU particles or CPU particles
  56146. * @returns a new ParticleSystemSet
  56147. */
  56148. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  56149. }
  56150. }
  56151. declare module BABYLON {
  56152. /**
  56153. * This class is made for on one-liner static method to help creating particle system set.
  56154. */
  56155. export class ParticleHelper {
  56156. /**
  56157. * Gets or sets base Assets URL
  56158. */
  56159. static BaseAssetsUrl: string;
  56160. /**
  56161. * Create a default particle system that you can tweak
  56162. * @param emitter defines the emitter to use
  56163. * @param capacity defines the system capacity (default is 500 particles)
  56164. * @param scene defines the hosting scene
  56165. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  56166. * @returns the new Particle system
  56167. */
  56168. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  56169. /**
  56170. * This is the main static method (one-liner) of this helper to create different particle systems
  56171. * @param type This string represents the type to the particle system to create
  56172. * @param scene The scene where the particle system should live
  56173. * @param gpu If the system will use gpu
  56174. * @returns the ParticleSystemSet created
  56175. */
  56176. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  56177. /**
  56178. * Static function used to export a particle system to a ParticleSystemSet variable.
  56179. * Please note that the emitter shape is not exported
  56180. * @param systems defines the particle systems to export
  56181. * @returns the created particle system set
  56182. */
  56183. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  56184. }
  56185. }
  56186. declare module BABYLON {
  56187. interface Engine {
  56188. /**
  56189. * Create an effect to use with particle systems.
  56190. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  56191. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  56192. * @param uniformsNames defines a list of attribute names
  56193. * @param samplers defines an array of string used to represent textures
  56194. * @param defines defines the string containing the defines to use to compile the shaders
  56195. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  56196. * @param onCompiled defines a function to call when the effect creation is successful
  56197. * @param onError defines a function to call when the effect creation has failed
  56198. * @returns the new Effect
  56199. */
  56200. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  56201. }
  56202. interface Mesh {
  56203. /**
  56204. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  56205. * @returns an array of IParticleSystem
  56206. */
  56207. getEmittedParticleSystems(): IParticleSystem[];
  56208. /**
  56209. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  56210. * @returns an array of IParticleSystem
  56211. */
  56212. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  56213. }
  56214. /**
  56215. * @hidden
  56216. */
  56217. export var _IDoNeedToBeInTheBuild: number;
  56218. }
  56219. declare module BABYLON {
  56220. interface Scene {
  56221. /** @hidden (Backing field) */
  56222. _physicsEngine: Nullable<IPhysicsEngine>;
  56223. /**
  56224. * Gets the current physics engine
  56225. * @returns a IPhysicsEngine or null if none attached
  56226. */
  56227. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  56228. /**
  56229. * Enables physics to the current scene
  56230. * @param gravity defines the scene's gravity for the physics engine
  56231. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  56232. * @return a boolean indicating if the physics engine was initialized
  56233. */
  56234. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  56235. /**
  56236. * Disables and disposes the physics engine associated with the scene
  56237. */
  56238. disablePhysicsEngine(): void;
  56239. /**
  56240. * Gets a boolean indicating if there is an active physics engine
  56241. * @returns a boolean indicating if there is an active physics engine
  56242. */
  56243. isPhysicsEnabled(): boolean;
  56244. /**
  56245. * Deletes a physics compound impostor
  56246. * @param compound defines the compound to delete
  56247. */
  56248. deleteCompoundImpostor(compound: any): void;
  56249. /**
  56250. * An event triggered when physic simulation is about to be run
  56251. */
  56252. onBeforePhysicsObservable: Observable<Scene>;
  56253. /**
  56254. * An event triggered when physic simulation has been done
  56255. */
  56256. onAfterPhysicsObservable: Observable<Scene>;
  56257. }
  56258. interface AbstractMesh {
  56259. /** @hidden */
  56260. _physicsImpostor: Nullable<PhysicsImpostor>;
  56261. /**
  56262. * Gets or sets impostor used for physic simulation
  56263. * @see http://doc.babylonjs.com/features/physics_engine
  56264. */
  56265. physicsImpostor: Nullable<PhysicsImpostor>;
  56266. /**
  56267. * Gets the current physics impostor
  56268. * @see http://doc.babylonjs.com/features/physics_engine
  56269. * @returns a physics impostor or null
  56270. */
  56271. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  56272. /** Apply a physic impulse to the mesh
  56273. * @param force defines the force to apply
  56274. * @param contactPoint defines where to apply the force
  56275. * @returns the current mesh
  56276. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  56277. */
  56278. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  56279. /**
  56280. * Creates a physic joint between two meshes
  56281. * @param otherMesh defines the other mesh to use
  56282. * @param pivot1 defines the pivot to use on this mesh
  56283. * @param pivot2 defines the pivot to use on the other mesh
  56284. * @param options defines additional options (can be plugin dependent)
  56285. * @returns the current mesh
  56286. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  56287. */
  56288. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  56289. /** @hidden */
  56290. _disposePhysicsObserver: Nullable<Observer<Node>>;
  56291. }
  56292. /**
  56293. * Defines the physics engine scene component responsible to manage a physics engine
  56294. */
  56295. export class PhysicsEngineSceneComponent implements ISceneComponent {
  56296. /**
  56297. * The component name helpful to identify the component in the list of scene components.
  56298. */
  56299. readonly name: string;
  56300. /**
  56301. * The scene the component belongs to.
  56302. */
  56303. scene: Scene;
  56304. /**
  56305. * Creates a new instance of the component for the given scene
  56306. * @param scene Defines the scene to register the component in
  56307. */
  56308. constructor(scene: Scene);
  56309. /**
  56310. * Registers the component in a given scene
  56311. */
  56312. register(): void;
  56313. /**
  56314. * Rebuilds the elements related to this component in case of
  56315. * context lost for instance.
  56316. */
  56317. rebuild(): void;
  56318. /**
  56319. * Disposes the component and the associated ressources
  56320. */
  56321. dispose(): void;
  56322. }
  56323. }
  56324. declare module BABYLON {
  56325. /**
  56326. * A helper for physics simulations
  56327. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56328. */
  56329. export class PhysicsHelper {
  56330. private _scene;
  56331. private _physicsEngine;
  56332. /**
  56333. * Initializes the Physics helper
  56334. * @param scene Babylon.js scene
  56335. */
  56336. constructor(scene: Scene);
  56337. /**
  56338. * Applies a radial explosion impulse
  56339. * @param origin the origin of the explosion
  56340. * @param radiusOrEventOptions the radius or the options of radial explosion
  56341. * @param strength the explosion strength
  56342. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56343. * @returns A physics radial explosion event, or null
  56344. */
  56345. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56346. /**
  56347. * Applies a radial explosion force
  56348. * @param origin the origin of the explosion
  56349. * @param radiusOrEventOptions the radius or the options of radial explosion
  56350. * @param strength the explosion strength
  56351. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56352. * @returns A physics radial explosion event, or null
  56353. */
  56354. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56355. /**
  56356. * Creates a gravitational field
  56357. * @param origin the origin of the explosion
  56358. * @param radiusOrEventOptions the radius or the options of radial explosion
  56359. * @param strength the explosion strength
  56360. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56361. * @returns A physics gravitational field event, or null
  56362. */
  56363. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  56364. /**
  56365. * Creates a physics updraft event
  56366. * @param origin the origin of the updraft
  56367. * @param radiusOrEventOptions the radius or the options of the updraft
  56368. * @param strength the strength of the updraft
  56369. * @param height the height of the updraft
  56370. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  56371. * @returns A physics updraft event, or null
  56372. */
  56373. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  56374. /**
  56375. * Creates a physics vortex event
  56376. * @param origin the of the vortex
  56377. * @param radiusOrEventOptions the radius or the options of the vortex
  56378. * @param strength the strength of the vortex
  56379. * @param height the height of the vortex
  56380. * @returns a Physics vortex event, or null
  56381. * A physics vortex event or null
  56382. */
  56383. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  56384. }
  56385. /**
  56386. * Represents a physics radial explosion event
  56387. */
  56388. class PhysicsRadialExplosionEvent {
  56389. private _scene;
  56390. private _options;
  56391. private _sphere;
  56392. private _dataFetched;
  56393. /**
  56394. * Initializes a radial explosioin event
  56395. * @param _scene BabylonJS scene
  56396. * @param _options The options for the vortex event
  56397. */
  56398. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  56399. /**
  56400. * Returns the data related to the radial explosion event (sphere).
  56401. * @returns The radial explosion event data
  56402. */
  56403. getData(): PhysicsRadialExplosionEventData;
  56404. /**
  56405. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  56406. * @param impostor A physics imposter
  56407. * @param origin the origin of the explosion
  56408. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  56409. */
  56410. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  56411. /**
  56412. * Triggers affecterd impostors callbacks
  56413. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  56414. */
  56415. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  56416. /**
  56417. * Disposes the sphere.
  56418. * @param force Specifies if the sphere should be disposed by force
  56419. */
  56420. dispose(force?: boolean): void;
  56421. /*** Helpers ***/
  56422. private _prepareSphere;
  56423. private _intersectsWithSphere;
  56424. }
  56425. /**
  56426. * Represents a gravitational field event
  56427. */
  56428. class PhysicsGravitationalFieldEvent {
  56429. private _physicsHelper;
  56430. private _scene;
  56431. private _origin;
  56432. private _options;
  56433. private _tickCallback;
  56434. private _sphere;
  56435. private _dataFetched;
  56436. /**
  56437. * Initializes the physics gravitational field event
  56438. * @param _physicsHelper A physics helper
  56439. * @param _scene BabylonJS scene
  56440. * @param _origin The origin position of the gravitational field event
  56441. * @param _options The options for the vortex event
  56442. */
  56443. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  56444. /**
  56445. * Returns the data related to the gravitational field event (sphere).
  56446. * @returns A gravitational field event
  56447. */
  56448. getData(): PhysicsGravitationalFieldEventData;
  56449. /**
  56450. * Enables the gravitational field.
  56451. */
  56452. enable(): void;
  56453. /**
  56454. * Disables the gravitational field.
  56455. */
  56456. disable(): void;
  56457. /**
  56458. * Disposes the sphere.
  56459. * @param force The force to dispose from the gravitational field event
  56460. */
  56461. dispose(force?: boolean): void;
  56462. private _tick;
  56463. }
  56464. /**
  56465. * Represents a physics updraft event
  56466. */
  56467. class PhysicsUpdraftEvent {
  56468. private _scene;
  56469. private _origin;
  56470. private _options;
  56471. private _physicsEngine;
  56472. private _originTop;
  56473. private _originDirection;
  56474. private _tickCallback;
  56475. private _cylinder;
  56476. private _cylinderPosition;
  56477. private _dataFetched;
  56478. /**
  56479. * Initializes the physics updraft event
  56480. * @param _scene BabylonJS scene
  56481. * @param _origin The origin position of the updraft
  56482. * @param _options The options for the updraft event
  56483. */
  56484. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  56485. /**
  56486. * Returns the data related to the updraft event (cylinder).
  56487. * @returns A physics updraft event
  56488. */
  56489. getData(): PhysicsUpdraftEventData;
  56490. /**
  56491. * Enables the updraft.
  56492. */
  56493. enable(): void;
  56494. /**
  56495. * Disables the updraft.
  56496. */
  56497. disable(): void;
  56498. /**
  56499. * Disposes the cylinder.
  56500. * @param force Specifies if the updraft should be disposed by force
  56501. */
  56502. dispose(force?: boolean): void;
  56503. private getImpostorHitData;
  56504. private _tick;
  56505. /*** Helpers ***/
  56506. private _prepareCylinder;
  56507. private _intersectsWithCylinder;
  56508. }
  56509. /**
  56510. * Represents a physics vortex event
  56511. */
  56512. class PhysicsVortexEvent {
  56513. private _scene;
  56514. private _origin;
  56515. private _options;
  56516. private _physicsEngine;
  56517. private _originTop;
  56518. private _tickCallback;
  56519. private _cylinder;
  56520. private _cylinderPosition;
  56521. private _dataFetched;
  56522. /**
  56523. * Initializes the physics vortex event
  56524. * @param _scene The BabylonJS scene
  56525. * @param _origin The origin position of the vortex
  56526. * @param _options The options for the vortex event
  56527. */
  56528. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  56529. /**
  56530. * Returns the data related to the vortex event (cylinder).
  56531. * @returns The physics vortex event data
  56532. */
  56533. getData(): PhysicsVortexEventData;
  56534. /**
  56535. * Enables the vortex.
  56536. */
  56537. enable(): void;
  56538. /**
  56539. * Disables the cortex.
  56540. */
  56541. disable(): void;
  56542. /**
  56543. * Disposes the sphere.
  56544. * @param force
  56545. */
  56546. dispose(force?: boolean): void;
  56547. private getImpostorHitData;
  56548. private _tick;
  56549. /*** Helpers ***/
  56550. private _prepareCylinder;
  56551. private _intersectsWithCylinder;
  56552. }
  56553. /**
  56554. * Options fot the radial explosion event
  56555. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56556. */
  56557. export class PhysicsRadialExplosionEventOptions {
  56558. /**
  56559. * The radius of the sphere for the radial explosion.
  56560. */
  56561. radius: number;
  56562. /**
  56563. * The strenth of the explosion.
  56564. */
  56565. strength: number;
  56566. /**
  56567. * The strenght of the force in correspondence to the distance of the affected object
  56568. */
  56569. falloff: PhysicsRadialImpulseFalloff;
  56570. /**
  56571. * Sphere options for the radial explosion.
  56572. */
  56573. sphere: {
  56574. segments: number;
  56575. diameter: number;
  56576. };
  56577. /**
  56578. * Sphere options for the radial explosion.
  56579. */
  56580. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  56581. }
  56582. /**
  56583. * Options fot the updraft event
  56584. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56585. */
  56586. export class PhysicsUpdraftEventOptions {
  56587. /**
  56588. * The radius of the cylinder for the vortex
  56589. */
  56590. radius: number;
  56591. /**
  56592. * The strenth of the updraft.
  56593. */
  56594. strength: number;
  56595. /**
  56596. * The height of the cylinder for the updraft.
  56597. */
  56598. height: number;
  56599. /**
  56600. * The mode for the the updraft.
  56601. */
  56602. updraftMode: PhysicsUpdraftMode;
  56603. }
  56604. /**
  56605. * Options fot the vortex event
  56606. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56607. */
  56608. export class PhysicsVortexEventOptions {
  56609. /**
  56610. * The radius of the cylinder for the vortex
  56611. */
  56612. radius: number;
  56613. /**
  56614. * The strenth of the vortex.
  56615. */
  56616. strength: number;
  56617. /**
  56618. * The height of the cylinder for the vortex.
  56619. */
  56620. height: number;
  56621. /**
  56622. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  56623. */
  56624. centripetalForceThreshold: number;
  56625. /**
  56626. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  56627. */
  56628. centripetalForceMultiplier: number;
  56629. /**
  56630. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  56631. */
  56632. centrifugalForceMultiplier: number;
  56633. /**
  56634. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  56635. */
  56636. updraftForceMultiplier: number;
  56637. }
  56638. /**
  56639. * The strenght of the force in correspondence to the distance of the affected object
  56640. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56641. */
  56642. export enum PhysicsRadialImpulseFalloff {
  56643. /** Defines that impulse is constant in strength across it's whole radius */
  56644. Constant = 0,
  56645. /** Defines that impulse gets weaker if it's further from the origin */
  56646. Linear = 1
  56647. }
  56648. /**
  56649. * The strength of the force in correspondence to the distance of the affected object
  56650. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56651. */
  56652. export enum PhysicsUpdraftMode {
  56653. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  56654. Center = 0,
  56655. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  56656. Perpendicular = 1
  56657. }
  56658. /**
  56659. * Interface for a physics hit data
  56660. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56661. */
  56662. export interface PhysicsHitData {
  56663. /**
  56664. * The force applied at the contact point
  56665. */
  56666. force: Vector3;
  56667. /**
  56668. * The contact point
  56669. */
  56670. contactPoint: Vector3;
  56671. /**
  56672. * The distance from the origin to the contact point
  56673. */
  56674. distanceFromOrigin: number;
  56675. }
  56676. /**
  56677. * Interface for radial explosion event data
  56678. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56679. */
  56680. export interface PhysicsRadialExplosionEventData {
  56681. /**
  56682. * A sphere used for the radial explosion event
  56683. */
  56684. sphere: Mesh;
  56685. }
  56686. /**
  56687. * Interface for gravitational field event data
  56688. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56689. */
  56690. export interface PhysicsGravitationalFieldEventData {
  56691. /**
  56692. * A sphere mesh used for the gravitational field event
  56693. */
  56694. sphere: Mesh;
  56695. }
  56696. /**
  56697. * Interface for updraft event data
  56698. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56699. */
  56700. export interface PhysicsUpdraftEventData {
  56701. /**
  56702. * A cylinder used for the updraft event
  56703. */
  56704. cylinder: Mesh;
  56705. }
  56706. /**
  56707. * Interface for vortex event data
  56708. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56709. */
  56710. export interface PhysicsVortexEventData {
  56711. /**
  56712. * A cylinder used for the vortex event
  56713. */
  56714. cylinder: Mesh;
  56715. }
  56716. /**
  56717. * Interface for an affected physics impostor
  56718. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56719. */
  56720. export interface PhysicsAffectedImpostorWithData {
  56721. /**
  56722. * The impostor affected by the effect
  56723. */
  56724. impostor: PhysicsImpostor;
  56725. /**
  56726. * The data about the hit/horce from the explosion
  56727. */
  56728. hitData: PhysicsHitData;
  56729. }
  56730. }
  56731. declare module BABYLON {
  56732. /** @hidden */
  56733. export var blackAndWhitePixelShader: {
  56734. name: string;
  56735. shader: string;
  56736. };
  56737. }
  56738. declare module BABYLON {
  56739. /**
  56740. * Post process used to render in black and white
  56741. */
  56742. export class BlackAndWhitePostProcess extends PostProcess {
  56743. /**
  56744. * Linear about to convert he result to black and white (default: 1)
  56745. */
  56746. degree: number;
  56747. /**
  56748. * Creates a black and white post process
  56749. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  56750. * @param name The name of the effect.
  56751. * @param options The required width/height ratio to downsize to before computing the render pass.
  56752. * @param camera The camera to apply the render pass to.
  56753. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56754. * @param engine The engine which the post process will be applied. (default: current engine)
  56755. * @param reusable If the post process can be reused on the same frame. (default: false)
  56756. */
  56757. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56758. }
  56759. }
  56760. declare module BABYLON {
  56761. /**
  56762. * This represents a set of one or more post processes in Babylon.
  56763. * A post process can be used to apply a shader to a texture after it is rendered.
  56764. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56765. */
  56766. export class PostProcessRenderEffect {
  56767. private _postProcesses;
  56768. private _getPostProcesses;
  56769. private _singleInstance;
  56770. private _cameras;
  56771. private _indicesForCamera;
  56772. /**
  56773. * Name of the effect
  56774. * @hidden
  56775. */
  56776. _name: string;
  56777. /**
  56778. * Instantiates a post process render effect.
  56779. * A post process can be used to apply a shader to a texture after it is rendered.
  56780. * @param engine The engine the effect is tied to
  56781. * @param name The name of the effect
  56782. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  56783. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  56784. */
  56785. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  56786. /**
  56787. * Checks if all the post processes in the effect are supported.
  56788. */
  56789. readonly isSupported: boolean;
  56790. /**
  56791. * Updates the current state of the effect
  56792. * @hidden
  56793. */
  56794. _update(): void;
  56795. /**
  56796. * Attaches the effect on cameras
  56797. * @param cameras The camera to attach to.
  56798. * @hidden
  56799. */
  56800. _attachCameras(cameras: Camera): void;
  56801. /**
  56802. * Attaches the effect on cameras
  56803. * @param cameras The camera to attach to.
  56804. * @hidden
  56805. */
  56806. _attachCameras(cameras: Camera[]): void;
  56807. /**
  56808. * Detaches the effect on cameras
  56809. * @param cameras The camera to detatch from.
  56810. * @hidden
  56811. */
  56812. _detachCameras(cameras: Camera): void;
  56813. /**
  56814. * Detatches the effect on cameras
  56815. * @param cameras The camera to detatch from.
  56816. * @hidden
  56817. */
  56818. _detachCameras(cameras: Camera[]): void;
  56819. /**
  56820. * Enables the effect on given cameras
  56821. * @param cameras The camera to enable.
  56822. * @hidden
  56823. */
  56824. _enable(cameras: Camera): void;
  56825. /**
  56826. * Enables the effect on given cameras
  56827. * @param cameras The camera to enable.
  56828. * @hidden
  56829. */
  56830. _enable(cameras: Nullable<Camera[]>): void;
  56831. /**
  56832. * Disables the effect on the given cameras
  56833. * @param cameras The camera to disable.
  56834. * @hidden
  56835. */
  56836. _disable(cameras: Camera): void;
  56837. /**
  56838. * Disables the effect on the given cameras
  56839. * @param cameras The camera to disable.
  56840. * @hidden
  56841. */
  56842. _disable(cameras: Nullable<Camera[]>): void;
  56843. /**
  56844. * Gets a list of the post processes contained in the effect.
  56845. * @param camera The camera to get the post processes on.
  56846. * @returns The list of the post processes in the effect.
  56847. */
  56848. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  56849. }
  56850. }
  56851. declare module BABYLON {
  56852. /** @hidden */
  56853. export var extractHighlightsPixelShader: {
  56854. name: string;
  56855. shader: string;
  56856. };
  56857. }
  56858. declare module BABYLON {
  56859. /**
  56860. * 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.
  56861. */
  56862. export class ExtractHighlightsPostProcess extends PostProcess {
  56863. /**
  56864. * The luminance threshold, pixels below this value will be set to black.
  56865. */
  56866. threshold: number;
  56867. /** @hidden */
  56868. _exposure: number;
  56869. /**
  56870. * Post process which has the input texture to be used when performing highlight extraction
  56871. * @hidden
  56872. */
  56873. _inputPostProcess: Nullable<PostProcess>;
  56874. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56875. }
  56876. }
  56877. declare module BABYLON {
  56878. /** @hidden */
  56879. export var bloomMergePixelShader: {
  56880. name: string;
  56881. shader: string;
  56882. };
  56883. }
  56884. declare module BABYLON {
  56885. /**
  56886. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  56887. */
  56888. export class BloomMergePostProcess extends PostProcess {
  56889. /** Weight of the bloom to be added to the original input. */
  56890. weight: number;
  56891. /**
  56892. * Creates a new instance of @see BloomMergePostProcess
  56893. * @param name The name of the effect.
  56894. * @param originalFromInput Post process which's input will be used for the merge.
  56895. * @param blurred Blurred highlights post process which's output will be used.
  56896. * @param weight Weight of the bloom to be added to the original input.
  56897. * @param options The required width/height ratio to downsize to before computing the render pass.
  56898. * @param camera The camera to apply the render pass to.
  56899. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56900. * @param engine The engine which the post process will be applied. (default: current engine)
  56901. * @param reusable If the post process can be reused on the same frame. (default: false)
  56902. * @param textureType Type of textures used when performing the post process. (default: 0)
  56903. * @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)
  56904. */
  56905. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  56906. /** Weight of the bloom to be added to the original input. */
  56907. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56908. }
  56909. }
  56910. declare module BABYLON {
  56911. /**
  56912. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  56913. */
  56914. export class BloomEffect extends PostProcessRenderEffect {
  56915. private bloomScale;
  56916. /**
  56917. * @hidden Internal
  56918. */
  56919. _effects: Array<PostProcess>;
  56920. /**
  56921. * @hidden Internal
  56922. */
  56923. _downscale: ExtractHighlightsPostProcess;
  56924. private _blurX;
  56925. private _blurY;
  56926. private _merge;
  56927. /**
  56928. * The luminance threshold to find bright areas of the image to bloom.
  56929. */
  56930. threshold: number;
  56931. /**
  56932. * The strength of the bloom.
  56933. */
  56934. weight: number;
  56935. /**
  56936. * Specifies the size of the bloom blur kernel, relative to the final output size
  56937. */
  56938. kernel: number;
  56939. /**
  56940. * Creates a new instance of @see BloomEffect
  56941. * @param scene The scene the effect belongs to.
  56942. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  56943. * @param bloomKernel The size of the kernel to be used when applying the blur.
  56944. * @param bloomWeight The the strength of bloom.
  56945. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  56946. * @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)
  56947. */
  56948. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  56949. /**
  56950. * Disposes each of the internal effects for a given camera.
  56951. * @param camera The camera to dispose the effect on.
  56952. */
  56953. disposeEffects(camera: Camera): void;
  56954. /**
  56955. * @hidden Internal
  56956. */
  56957. _updateEffects(): void;
  56958. /**
  56959. * Internal
  56960. * @returns if all the contained post processes are ready.
  56961. * @hidden
  56962. */
  56963. _isReady(): boolean;
  56964. }
  56965. }
  56966. declare module BABYLON {
  56967. /** @hidden */
  56968. export var chromaticAberrationPixelShader: {
  56969. name: string;
  56970. shader: string;
  56971. };
  56972. }
  56973. declare module BABYLON {
  56974. /**
  56975. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  56976. */
  56977. export class ChromaticAberrationPostProcess extends PostProcess {
  56978. /**
  56979. * The amount of seperation of rgb channels (default: 30)
  56980. */
  56981. aberrationAmount: number;
  56982. /**
  56983. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  56984. */
  56985. radialIntensity: number;
  56986. /**
  56987. * 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))
  56988. */
  56989. direction: Vector2;
  56990. /**
  56991. * 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))
  56992. */
  56993. centerPosition: Vector2;
  56994. /**
  56995. * Creates a new instance ChromaticAberrationPostProcess
  56996. * @param name The name of the effect.
  56997. * @param screenWidth The width of the screen to apply the effect on.
  56998. * @param screenHeight The height of the screen to apply the effect on.
  56999. * @param options The required width/height ratio to downsize to before computing the render pass.
  57000. * @param camera The camera to apply the render pass to.
  57001. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57002. * @param engine The engine which the post process will be applied. (default: current engine)
  57003. * @param reusable If the post process can be reused on the same frame. (default: false)
  57004. * @param textureType Type of textures used when performing the post process. (default: 0)
  57005. * @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)
  57006. */
  57007. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57008. }
  57009. }
  57010. declare module BABYLON {
  57011. /** @hidden */
  57012. export var circleOfConfusionPixelShader: {
  57013. name: string;
  57014. shader: string;
  57015. };
  57016. }
  57017. declare module BABYLON {
  57018. /**
  57019. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  57020. */
  57021. export class CircleOfConfusionPostProcess extends PostProcess {
  57022. /**
  57023. * 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.
  57024. */
  57025. lensSize: number;
  57026. /**
  57027. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57028. */
  57029. fStop: number;
  57030. /**
  57031. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57032. */
  57033. focusDistance: number;
  57034. /**
  57035. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  57036. */
  57037. focalLength: number;
  57038. private _depthTexture;
  57039. /**
  57040. * Creates a new instance CircleOfConfusionPostProcess
  57041. * @param name The name of the effect.
  57042. * @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.
  57043. * @param options The required width/height ratio to downsize to before computing the render pass.
  57044. * @param camera The camera to apply the render pass to.
  57045. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57046. * @param engine The engine which the post process will be applied. (default: current engine)
  57047. * @param reusable If the post process can be reused on the same frame. (default: false)
  57048. * @param textureType Type of textures used when performing the post process. (default: 0)
  57049. * @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)
  57050. */
  57051. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57052. /**
  57053. * 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.
  57054. */
  57055. depthTexture: RenderTargetTexture;
  57056. }
  57057. }
  57058. declare module BABYLON {
  57059. /** @hidden */
  57060. export var colorCorrectionPixelShader: {
  57061. name: string;
  57062. shader: string;
  57063. };
  57064. }
  57065. declare module BABYLON {
  57066. /**
  57067. *
  57068. * This post-process allows the modification of rendered colors by using
  57069. * a 'look-up table' (LUT). This effect is also called Color Grading.
  57070. *
  57071. * The object needs to be provided an url to a texture containing the color
  57072. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  57073. * Use an image editing software to tweak the LUT to match your needs.
  57074. *
  57075. * For an example of a color LUT, see here:
  57076. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  57077. * For explanations on color grading, see here:
  57078. * @see http://udn.epicgames.com/Three/ColorGrading.html
  57079. *
  57080. */
  57081. export class ColorCorrectionPostProcess extends PostProcess {
  57082. private _colorTableTexture;
  57083. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57084. }
  57085. }
  57086. declare module BABYLON {
  57087. /** @hidden */
  57088. export var convolutionPixelShader: {
  57089. name: string;
  57090. shader: string;
  57091. };
  57092. }
  57093. declare module BABYLON {
  57094. /**
  57095. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  57096. * input texture to perform effects such as edge detection or sharpening
  57097. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  57098. */
  57099. export class ConvolutionPostProcess extends PostProcess {
  57100. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57101. kernel: number[];
  57102. /**
  57103. * Creates a new instance ConvolutionPostProcess
  57104. * @param name The name of the effect.
  57105. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  57106. * @param options The required width/height ratio to downsize to before computing the render pass.
  57107. * @param camera The camera to apply the render pass to.
  57108. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57109. * @param engine The engine which the post process will be applied. (default: current engine)
  57110. * @param reusable If the post process can be reused on the same frame. (default: false)
  57111. * @param textureType Type of textures used when performing the post process. (default: 0)
  57112. */
  57113. constructor(name: string,
  57114. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57115. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57116. /**
  57117. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57118. */
  57119. static EdgeDetect0Kernel: number[];
  57120. /**
  57121. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57122. */
  57123. static EdgeDetect1Kernel: number[];
  57124. /**
  57125. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57126. */
  57127. static EdgeDetect2Kernel: number[];
  57128. /**
  57129. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57130. */
  57131. static SharpenKernel: number[];
  57132. /**
  57133. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57134. */
  57135. static EmbossKernel: number[];
  57136. /**
  57137. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57138. */
  57139. static GaussianKernel: number[];
  57140. }
  57141. }
  57142. declare module BABYLON {
  57143. /**
  57144. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  57145. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  57146. * based on samples that have a large difference in distance than the center pixel.
  57147. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  57148. */
  57149. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  57150. direction: Vector2;
  57151. /**
  57152. * Creates a new instance CircleOfConfusionPostProcess
  57153. * @param name The name of the effect.
  57154. * @param scene The scene the effect belongs to.
  57155. * @param direction The direction the blur should be applied.
  57156. * @param kernel The size of the kernel used to blur.
  57157. * @param options The required width/height ratio to downsize to before computing the render pass.
  57158. * @param camera The camera to apply the render pass to.
  57159. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  57160. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  57161. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57162. * @param engine The engine which the post process will be applied. (default: current engine)
  57163. * @param reusable If the post process can be reused on the same frame. (default: false)
  57164. * @param textureType Type of textures used when performing the post process. (default: 0)
  57165. * @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)
  57166. */
  57167. 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);
  57168. }
  57169. }
  57170. declare module BABYLON {
  57171. /** @hidden */
  57172. export var depthOfFieldMergePixelShader: {
  57173. name: string;
  57174. shader: string;
  57175. };
  57176. }
  57177. declare module BABYLON {
  57178. /**
  57179. * Options to be set when merging outputs from the default pipeline.
  57180. */
  57181. export class DepthOfFieldMergePostProcessOptions {
  57182. /**
  57183. * The original image to merge on top of
  57184. */
  57185. originalFromInput: PostProcess;
  57186. /**
  57187. * Parameters to perform the merge of the depth of field effect
  57188. */
  57189. depthOfField?: {
  57190. circleOfConfusion: PostProcess;
  57191. blurSteps: Array<PostProcess>;
  57192. };
  57193. /**
  57194. * Parameters to perform the merge of bloom effect
  57195. */
  57196. bloom?: {
  57197. blurred: PostProcess;
  57198. weight: number;
  57199. };
  57200. }
  57201. /**
  57202. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57203. */
  57204. export class DepthOfFieldMergePostProcess extends PostProcess {
  57205. private blurSteps;
  57206. /**
  57207. * Creates a new instance of DepthOfFieldMergePostProcess
  57208. * @param name The name of the effect.
  57209. * @param originalFromInput Post process which's input will be used for the merge.
  57210. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  57211. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  57212. * @param options The required width/height ratio to downsize to before computing the render pass.
  57213. * @param camera The camera to apply the render pass to.
  57214. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57215. * @param engine The engine which the post process will be applied. (default: current engine)
  57216. * @param reusable If the post process can be reused on the same frame. (default: false)
  57217. * @param textureType Type of textures used when performing the post process. (default: 0)
  57218. * @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)
  57219. */
  57220. 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);
  57221. /**
  57222. * Updates the effect with the current post process compile time values and recompiles the shader.
  57223. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  57224. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  57225. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  57226. * @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
  57227. * @param onCompiled Called when the shader has been compiled.
  57228. * @param onError Called if there is an error when compiling a shader.
  57229. */
  57230. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  57231. }
  57232. }
  57233. declare module BABYLON {
  57234. /**
  57235. * Specifies the level of max blur that should be applied when using the depth of field effect
  57236. */
  57237. export enum DepthOfFieldEffectBlurLevel {
  57238. /**
  57239. * Subtle blur
  57240. */
  57241. Low = 0,
  57242. /**
  57243. * Medium blur
  57244. */
  57245. Medium = 1,
  57246. /**
  57247. * Large blur
  57248. */
  57249. High = 2
  57250. }
  57251. /**
  57252. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  57253. */
  57254. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  57255. private _circleOfConfusion;
  57256. /**
  57257. * @hidden Internal, blurs from high to low
  57258. */
  57259. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  57260. private _depthOfFieldBlurY;
  57261. private _dofMerge;
  57262. /**
  57263. * @hidden Internal post processes in depth of field effect
  57264. */
  57265. _effects: Array<PostProcess>;
  57266. /**
  57267. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  57268. */
  57269. focalLength: number;
  57270. /**
  57271. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57272. */
  57273. fStop: number;
  57274. /**
  57275. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57276. */
  57277. focusDistance: number;
  57278. /**
  57279. * 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.
  57280. */
  57281. lensSize: number;
  57282. /**
  57283. * Creates a new instance DepthOfFieldEffect
  57284. * @param scene The scene the effect belongs to.
  57285. * @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.
  57286. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57287. * @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)
  57288. */
  57289. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  57290. /**
  57291. * Get the current class name of the current effet
  57292. * @returns "DepthOfFieldEffect"
  57293. */
  57294. getClassName(): string;
  57295. /**
  57296. * 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.
  57297. */
  57298. depthTexture: RenderTargetTexture;
  57299. /**
  57300. * Disposes each of the internal effects for a given camera.
  57301. * @param camera The camera to dispose the effect on.
  57302. */
  57303. disposeEffects(camera: Camera): void;
  57304. /**
  57305. * @hidden Internal
  57306. */
  57307. _updateEffects(): void;
  57308. /**
  57309. * Internal
  57310. * @returns if all the contained post processes are ready.
  57311. * @hidden
  57312. */
  57313. _isReady(): boolean;
  57314. }
  57315. }
  57316. declare module BABYLON {
  57317. /** @hidden */
  57318. export var displayPassPixelShader: {
  57319. name: string;
  57320. shader: string;
  57321. };
  57322. }
  57323. declare module BABYLON {
  57324. /**
  57325. * DisplayPassPostProcess which produces an output the same as it's input
  57326. */
  57327. export class DisplayPassPostProcess extends PostProcess {
  57328. /**
  57329. * Creates the DisplayPassPostProcess
  57330. * @param name The name of the effect.
  57331. * @param options The required width/height ratio to downsize to before computing the render pass.
  57332. * @param camera The camera to apply the render pass to.
  57333. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57334. * @param engine The engine which the post process will be applied. (default: current engine)
  57335. * @param reusable If the post process can be reused on the same frame. (default: false)
  57336. */
  57337. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57338. }
  57339. }
  57340. declare module BABYLON {
  57341. /** @hidden */
  57342. export var filterPixelShader: {
  57343. name: string;
  57344. shader: string;
  57345. };
  57346. }
  57347. declare module BABYLON {
  57348. /**
  57349. * Applies a kernel filter to the image
  57350. */
  57351. export class FilterPostProcess extends PostProcess {
  57352. /** The matrix to be applied to the image */
  57353. kernelMatrix: Matrix;
  57354. /**
  57355. *
  57356. * @param name The name of the effect.
  57357. * @param kernelMatrix The matrix to be applied to the image
  57358. * @param options The required width/height ratio to downsize to before computing the render pass.
  57359. * @param camera The camera to apply the render pass to.
  57360. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57361. * @param engine The engine which the post process will be applied. (default: current engine)
  57362. * @param reusable If the post process can be reused on the same frame. (default: false)
  57363. */
  57364. constructor(name: string,
  57365. /** The matrix to be applied to the image */
  57366. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57367. }
  57368. }
  57369. declare module BABYLON {
  57370. /** @hidden */
  57371. export var fxaaPixelShader: {
  57372. name: string;
  57373. shader: string;
  57374. };
  57375. }
  57376. declare module BABYLON {
  57377. /** @hidden */
  57378. export var fxaaVertexShader: {
  57379. name: string;
  57380. shader: string;
  57381. };
  57382. }
  57383. declare module BABYLON {
  57384. /**
  57385. * Fxaa post process
  57386. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  57387. */
  57388. export class FxaaPostProcess extends PostProcess {
  57389. /** @hidden */
  57390. texelWidth: number;
  57391. /** @hidden */
  57392. texelHeight: number;
  57393. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57394. private _getDefines;
  57395. }
  57396. }
  57397. declare module BABYLON {
  57398. /** @hidden */
  57399. export var grainPixelShader: {
  57400. name: string;
  57401. shader: string;
  57402. };
  57403. }
  57404. declare module BABYLON {
  57405. /**
  57406. * The GrainPostProcess adds noise to the image at mid luminance levels
  57407. */
  57408. export class GrainPostProcess extends PostProcess {
  57409. /**
  57410. * The intensity of the grain added (default: 30)
  57411. */
  57412. intensity: number;
  57413. /**
  57414. * If the grain should be randomized on every frame
  57415. */
  57416. animated: boolean;
  57417. /**
  57418. * Creates a new instance of @see GrainPostProcess
  57419. * @param name The name of the effect.
  57420. * @param options The required width/height ratio to downsize to before computing the render pass.
  57421. * @param camera The camera to apply the render pass to.
  57422. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57423. * @param engine The engine which the post process will be applied. (default: current engine)
  57424. * @param reusable If the post process can be reused on the same frame. (default: false)
  57425. * @param textureType Type of textures used when performing the post process. (default: 0)
  57426. * @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)
  57427. */
  57428. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57429. }
  57430. }
  57431. declare module BABYLON {
  57432. /** @hidden */
  57433. export var highlightsPixelShader: {
  57434. name: string;
  57435. shader: string;
  57436. };
  57437. }
  57438. declare module BABYLON {
  57439. /**
  57440. * Extracts highlights from the image
  57441. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  57442. */
  57443. export class HighlightsPostProcess extends PostProcess {
  57444. /**
  57445. * Extracts highlights from the image
  57446. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  57447. * @param name The name of the effect.
  57448. * @param options The required width/height ratio to downsize to before computing the render pass.
  57449. * @param camera The camera to apply the render pass to.
  57450. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57451. * @param engine The engine which the post process will be applied. (default: current engine)
  57452. * @param reusable If the post process can be reused on the same frame. (default: false)
  57453. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  57454. */
  57455. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57456. }
  57457. }
  57458. declare module BABYLON {
  57459. /** @hidden */
  57460. export var mrtFragmentDeclaration: {
  57461. name: string;
  57462. shader: string;
  57463. };
  57464. }
  57465. declare module BABYLON {
  57466. /** @hidden */
  57467. export var geometryPixelShader: {
  57468. name: string;
  57469. shader: string;
  57470. };
  57471. }
  57472. declare module BABYLON {
  57473. /** @hidden */
  57474. export var geometryVertexShader: {
  57475. name: string;
  57476. shader: string;
  57477. };
  57478. }
  57479. declare module BABYLON {
  57480. /** @hidden */
  57481. interface ISavedTransformationMatrix {
  57482. world: Matrix;
  57483. viewProjection: Matrix;
  57484. }
  57485. /**
  57486. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  57487. */
  57488. export class GeometryBufferRenderer {
  57489. /**
  57490. * Constant used to retrieve the position texture index in the G-Buffer textures array
  57491. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  57492. */
  57493. static readonly POSITION_TEXTURE_TYPE: number;
  57494. /**
  57495. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  57496. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  57497. */
  57498. static readonly VELOCITY_TEXTURE_TYPE: number;
  57499. /**
  57500. * Dictionary used to store the previous transformation matrices of each rendered mesh
  57501. * in order to compute objects velocities when enableVelocity is set to "true"
  57502. * @hidden
  57503. */
  57504. _previousTransformationMatrices: {
  57505. [index: number]: ISavedTransformationMatrix;
  57506. };
  57507. /**
  57508. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  57509. * in order to compute objects velocities when enableVelocity is set to "true"
  57510. * @hidden
  57511. */
  57512. _previousBonesTransformationMatrices: {
  57513. [index: number]: Float32Array;
  57514. };
  57515. /**
  57516. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  57517. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  57518. */
  57519. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  57520. private _scene;
  57521. private _multiRenderTarget;
  57522. private _ratio;
  57523. private _enablePosition;
  57524. private _enableVelocity;
  57525. private _positionIndex;
  57526. private _velocityIndex;
  57527. protected _effect: Effect;
  57528. protected _cachedDefines: string;
  57529. /**
  57530. * Set the render list (meshes to be rendered) used in the G buffer.
  57531. */
  57532. renderList: Mesh[];
  57533. /**
  57534. * Gets wether or not G buffer are supported by the running hardware.
  57535. * This requires draw buffer supports
  57536. */
  57537. readonly isSupported: boolean;
  57538. /**
  57539. * Returns the index of the given texture type in the G-Buffer textures array
  57540. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  57541. * @returns the index of the given texture type in the G-Buffer textures array
  57542. */
  57543. getTextureIndex(textureType: number): number;
  57544. /**
  57545. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  57546. */
  57547. /**
  57548. * Sets whether or not objects positions are enabled for the G buffer.
  57549. */
  57550. enablePosition: boolean;
  57551. /**
  57552. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  57553. */
  57554. /**
  57555. * Sets wether or not objects velocities are enabled for the G buffer.
  57556. */
  57557. enableVelocity: boolean;
  57558. /**
  57559. * Gets the scene associated with the buffer.
  57560. */
  57561. readonly scene: Scene;
  57562. /**
  57563. * Gets the ratio used by the buffer during its creation.
  57564. * How big is the buffer related to the main canvas.
  57565. */
  57566. readonly ratio: number;
  57567. /** @hidden */
  57568. static _SceneComponentInitialization: (scene: Scene) => void;
  57569. /**
  57570. * Creates a new G Buffer for the scene
  57571. * @param scene The scene the buffer belongs to
  57572. * @param ratio How big is the buffer related to the main canvas.
  57573. */
  57574. constructor(scene: Scene, ratio?: number);
  57575. /**
  57576. * Checks wether everything is ready to render a submesh to the G buffer.
  57577. * @param subMesh the submesh to check readiness for
  57578. * @param useInstances is the mesh drawn using instance or not
  57579. * @returns true if ready otherwise false
  57580. */
  57581. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57582. /**
  57583. * Gets the current underlying G Buffer.
  57584. * @returns the buffer
  57585. */
  57586. getGBuffer(): MultiRenderTarget;
  57587. /**
  57588. * Gets the number of samples used to render the buffer (anti aliasing).
  57589. */
  57590. /**
  57591. * Sets the number of samples used to render the buffer (anti aliasing).
  57592. */
  57593. samples: number;
  57594. /**
  57595. * Disposes the renderer and frees up associated resources.
  57596. */
  57597. dispose(): void;
  57598. protected _createRenderTargets(): void;
  57599. private _copyBonesTransformationMatrices;
  57600. }
  57601. }
  57602. declare module BABYLON {
  57603. interface Scene {
  57604. /** @hidden (Backing field) */
  57605. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  57606. /**
  57607. * Gets or Sets the current geometry buffer associated to the scene.
  57608. */
  57609. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  57610. /**
  57611. * Enables a GeometryBufferRender and associates it with the scene
  57612. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  57613. * @returns the GeometryBufferRenderer
  57614. */
  57615. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  57616. /**
  57617. * Disables the GeometryBufferRender associated with the scene
  57618. */
  57619. disableGeometryBufferRenderer(): void;
  57620. }
  57621. /**
  57622. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  57623. * in several rendering techniques.
  57624. */
  57625. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  57626. /**
  57627. * The component name helpful to identify the component in the list of scene components.
  57628. */
  57629. readonly name: string;
  57630. /**
  57631. * The scene the component belongs to.
  57632. */
  57633. scene: Scene;
  57634. /**
  57635. * Creates a new instance of the component for the given scene
  57636. * @param scene Defines the scene to register the component in
  57637. */
  57638. constructor(scene: Scene);
  57639. /**
  57640. * Registers the component in a given scene
  57641. */
  57642. register(): void;
  57643. /**
  57644. * Rebuilds the elements related to this component in case of
  57645. * context lost for instance.
  57646. */
  57647. rebuild(): void;
  57648. /**
  57649. * Disposes the component and the associated ressources
  57650. */
  57651. dispose(): void;
  57652. private _gatherRenderTargets;
  57653. }
  57654. }
  57655. declare module BABYLON {
  57656. /** @hidden */
  57657. export var motionBlurPixelShader: {
  57658. name: string;
  57659. shader: string;
  57660. };
  57661. }
  57662. declare module BABYLON {
  57663. /**
  57664. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  57665. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  57666. * As an example, all you have to do is to create the post-process:
  57667. * var mb = new BABYLON.MotionBlurPostProcess(
  57668. * 'mb', // The name of the effect.
  57669. * scene, // The scene containing the objects to blur according to their velocity.
  57670. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  57671. * camera // The camera to apply the render pass to.
  57672. * );
  57673. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  57674. */
  57675. export class MotionBlurPostProcess extends PostProcess {
  57676. /**
  57677. * Defines how much the image is blurred by the movement. Default value is equal to 1
  57678. */
  57679. motionStrength: number;
  57680. /**
  57681. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  57682. */
  57683. /**
  57684. * Sets the number of iterations to be used for motion blur quality
  57685. */
  57686. motionBlurSamples: number;
  57687. private _motionBlurSamples;
  57688. private _geometryBufferRenderer;
  57689. /**
  57690. * Creates a new instance MotionBlurPostProcess
  57691. * @param name The name of the effect.
  57692. * @param scene The scene containing the objects to blur according to their velocity.
  57693. * @param options The required width/height ratio to downsize to before computing the render pass.
  57694. * @param camera The camera to apply the render pass to.
  57695. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57696. * @param engine The engine which the post process will be applied. (default: current engine)
  57697. * @param reusable If the post process can be reused on the same frame. (default: false)
  57698. * @param textureType Type of textures used when performing the post process. (default: 0)
  57699. * @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)
  57700. */
  57701. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57702. /**
  57703. * Excludes the given skinned mesh from computing bones velocities.
  57704. * 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.
  57705. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  57706. */
  57707. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  57708. /**
  57709. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  57710. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  57711. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  57712. */
  57713. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  57714. /**
  57715. * Disposes the post process.
  57716. * @param camera The camera to dispose the post process on.
  57717. */
  57718. dispose(camera?: Camera): void;
  57719. }
  57720. }
  57721. declare module BABYLON {
  57722. /** @hidden */
  57723. export var refractionPixelShader: {
  57724. name: string;
  57725. shader: string;
  57726. };
  57727. }
  57728. declare module BABYLON {
  57729. /**
  57730. * Post process which applies a refractin texture
  57731. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  57732. */
  57733. export class RefractionPostProcess extends PostProcess {
  57734. /** the base color of the refraction (used to taint the rendering) */
  57735. color: Color3;
  57736. /** simulated refraction depth */
  57737. depth: number;
  57738. /** the coefficient of the base color (0 to remove base color tainting) */
  57739. colorLevel: number;
  57740. private _refTexture;
  57741. private _ownRefractionTexture;
  57742. /**
  57743. * Gets or sets the refraction texture
  57744. * Please note that you are responsible for disposing the texture if you set it manually
  57745. */
  57746. refractionTexture: Texture;
  57747. /**
  57748. * Initializes the RefractionPostProcess
  57749. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  57750. * @param name The name of the effect.
  57751. * @param refractionTextureUrl Url of the refraction texture to use
  57752. * @param color the base color of the refraction (used to taint the rendering)
  57753. * @param depth simulated refraction depth
  57754. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  57755. * @param camera The camera to apply the render pass to.
  57756. * @param options The required width/height ratio to downsize to before computing the render pass.
  57757. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57758. * @param engine The engine which the post process will be applied. (default: current engine)
  57759. * @param reusable If the post process can be reused on the same frame. (default: false)
  57760. */
  57761. constructor(name: string, refractionTextureUrl: string,
  57762. /** the base color of the refraction (used to taint the rendering) */
  57763. color: Color3,
  57764. /** simulated refraction depth */
  57765. depth: number,
  57766. /** the coefficient of the base color (0 to remove base color tainting) */
  57767. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57768. /**
  57769. * Disposes of the post process
  57770. * @param camera Camera to dispose post process on
  57771. */
  57772. dispose(camera: Camera): void;
  57773. }
  57774. }
  57775. declare module BABYLON {
  57776. /** @hidden */
  57777. export var sharpenPixelShader: {
  57778. name: string;
  57779. shader: string;
  57780. };
  57781. }
  57782. declare module BABYLON {
  57783. /**
  57784. * The SharpenPostProcess applies a sharpen kernel to every pixel
  57785. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  57786. */
  57787. export class SharpenPostProcess extends PostProcess {
  57788. /**
  57789. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  57790. */
  57791. colorAmount: number;
  57792. /**
  57793. * How much sharpness should be applied (default: 0.3)
  57794. */
  57795. edgeAmount: number;
  57796. /**
  57797. * Creates a new instance ConvolutionPostProcess
  57798. * @param name The name of the effect.
  57799. * @param options The required width/height ratio to downsize to before computing the render pass.
  57800. * @param camera The camera to apply the render pass to.
  57801. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57802. * @param engine The engine which the post process will be applied. (default: current engine)
  57803. * @param reusable If the post process can be reused on the same frame. (default: false)
  57804. * @param textureType Type of textures used when performing the post process. (default: 0)
  57805. * @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)
  57806. */
  57807. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57808. }
  57809. }
  57810. declare module BABYLON {
  57811. /**
  57812. * PostProcessRenderPipeline
  57813. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57814. */
  57815. export class PostProcessRenderPipeline {
  57816. private engine;
  57817. private _renderEffects;
  57818. private _renderEffectsForIsolatedPass;
  57819. /**
  57820. * List of inspectable custom properties (used by the Inspector)
  57821. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  57822. */
  57823. inspectableCustomProperties: IInspectable[];
  57824. /**
  57825. * @hidden
  57826. */
  57827. protected _cameras: Camera[];
  57828. /** @hidden */
  57829. _name: string;
  57830. /**
  57831. * Gets pipeline name
  57832. */
  57833. readonly name: string;
  57834. /**
  57835. * Initializes a PostProcessRenderPipeline
  57836. * @param engine engine to add the pipeline to
  57837. * @param name name of the pipeline
  57838. */
  57839. constructor(engine: Engine, name: string);
  57840. /**
  57841. * Gets the class name
  57842. * @returns "PostProcessRenderPipeline"
  57843. */
  57844. getClassName(): string;
  57845. /**
  57846. * If all the render effects in the pipeline are supported
  57847. */
  57848. readonly isSupported: boolean;
  57849. /**
  57850. * Adds an effect to the pipeline
  57851. * @param renderEffect the effect to add
  57852. */
  57853. addEffect(renderEffect: PostProcessRenderEffect): void;
  57854. /** @hidden */
  57855. _rebuild(): void;
  57856. /** @hidden */
  57857. _enableEffect(renderEffectName: string, cameras: Camera): void;
  57858. /** @hidden */
  57859. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  57860. /** @hidden */
  57861. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  57862. /** @hidden */
  57863. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  57864. /** @hidden */
  57865. _attachCameras(cameras: Camera, unique: boolean): void;
  57866. /** @hidden */
  57867. _attachCameras(cameras: Camera[], unique: boolean): void;
  57868. /** @hidden */
  57869. _detachCameras(cameras: Camera): void;
  57870. /** @hidden */
  57871. _detachCameras(cameras: Nullable<Camera[]>): void;
  57872. /** @hidden */
  57873. _update(): void;
  57874. /** @hidden */
  57875. _reset(): void;
  57876. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  57877. /**
  57878. * Disposes of the pipeline
  57879. */
  57880. dispose(): void;
  57881. }
  57882. }
  57883. declare module BABYLON {
  57884. /**
  57885. * PostProcessRenderPipelineManager class
  57886. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57887. */
  57888. export class PostProcessRenderPipelineManager {
  57889. private _renderPipelines;
  57890. /**
  57891. * Initializes a PostProcessRenderPipelineManager
  57892. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57893. */
  57894. constructor();
  57895. /**
  57896. * Gets the list of supported render pipelines
  57897. */
  57898. readonly supportedPipelines: PostProcessRenderPipeline[];
  57899. /**
  57900. * Adds a pipeline to the manager
  57901. * @param renderPipeline The pipeline to add
  57902. */
  57903. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  57904. /**
  57905. * Attaches a camera to the pipeline
  57906. * @param renderPipelineName The name of the pipeline to attach to
  57907. * @param cameras the camera to attach
  57908. * @param unique if the camera can be attached multiple times to the pipeline
  57909. */
  57910. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  57911. /**
  57912. * Detaches a camera from the pipeline
  57913. * @param renderPipelineName The name of the pipeline to detach from
  57914. * @param cameras the camera to detach
  57915. */
  57916. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  57917. /**
  57918. * Enables an effect by name on a pipeline
  57919. * @param renderPipelineName the name of the pipeline to enable the effect in
  57920. * @param renderEffectName the name of the effect to enable
  57921. * @param cameras the cameras that the effect should be enabled on
  57922. */
  57923. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  57924. /**
  57925. * Disables an effect by name on a pipeline
  57926. * @param renderPipelineName the name of the pipeline to disable the effect in
  57927. * @param renderEffectName the name of the effect to disable
  57928. * @param cameras the cameras that the effect should be disabled on
  57929. */
  57930. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  57931. /**
  57932. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  57933. */
  57934. update(): void;
  57935. /** @hidden */
  57936. _rebuild(): void;
  57937. /**
  57938. * Disposes of the manager and pipelines
  57939. */
  57940. dispose(): void;
  57941. }
  57942. }
  57943. declare module BABYLON {
  57944. interface Scene {
  57945. /** @hidden (Backing field) */
  57946. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  57947. /**
  57948. * Gets the postprocess render pipeline manager
  57949. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57950. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  57951. */
  57952. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  57953. }
  57954. /**
  57955. * Defines the Render Pipeline scene component responsible to rendering pipelines
  57956. */
  57957. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  57958. /**
  57959. * The component name helpfull to identify the component in the list of scene components.
  57960. */
  57961. readonly name: string;
  57962. /**
  57963. * The scene the component belongs to.
  57964. */
  57965. scene: Scene;
  57966. /**
  57967. * Creates a new instance of the component for the given scene
  57968. * @param scene Defines the scene to register the component in
  57969. */
  57970. constructor(scene: Scene);
  57971. /**
  57972. * Registers the component in a given scene
  57973. */
  57974. register(): void;
  57975. /**
  57976. * Rebuilds the elements related to this component in case of
  57977. * context lost for instance.
  57978. */
  57979. rebuild(): void;
  57980. /**
  57981. * Disposes the component and the associated ressources
  57982. */
  57983. dispose(): void;
  57984. private _gatherRenderTargets;
  57985. }
  57986. }
  57987. declare module BABYLON {
  57988. /**
  57989. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  57990. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  57991. */
  57992. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  57993. private _scene;
  57994. private _camerasToBeAttached;
  57995. /**
  57996. * ID of the sharpen post process,
  57997. */
  57998. private readonly SharpenPostProcessId;
  57999. /**
  58000. * @ignore
  58001. * ID of the image processing post process;
  58002. */
  58003. readonly ImageProcessingPostProcessId: string;
  58004. /**
  58005. * @ignore
  58006. * ID of the Fast Approximate Anti-Aliasing post process;
  58007. */
  58008. readonly FxaaPostProcessId: string;
  58009. /**
  58010. * ID of the chromatic aberration post process,
  58011. */
  58012. private readonly ChromaticAberrationPostProcessId;
  58013. /**
  58014. * ID of the grain post process
  58015. */
  58016. private readonly GrainPostProcessId;
  58017. /**
  58018. * Sharpen post process which will apply a sharpen convolution to enhance edges
  58019. */
  58020. sharpen: SharpenPostProcess;
  58021. private _sharpenEffect;
  58022. private bloom;
  58023. /**
  58024. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  58025. */
  58026. depthOfField: DepthOfFieldEffect;
  58027. /**
  58028. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  58029. */
  58030. fxaa: FxaaPostProcess;
  58031. /**
  58032. * Image post processing pass used to perform operations such as tone mapping or color grading.
  58033. */
  58034. imageProcessing: ImageProcessingPostProcess;
  58035. /**
  58036. * Chromatic aberration post process which will shift rgb colors in the image
  58037. */
  58038. chromaticAberration: ChromaticAberrationPostProcess;
  58039. private _chromaticAberrationEffect;
  58040. /**
  58041. * Grain post process which add noise to the image
  58042. */
  58043. grain: GrainPostProcess;
  58044. private _grainEffect;
  58045. /**
  58046. * Glow post process which adds a glow to emissive areas of the image
  58047. */
  58048. private _glowLayer;
  58049. /**
  58050. * Animations which can be used to tweak settings over a period of time
  58051. */
  58052. animations: Animation[];
  58053. private _imageProcessingConfigurationObserver;
  58054. private _sharpenEnabled;
  58055. private _bloomEnabled;
  58056. private _depthOfFieldEnabled;
  58057. private _depthOfFieldBlurLevel;
  58058. private _fxaaEnabled;
  58059. private _imageProcessingEnabled;
  58060. private _defaultPipelineTextureType;
  58061. private _bloomScale;
  58062. private _chromaticAberrationEnabled;
  58063. private _grainEnabled;
  58064. private _buildAllowed;
  58065. /**
  58066. * Gets active scene
  58067. */
  58068. readonly scene: Scene;
  58069. /**
  58070. * Enable or disable the sharpen process from the pipeline
  58071. */
  58072. sharpenEnabled: boolean;
  58073. private _resizeObserver;
  58074. private _hardwareScaleLevel;
  58075. private _bloomKernel;
  58076. /**
  58077. * Specifies the size of the bloom blur kernel, relative to the final output size
  58078. */
  58079. bloomKernel: number;
  58080. /**
  58081. * Specifies the weight of the bloom in the final rendering
  58082. */
  58083. private _bloomWeight;
  58084. /**
  58085. * Specifies the luma threshold for the area that will be blurred by the bloom
  58086. */
  58087. private _bloomThreshold;
  58088. private _hdr;
  58089. /**
  58090. * The strength of the bloom.
  58091. */
  58092. bloomWeight: number;
  58093. /**
  58094. * The strength of the bloom.
  58095. */
  58096. bloomThreshold: number;
  58097. /**
  58098. * The scale of the bloom, lower value will provide better performance.
  58099. */
  58100. bloomScale: number;
  58101. /**
  58102. * Enable or disable the bloom from the pipeline
  58103. */
  58104. bloomEnabled: boolean;
  58105. private _rebuildBloom;
  58106. /**
  58107. * If the depth of field is enabled.
  58108. */
  58109. depthOfFieldEnabled: boolean;
  58110. /**
  58111. * Blur level of the depth of field effect. (Higher blur will effect performance)
  58112. */
  58113. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  58114. /**
  58115. * If the anti aliasing is enabled.
  58116. */
  58117. fxaaEnabled: boolean;
  58118. private _samples;
  58119. /**
  58120. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  58121. */
  58122. samples: number;
  58123. /**
  58124. * If image processing is enabled.
  58125. */
  58126. imageProcessingEnabled: boolean;
  58127. /**
  58128. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  58129. */
  58130. glowLayerEnabled: boolean;
  58131. /**
  58132. * Gets the glow layer (or null if not defined)
  58133. */
  58134. readonly glowLayer: Nullable<GlowLayer>;
  58135. /**
  58136. * Enable or disable the chromaticAberration process from the pipeline
  58137. */
  58138. chromaticAberrationEnabled: boolean;
  58139. /**
  58140. * Enable or disable the grain process from the pipeline
  58141. */
  58142. grainEnabled: boolean;
  58143. /**
  58144. * @constructor
  58145. * @param name - The rendering pipeline name (default: "")
  58146. * @param hdr - If high dynamic range textures should be used (default: true)
  58147. * @param scene - The scene linked to this pipeline (default: the last created scene)
  58148. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  58149. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  58150. */
  58151. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  58152. /**
  58153. * Get the class name
  58154. * @returns "DefaultRenderingPipeline"
  58155. */
  58156. getClassName(): string;
  58157. /**
  58158. * Force the compilation of the entire pipeline.
  58159. */
  58160. prepare(): void;
  58161. private _hasCleared;
  58162. private _prevPostProcess;
  58163. private _prevPrevPostProcess;
  58164. private _setAutoClearAndTextureSharing;
  58165. private _depthOfFieldSceneObserver;
  58166. private _buildPipeline;
  58167. private _disposePostProcesses;
  58168. /**
  58169. * Adds a camera to the pipeline
  58170. * @param camera the camera to be added
  58171. */
  58172. addCamera(camera: Camera): void;
  58173. /**
  58174. * Removes a camera from the pipeline
  58175. * @param camera the camera to remove
  58176. */
  58177. removeCamera(camera: Camera): void;
  58178. /**
  58179. * Dispose of the pipeline and stop all post processes
  58180. */
  58181. dispose(): void;
  58182. /**
  58183. * Serialize the rendering pipeline (Used when exporting)
  58184. * @returns the serialized object
  58185. */
  58186. serialize(): any;
  58187. /**
  58188. * Parse the serialized pipeline
  58189. * @param source Source pipeline.
  58190. * @param scene The scene to load the pipeline to.
  58191. * @param rootUrl The URL of the serialized pipeline.
  58192. * @returns An instantiated pipeline from the serialized object.
  58193. */
  58194. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  58195. }
  58196. }
  58197. declare module BABYLON {
  58198. /** @hidden */
  58199. export var lensHighlightsPixelShader: {
  58200. name: string;
  58201. shader: string;
  58202. };
  58203. }
  58204. declare module BABYLON {
  58205. /** @hidden */
  58206. export var depthOfFieldPixelShader: {
  58207. name: string;
  58208. shader: string;
  58209. };
  58210. }
  58211. declare module BABYLON {
  58212. /**
  58213. * BABYLON.JS Chromatic Aberration GLSL Shader
  58214. * Author: Olivier Guyot
  58215. * Separates very slightly R, G and B colors on the edges of the screen
  58216. * Inspired by Francois Tarlier & Martins Upitis
  58217. */
  58218. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  58219. /**
  58220. * @ignore
  58221. * The chromatic aberration PostProcess id in the pipeline
  58222. */
  58223. LensChromaticAberrationEffect: string;
  58224. /**
  58225. * @ignore
  58226. * The highlights enhancing PostProcess id in the pipeline
  58227. */
  58228. HighlightsEnhancingEffect: string;
  58229. /**
  58230. * @ignore
  58231. * The depth-of-field PostProcess id in the pipeline
  58232. */
  58233. LensDepthOfFieldEffect: string;
  58234. private _scene;
  58235. private _depthTexture;
  58236. private _grainTexture;
  58237. private _chromaticAberrationPostProcess;
  58238. private _highlightsPostProcess;
  58239. private _depthOfFieldPostProcess;
  58240. private _edgeBlur;
  58241. private _grainAmount;
  58242. private _chromaticAberration;
  58243. private _distortion;
  58244. private _highlightsGain;
  58245. private _highlightsThreshold;
  58246. private _dofDistance;
  58247. private _dofAperture;
  58248. private _dofDarken;
  58249. private _dofPentagon;
  58250. private _blurNoise;
  58251. /**
  58252. * @constructor
  58253. *
  58254. * Effect parameters are as follow:
  58255. * {
  58256. * chromatic_aberration: number; // from 0 to x (1 for realism)
  58257. * edge_blur: number; // from 0 to x (1 for realism)
  58258. * distortion: number; // from 0 to x (1 for realism)
  58259. * grain_amount: number; // from 0 to 1
  58260. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  58261. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  58262. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  58263. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  58264. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  58265. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  58266. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  58267. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  58268. * }
  58269. * Note: if an effect parameter is unset, effect is disabled
  58270. *
  58271. * @param name The rendering pipeline name
  58272. * @param parameters - An object containing all parameters (see above)
  58273. * @param scene The scene linked to this pipeline
  58274. * @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)
  58275. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58276. */
  58277. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  58278. /**
  58279. * Get the class name
  58280. * @returns "LensRenderingPipeline"
  58281. */
  58282. getClassName(): string;
  58283. /**
  58284. * Gets associated scene
  58285. */
  58286. readonly scene: Scene;
  58287. /**
  58288. * Gets or sets the edge blur
  58289. */
  58290. edgeBlur: number;
  58291. /**
  58292. * Gets or sets the grain amount
  58293. */
  58294. grainAmount: number;
  58295. /**
  58296. * Gets or sets the chromatic aberration amount
  58297. */
  58298. chromaticAberration: number;
  58299. /**
  58300. * Gets or sets the depth of field aperture
  58301. */
  58302. dofAperture: number;
  58303. /**
  58304. * Gets or sets the edge distortion
  58305. */
  58306. edgeDistortion: number;
  58307. /**
  58308. * Gets or sets the depth of field distortion
  58309. */
  58310. dofDistortion: number;
  58311. /**
  58312. * Gets or sets the darken out of focus amount
  58313. */
  58314. darkenOutOfFocus: number;
  58315. /**
  58316. * Gets or sets a boolean indicating if blur noise is enabled
  58317. */
  58318. blurNoise: boolean;
  58319. /**
  58320. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  58321. */
  58322. pentagonBokeh: boolean;
  58323. /**
  58324. * Gets or sets the highlight grain amount
  58325. */
  58326. highlightsGain: number;
  58327. /**
  58328. * Gets or sets the highlight threshold
  58329. */
  58330. highlightsThreshold: number;
  58331. /**
  58332. * Sets the amount of blur at the edges
  58333. * @param amount blur amount
  58334. */
  58335. setEdgeBlur(amount: number): void;
  58336. /**
  58337. * Sets edge blur to 0
  58338. */
  58339. disableEdgeBlur(): void;
  58340. /**
  58341. * Sets the amout of grain
  58342. * @param amount Amount of grain
  58343. */
  58344. setGrainAmount(amount: number): void;
  58345. /**
  58346. * Set grain amount to 0
  58347. */
  58348. disableGrain(): void;
  58349. /**
  58350. * Sets the chromatic aberration amount
  58351. * @param amount amount of chromatic aberration
  58352. */
  58353. setChromaticAberration(amount: number): void;
  58354. /**
  58355. * Sets chromatic aberration amount to 0
  58356. */
  58357. disableChromaticAberration(): void;
  58358. /**
  58359. * Sets the EdgeDistortion amount
  58360. * @param amount amount of EdgeDistortion
  58361. */
  58362. setEdgeDistortion(amount: number): void;
  58363. /**
  58364. * Sets edge distortion to 0
  58365. */
  58366. disableEdgeDistortion(): void;
  58367. /**
  58368. * Sets the FocusDistance amount
  58369. * @param amount amount of FocusDistance
  58370. */
  58371. setFocusDistance(amount: number): void;
  58372. /**
  58373. * Disables depth of field
  58374. */
  58375. disableDepthOfField(): void;
  58376. /**
  58377. * Sets the Aperture amount
  58378. * @param amount amount of Aperture
  58379. */
  58380. setAperture(amount: number): void;
  58381. /**
  58382. * Sets the DarkenOutOfFocus amount
  58383. * @param amount amount of DarkenOutOfFocus
  58384. */
  58385. setDarkenOutOfFocus(amount: number): void;
  58386. private _pentagonBokehIsEnabled;
  58387. /**
  58388. * Creates a pentagon bokeh effect
  58389. */
  58390. enablePentagonBokeh(): void;
  58391. /**
  58392. * Disables the pentagon bokeh effect
  58393. */
  58394. disablePentagonBokeh(): void;
  58395. /**
  58396. * Enables noise blur
  58397. */
  58398. enableNoiseBlur(): void;
  58399. /**
  58400. * Disables noise blur
  58401. */
  58402. disableNoiseBlur(): void;
  58403. /**
  58404. * Sets the HighlightsGain amount
  58405. * @param amount amount of HighlightsGain
  58406. */
  58407. setHighlightsGain(amount: number): void;
  58408. /**
  58409. * Sets the HighlightsThreshold amount
  58410. * @param amount amount of HighlightsThreshold
  58411. */
  58412. setHighlightsThreshold(amount: number): void;
  58413. /**
  58414. * Disables highlights
  58415. */
  58416. disableHighlights(): void;
  58417. /**
  58418. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  58419. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  58420. */
  58421. dispose(disableDepthRender?: boolean): void;
  58422. private _createChromaticAberrationPostProcess;
  58423. private _createHighlightsPostProcess;
  58424. private _createDepthOfFieldPostProcess;
  58425. private _createGrainTexture;
  58426. }
  58427. }
  58428. declare module BABYLON {
  58429. /** @hidden */
  58430. export var ssao2PixelShader: {
  58431. name: string;
  58432. shader: string;
  58433. };
  58434. }
  58435. declare module BABYLON {
  58436. /** @hidden */
  58437. export var ssaoCombinePixelShader: {
  58438. name: string;
  58439. shader: string;
  58440. };
  58441. }
  58442. declare module BABYLON {
  58443. /**
  58444. * Render pipeline to produce ssao effect
  58445. */
  58446. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  58447. /**
  58448. * @ignore
  58449. * The PassPostProcess id in the pipeline that contains the original scene color
  58450. */
  58451. SSAOOriginalSceneColorEffect: string;
  58452. /**
  58453. * @ignore
  58454. * The SSAO PostProcess id in the pipeline
  58455. */
  58456. SSAORenderEffect: string;
  58457. /**
  58458. * @ignore
  58459. * The horizontal blur PostProcess id in the pipeline
  58460. */
  58461. SSAOBlurHRenderEffect: string;
  58462. /**
  58463. * @ignore
  58464. * The vertical blur PostProcess id in the pipeline
  58465. */
  58466. SSAOBlurVRenderEffect: string;
  58467. /**
  58468. * @ignore
  58469. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  58470. */
  58471. SSAOCombineRenderEffect: string;
  58472. /**
  58473. * The output strength of the SSAO post-process. Default value is 1.0.
  58474. */
  58475. totalStrength: number;
  58476. /**
  58477. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  58478. */
  58479. maxZ: number;
  58480. /**
  58481. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  58482. */
  58483. minZAspect: number;
  58484. private _samples;
  58485. /**
  58486. * Number of samples used for the SSAO calculations. Default value is 8
  58487. */
  58488. samples: number;
  58489. private _textureSamples;
  58490. /**
  58491. * Number of samples to use for antialiasing
  58492. */
  58493. textureSamples: number;
  58494. /**
  58495. * Ratio object used for SSAO ratio and blur ratio
  58496. */
  58497. private _ratio;
  58498. /**
  58499. * Dynamically generated sphere sampler.
  58500. */
  58501. private _sampleSphere;
  58502. /**
  58503. * Blur filter offsets
  58504. */
  58505. private _samplerOffsets;
  58506. private _expensiveBlur;
  58507. /**
  58508. * If bilateral blur should be used
  58509. */
  58510. expensiveBlur: boolean;
  58511. /**
  58512. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  58513. */
  58514. radius: number;
  58515. /**
  58516. * The base color of the SSAO post-process
  58517. * The final result is "base + ssao" between [0, 1]
  58518. */
  58519. base: number;
  58520. /**
  58521. * Support test.
  58522. */
  58523. static readonly IsSupported: boolean;
  58524. private _scene;
  58525. private _depthTexture;
  58526. private _normalTexture;
  58527. private _randomTexture;
  58528. private _originalColorPostProcess;
  58529. private _ssaoPostProcess;
  58530. private _blurHPostProcess;
  58531. private _blurVPostProcess;
  58532. private _ssaoCombinePostProcess;
  58533. private _firstUpdate;
  58534. /**
  58535. * Gets active scene
  58536. */
  58537. readonly scene: Scene;
  58538. /**
  58539. * @constructor
  58540. * @param name The rendering pipeline name
  58541. * @param scene The scene linked to this pipeline
  58542. * @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 }
  58543. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58544. */
  58545. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  58546. /**
  58547. * Get the class name
  58548. * @returns "SSAO2RenderingPipeline"
  58549. */
  58550. getClassName(): string;
  58551. /**
  58552. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  58553. */
  58554. dispose(disableGeometryBufferRenderer?: boolean): void;
  58555. private _createBlurPostProcess;
  58556. /** @hidden */
  58557. _rebuild(): void;
  58558. private _bits;
  58559. private _radicalInverse_VdC;
  58560. private _hammersley;
  58561. private _hemisphereSample_uniform;
  58562. private _generateHemisphere;
  58563. private _createSSAOPostProcess;
  58564. private _createSSAOCombinePostProcess;
  58565. private _createRandomTexture;
  58566. /**
  58567. * Serialize the rendering pipeline (Used when exporting)
  58568. * @returns the serialized object
  58569. */
  58570. serialize(): any;
  58571. /**
  58572. * Parse the serialized pipeline
  58573. * @param source Source pipeline.
  58574. * @param scene The scene to load the pipeline to.
  58575. * @param rootUrl The URL of the serialized pipeline.
  58576. * @returns An instantiated pipeline from the serialized object.
  58577. */
  58578. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  58579. }
  58580. }
  58581. declare module BABYLON {
  58582. /** @hidden */
  58583. export var ssaoPixelShader: {
  58584. name: string;
  58585. shader: string;
  58586. };
  58587. }
  58588. declare module BABYLON {
  58589. /**
  58590. * Render pipeline to produce ssao effect
  58591. */
  58592. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  58593. /**
  58594. * @ignore
  58595. * The PassPostProcess id in the pipeline that contains the original scene color
  58596. */
  58597. SSAOOriginalSceneColorEffect: string;
  58598. /**
  58599. * @ignore
  58600. * The SSAO PostProcess id in the pipeline
  58601. */
  58602. SSAORenderEffect: string;
  58603. /**
  58604. * @ignore
  58605. * The horizontal blur PostProcess id in the pipeline
  58606. */
  58607. SSAOBlurHRenderEffect: string;
  58608. /**
  58609. * @ignore
  58610. * The vertical blur PostProcess id in the pipeline
  58611. */
  58612. SSAOBlurVRenderEffect: string;
  58613. /**
  58614. * @ignore
  58615. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  58616. */
  58617. SSAOCombineRenderEffect: string;
  58618. /**
  58619. * The output strength of the SSAO post-process. Default value is 1.0.
  58620. */
  58621. totalStrength: number;
  58622. /**
  58623. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  58624. */
  58625. radius: number;
  58626. /**
  58627. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  58628. * Must not be equal to fallOff and superior to fallOff.
  58629. * Default value is 0.0075
  58630. */
  58631. area: number;
  58632. /**
  58633. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  58634. * Must not be equal to area and inferior to area.
  58635. * Default value is 0.000001
  58636. */
  58637. fallOff: number;
  58638. /**
  58639. * The base color of the SSAO post-process
  58640. * The final result is "base + ssao" between [0, 1]
  58641. */
  58642. base: number;
  58643. private _scene;
  58644. private _depthTexture;
  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, combineRatio: 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 "SSAORenderingPipeline"
  58667. */
  58668. getClassName(): string;
  58669. /**
  58670. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  58671. */
  58672. dispose(disableDepthRender?: boolean): void;
  58673. private _createBlurPostProcess;
  58674. /** @hidden */
  58675. _rebuild(): void;
  58676. private _createSSAOPostProcess;
  58677. private _createSSAOCombinePostProcess;
  58678. private _createRandomTexture;
  58679. }
  58680. }
  58681. declare module BABYLON {
  58682. /** @hidden */
  58683. export var standardPixelShader: {
  58684. name: string;
  58685. shader: string;
  58686. };
  58687. }
  58688. declare module BABYLON {
  58689. /**
  58690. * Standard rendering pipeline
  58691. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  58692. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  58693. */
  58694. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  58695. /**
  58696. * Public members
  58697. */
  58698. /**
  58699. * Post-process which contains the original scene color before the pipeline applies all the effects
  58700. */
  58701. originalPostProcess: Nullable<PostProcess>;
  58702. /**
  58703. * Post-process used to down scale an image x4
  58704. */
  58705. downSampleX4PostProcess: Nullable<PostProcess>;
  58706. /**
  58707. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  58708. */
  58709. brightPassPostProcess: Nullable<PostProcess>;
  58710. /**
  58711. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  58712. */
  58713. blurHPostProcesses: PostProcess[];
  58714. /**
  58715. * Post-process array storing all the vertical blur post-processes used by the pipeline
  58716. */
  58717. blurVPostProcesses: PostProcess[];
  58718. /**
  58719. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  58720. */
  58721. textureAdderPostProcess: Nullable<PostProcess>;
  58722. /**
  58723. * Post-process used to create volumetric lighting effect
  58724. */
  58725. volumetricLightPostProcess: Nullable<PostProcess>;
  58726. /**
  58727. * Post-process used to smooth the previous volumetric light post-process on the X axis
  58728. */
  58729. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  58730. /**
  58731. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  58732. */
  58733. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  58734. /**
  58735. * Post-process used to merge the volumetric light effect and the real scene color
  58736. */
  58737. volumetricLightMergePostProces: Nullable<PostProcess>;
  58738. /**
  58739. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  58740. */
  58741. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  58742. /**
  58743. * Base post-process used to calculate the average luminance of the final image for HDR
  58744. */
  58745. luminancePostProcess: Nullable<PostProcess>;
  58746. /**
  58747. * Post-processes used to create down sample post-processes in order to get
  58748. * the average luminance of the final image for HDR
  58749. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  58750. */
  58751. luminanceDownSamplePostProcesses: PostProcess[];
  58752. /**
  58753. * Post-process used to create a HDR effect (light adaptation)
  58754. */
  58755. hdrPostProcess: Nullable<PostProcess>;
  58756. /**
  58757. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  58758. */
  58759. textureAdderFinalPostProcess: Nullable<PostProcess>;
  58760. /**
  58761. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  58762. */
  58763. lensFlareFinalPostProcess: Nullable<PostProcess>;
  58764. /**
  58765. * Post-process used to merge the final HDR post-process and the real scene color
  58766. */
  58767. hdrFinalPostProcess: Nullable<PostProcess>;
  58768. /**
  58769. * Post-process used to create a lens flare effect
  58770. */
  58771. lensFlarePostProcess: Nullable<PostProcess>;
  58772. /**
  58773. * Post-process that merges the result of the lens flare post-process and the real scene color
  58774. */
  58775. lensFlareComposePostProcess: Nullable<PostProcess>;
  58776. /**
  58777. * Post-process used to create a motion blur effect
  58778. */
  58779. motionBlurPostProcess: Nullable<PostProcess>;
  58780. /**
  58781. * Post-process used to create a depth of field effect
  58782. */
  58783. depthOfFieldPostProcess: Nullable<PostProcess>;
  58784. /**
  58785. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  58786. */
  58787. fxaaPostProcess: Nullable<FxaaPostProcess>;
  58788. /**
  58789. * Represents the brightness threshold in order to configure the illuminated surfaces
  58790. */
  58791. brightThreshold: number;
  58792. /**
  58793. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  58794. */
  58795. blurWidth: number;
  58796. /**
  58797. * Sets if the blur for highlighted surfaces must be only horizontal
  58798. */
  58799. horizontalBlur: boolean;
  58800. /**
  58801. * Gets the overall exposure used by the pipeline
  58802. */
  58803. /**
  58804. * Sets the overall exposure used by the pipeline
  58805. */
  58806. exposure: number;
  58807. /**
  58808. * Texture used typically to simulate "dirty" on camera lens
  58809. */
  58810. lensTexture: Nullable<Texture>;
  58811. /**
  58812. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  58813. */
  58814. volumetricLightCoefficient: number;
  58815. /**
  58816. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  58817. */
  58818. volumetricLightPower: number;
  58819. /**
  58820. * Used the set the blur intensity to smooth the volumetric lights
  58821. */
  58822. volumetricLightBlurScale: number;
  58823. /**
  58824. * Light (spot or directional) used to generate the volumetric lights rays
  58825. * The source light must have a shadow generate so the pipeline can get its
  58826. * depth map
  58827. */
  58828. sourceLight: Nullable<SpotLight | DirectionalLight>;
  58829. /**
  58830. * For eye adaptation, represents the minimum luminance the eye can see
  58831. */
  58832. hdrMinimumLuminance: number;
  58833. /**
  58834. * For eye adaptation, represents the decrease luminance speed
  58835. */
  58836. hdrDecreaseRate: number;
  58837. /**
  58838. * For eye adaptation, represents the increase luminance speed
  58839. */
  58840. hdrIncreaseRate: number;
  58841. /**
  58842. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  58843. */
  58844. /**
  58845. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  58846. */
  58847. hdrAutoExposure: boolean;
  58848. /**
  58849. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  58850. */
  58851. lensColorTexture: Nullable<Texture>;
  58852. /**
  58853. * The overall strengh for the lens flare effect
  58854. */
  58855. lensFlareStrength: number;
  58856. /**
  58857. * Dispersion coefficient for lens flare ghosts
  58858. */
  58859. lensFlareGhostDispersal: number;
  58860. /**
  58861. * Main lens flare halo width
  58862. */
  58863. lensFlareHaloWidth: number;
  58864. /**
  58865. * Based on the lens distortion effect, defines how much the lens flare result
  58866. * is distorted
  58867. */
  58868. lensFlareDistortionStrength: number;
  58869. /**
  58870. * Lens star texture must be used to simulate rays on the flares and is available
  58871. * in the documentation
  58872. */
  58873. lensStarTexture: Nullable<Texture>;
  58874. /**
  58875. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  58876. * flare effect by taking account of the dirt texture
  58877. */
  58878. lensFlareDirtTexture: Nullable<Texture>;
  58879. /**
  58880. * Represents the focal length for the depth of field effect
  58881. */
  58882. depthOfFieldDistance: number;
  58883. /**
  58884. * Represents the blur intensity for the blurred part of the depth of field effect
  58885. */
  58886. depthOfFieldBlurWidth: number;
  58887. /**
  58888. * Gets how much the image is blurred by the movement while using the motion blur post-process
  58889. */
  58890. /**
  58891. * Sets how much the image is blurred by the movement while using the motion blur post-process
  58892. */
  58893. motionStrength: number;
  58894. /**
  58895. * Gets wether or not the motion blur post-process is object based or screen based.
  58896. */
  58897. /**
  58898. * Sets wether or not the motion blur post-process should be object based or screen based
  58899. */
  58900. objectBasedMotionBlur: boolean;
  58901. /**
  58902. * List of animations for the pipeline (IAnimatable implementation)
  58903. */
  58904. animations: Animation[];
  58905. /**
  58906. * Private members
  58907. */
  58908. private _scene;
  58909. private _currentDepthOfFieldSource;
  58910. private _basePostProcess;
  58911. private _fixedExposure;
  58912. private _currentExposure;
  58913. private _hdrAutoExposure;
  58914. private _hdrCurrentLuminance;
  58915. private _motionStrength;
  58916. private _isObjectBasedMotionBlur;
  58917. private _floatTextureType;
  58918. private _ratio;
  58919. private _bloomEnabled;
  58920. private _depthOfFieldEnabled;
  58921. private _vlsEnabled;
  58922. private _lensFlareEnabled;
  58923. private _hdrEnabled;
  58924. private _motionBlurEnabled;
  58925. private _fxaaEnabled;
  58926. private _motionBlurSamples;
  58927. private _volumetricLightStepsCount;
  58928. private _samples;
  58929. /**
  58930. * @ignore
  58931. * Specifies if the bloom pipeline is enabled
  58932. */
  58933. BloomEnabled: boolean;
  58934. /**
  58935. * @ignore
  58936. * Specifies if the depth of field pipeline is enabed
  58937. */
  58938. DepthOfFieldEnabled: boolean;
  58939. /**
  58940. * @ignore
  58941. * Specifies if the lens flare pipeline is enabed
  58942. */
  58943. LensFlareEnabled: boolean;
  58944. /**
  58945. * @ignore
  58946. * Specifies if the HDR pipeline is enabled
  58947. */
  58948. HDREnabled: boolean;
  58949. /**
  58950. * @ignore
  58951. * Specifies if the volumetric lights scattering effect is enabled
  58952. */
  58953. VLSEnabled: boolean;
  58954. /**
  58955. * @ignore
  58956. * Specifies if the motion blur effect is enabled
  58957. */
  58958. MotionBlurEnabled: boolean;
  58959. /**
  58960. * Specifies if anti-aliasing is enabled
  58961. */
  58962. fxaaEnabled: boolean;
  58963. /**
  58964. * Specifies the number of steps used to calculate the volumetric lights
  58965. * Typically in interval [50, 200]
  58966. */
  58967. volumetricLightStepsCount: number;
  58968. /**
  58969. * Specifies the number of samples used for the motion blur effect
  58970. * Typically in interval [16, 64]
  58971. */
  58972. motionBlurSamples: number;
  58973. /**
  58974. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  58975. */
  58976. samples: number;
  58977. /**
  58978. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  58979. * @constructor
  58980. * @param name The rendering pipeline name
  58981. * @param scene The scene linked to this pipeline
  58982. * @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)
  58983. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  58984. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58985. */
  58986. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  58987. private _buildPipeline;
  58988. private _createDownSampleX4PostProcess;
  58989. private _createBrightPassPostProcess;
  58990. private _createBlurPostProcesses;
  58991. private _createTextureAdderPostProcess;
  58992. private _createVolumetricLightPostProcess;
  58993. private _createLuminancePostProcesses;
  58994. private _createHdrPostProcess;
  58995. private _createLensFlarePostProcess;
  58996. private _createDepthOfFieldPostProcess;
  58997. private _createMotionBlurPostProcess;
  58998. private _getDepthTexture;
  58999. private _disposePostProcesses;
  59000. /**
  59001. * Dispose of the pipeline and stop all post processes
  59002. */
  59003. dispose(): void;
  59004. /**
  59005. * Serialize the rendering pipeline (Used when exporting)
  59006. * @returns the serialized object
  59007. */
  59008. serialize(): any;
  59009. /**
  59010. * Parse the serialized pipeline
  59011. * @param source Source pipeline.
  59012. * @param scene The scene to load the pipeline to.
  59013. * @param rootUrl The URL of the serialized pipeline.
  59014. * @returns An instantiated pipeline from the serialized object.
  59015. */
  59016. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  59017. /**
  59018. * Luminance steps
  59019. */
  59020. static LuminanceSteps: number;
  59021. }
  59022. }
  59023. declare module BABYLON {
  59024. /** @hidden */
  59025. export var tonemapPixelShader: {
  59026. name: string;
  59027. shader: string;
  59028. };
  59029. }
  59030. declare module BABYLON {
  59031. /** Defines operator used for tonemapping */
  59032. export enum TonemappingOperator {
  59033. /** Hable */
  59034. Hable = 0,
  59035. /** Reinhard */
  59036. Reinhard = 1,
  59037. /** HejiDawson */
  59038. HejiDawson = 2,
  59039. /** Photographic */
  59040. Photographic = 3
  59041. }
  59042. /**
  59043. * Defines a post process to apply tone mapping
  59044. */
  59045. export class TonemapPostProcess extends PostProcess {
  59046. private _operator;
  59047. /** Defines the required exposure adjustement */
  59048. exposureAdjustment: number;
  59049. /**
  59050. * Creates a new TonemapPostProcess
  59051. * @param name defines the name of the postprocess
  59052. * @param _operator defines the operator to use
  59053. * @param exposureAdjustment defines the required exposure adjustement
  59054. * @param camera defines the camera to use (can be null)
  59055. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  59056. * @param engine defines the hosting engine (can be ignore if camera is set)
  59057. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59058. */
  59059. constructor(name: string, _operator: TonemappingOperator,
  59060. /** Defines the required exposure adjustement */
  59061. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  59062. }
  59063. }
  59064. declare module BABYLON {
  59065. /** @hidden */
  59066. export var depthVertexShader: {
  59067. name: string;
  59068. shader: string;
  59069. };
  59070. }
  59071. declare module BABYLON {
  59072. /** @hidden */
  59073. export var volumetricLightScatteringPixelShader: {
  59074. name: string;
  59075. shader: string;
  59076. };
  59077. }
  59078. declare module BABYLON {
  59079. /** @hidden */
  59080. export var volumetricLightScatteringPassVertexShader: {
  59081. name: string;
  59082. shader: string;
  59083. };
  59084. }
  59085. declare module BABYLON {
  59086. /** @hidden */
  59087. export var volumetricLightScatteringPassPixelShader: {
  59088. name: string;
  59089. shader: string;
  59090. };
  59091. }
  59092. declare module BABYLON {
  59093. /**
  59094. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  59095. */
  59096. export class VolumetricLightScatteringPostProcess extends PostProcess {
  59097. private _volumetricLightScatteringPass;
  59098. private _volumetricLightScatteringRTT;
  59099. private _viewPort;
  59100. private _screenCoordinates;
  59101. private _cachedDefines;
  59102. /**
  59103. * If not undefined, the mesh position is computed from the attached node position
  59104. */
  59105. attachedNode: {
  59106. position: Vector3;
  59107. };
  59108. /**
  59109. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  59110. */
  59111. customMeshPosition: Vector3;
  59112. /**
  59113. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  59114. */
  59115. useCustomMeshPosition: boolean;
  59116. /**
  59117. * If the post-process should inverse the light scattering direction
  59118. */
  59119. invert: boolean;
  59120. /**
  59121. * The internal mesh used by the post-process
  59122. */
  59123. mesh: Mesh;
  59124. /**
  59125. * @hidden
  59126. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  59127. */
  59128. useDiffuseColor: boolean;
  59129. /**
  59130. * Array containing the excluded meshes not rendered in the internal pass
  59131. */
  59132. excludedMeshes: AbstractMesh[];
  59133. /**
  59134. * Controls the overall intensity of the post-process
  59135. */
  59136. exposure: number;
  59137. /**
  59138. * Dissipates each sample's contribution in range [0, 1]
  59139. */
  59140. decay: number;
  59141. /**
  59142. * Controls the overall intensity of each sample
  59143. */
  59144. weight: number;
  59145. /**
  59146. * Controls the density of each sample
  59147. */
  59148. density: number;
  59149. /**
  59150. * @constructor
  59151. * @param name The post-process name
  59152. * @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)
  59153. * @param camera The camera that the post-process will be attached to
  59154. * @param mesh The mesh used to create the light scattering
  59155. * @param samples The post-process quality, default 100
  59156. * @param samplingModeThe post-process filtering mode
  59157. * @param engine The babylon engine
  59158. * @param reusable If the post-process is reusable
  59159. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  59160. */
  59161. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  59162. /**
  59163. * Returns the string "VolumetricLightScatteringPostProcess"
  59164. * @returns "VolumetricLightScatteringPostProcess"
  59165. */
  59166. getClassName(): string;
  59167. private _isReady;
  59168. /**
  59169. * Sets the new light position for light scattering effect
  59170. * @param position The new custom light position
  59171. */
  59172. setCustomMeshPosition(position: Vector3): void;
  59173. /**
  59174. * Returns the light position for light scattering effect
  59175. * @return Vector3 The custom light position
  59176. */
  59177. getCustomMeshPosition(): Vector3;
  59178. /**
  59179. * Disposes the internal assets and detaches the post-process from the camera
  59180. */
  59181. dispose(camera: Camera): void;
  59182. /**
  59183. * Returns the render target texture used by the post-process
  59184. * @return the render target texture used by the post-process
  59185. */
  59186. getPass(): RenderTargetTexture;
  59187. private _meshExcluded;
  59188. private _createPass;
  59189. private _updateMeshScreenCoordinates;
  59190. /**
  59191. * Creates a default mesh for the Volumeric Light Scattering post-process
  59192. * @param name The mesh name
  59193. * @param scene The scene where to create the mesh
  59194. * @return the default mesh
  59195. */
  59196. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  59197. }
  59198. }
  59199. declare module BABYLON {
  59200. interface Scene {
  59201. /** @hidden (Backing field) */
  59202. _boundingBoxRenderer: BoundingBoxRenderer;
  59203. /** @hidden (Backing field) */
  59204. _forceShowBoundingBoxes: boolean;
  59205. /**
  59206. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  59207. */
  59208. forceShowBoundingBoxes: boolean;
  59209. /**
  59210. * Gets the bounding box renderer associated with the scene
  59211. * @returns a BoundingBoxRenderer
  59212. */
  59213. getBoundingBoxRenderer(): BoundingBoxRenderer;
  59214. }
  59215. interface AbstractMesh {
  59216. /** @hidden (Backing field) */
  59217. _showBoundingBox: boolean;
  59218. /**
  59219. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  59220. */
  59221. showBoundingBox: boolean;
  59222. }
  59223. /**
  59224. * Component responsible of rendering the bounding box of the meshes in a scene.
  59225. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  59226. */
  59227. export class BoundingBoxRenderer implements ISceneComponent {
  59228. /**
  59229. * The component name helpfull to identify the component in the list of scene components.
  59230. */
  59231. readonly name: string;
  59232. /**
  59233. * The scene the component belongs to.
  59234. */
  59235. scene: Scene;
  59236. /**
  59237. * Color of the bounding box lines placed in front of an object
  59238. */
  59239. frontColor: Color3;
  59240. /**
  59241. * Color of the bounding box lines placed behind an object
  59242. */
  59243. backColor: Color3;
  59244. /**
  59245. * Defines if the renderer should show the back lines or not
  59246. */
  59247. showBackLines: boolean;
  59248. /**
  59249. * @hidden
  59250. */
  59251. renderList: SmartArray<BoundingBox>;
  59252. private _colorShader;
  59253. private _vertexBuffers;
  59254. private _indexBuffer;
  59255. private _fillIndexBuffer;
  59256. private _fillIndexData;
  59257. /**
  59258. * Instantiates a new bounding box renderer in a scene.
  59259. * @param scene the scene the renderer renders in
  59260. */
  59261. constructor(scene: Scene);
  59262. /**
  59263. * Registers the component in a given scene
  59264. */
  59265. register(): void;
  59266. private _evaluateSubMesh;
  59267. private _activeMesh;
  59268. private _prepareRessources;
  59269. private _createIndexBuffer;
  59270. /**
  59271. * Rebuilds the elements related to this component in case of
  59272. * context lost for instance.
  59273. */
  59274. rebuild(): void;
  59275. /**
  59276. * @hidden
  59277. */
  59278. reset(): void;
  59279. /**
  59280. * Render the bounding boxes of a specific rendering group
  59281. * @param renderingGroupId defines the rendering group to render
  59282. */
  59283. render(renderingGroupId: number): void;
  59284. /**
  59285. * In case of occlusion queries, we can render the occlusion bounding box through this method
  59286. * @param mesh Define the mesh to render the occlusion bounding box for
  59287. */
  59288. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  59289. /**
  59290. * Dispose and release the resources attached to this renderer.
  59291. */
  59292. dispose(): void;
  59293. }
  59294. }
  59295. declare module BABYLON {
  59296. /** @hidden */
  59297. export var depthPixelShader: {
  59298. name: string;
  59299. shader: string;
  59300. };
  59301. }
  59302. declare module BABYLON {
  59303. /**
  59304. * This represents a depth renderer in Babylon.
  59305. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59306. */
  59307. export class DepthRenderer {
  59308. private _scene;
  59309. private _depthMap;
  59310. private _effect;
  59311. private readonly _storeNonLinearDepth;
  59312. private readonly _clearColor;
  59313. /** Get if the depth renderer is using packed depth or not */
  59314. readonly isPacked: boolean;
  59315. private _cachedDefines;
  59316. private _camera;
  59317. /**
  59318. * Specifiess that the depth renderer will only be used within
  59319. * the camera it is created for.
  59320. * This can help forcing its rendering during the camera processing.
  59321. */
  59322. useOnlyInActiveCamera: boolean;
  59323. /** @hidden */
  59324. static _SceneComponentInitialization: (scene: Scene) => void;
  59325. /**
  59326. * Instantiates a depth renderer
  59327. * @param scene The scene the renderer belongs to
  59328. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59329. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59330. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59331. */
  59332. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  59333. /**
  59334. * Creates the depth rendering effect and checks if the effect is ready.
  59335. * @param subMesh The submesh to be used to render the depth map of
  59336. * @param useInstances If multiple world instances should be used
  59337. * @returns if the depth renderer is ready to render the depth map
  59338. */
  59339. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59340. /**
  59341. * Gets the texture which the depth map will be written to.
  59342. * @returns The depth map texture
  59343. */
  59344. getDepthMap(): RenderTargetTexture;
  59345. /**
  59346. * Disposes of the depth renderer.
  59347. */
  59348. dispose(): void;
  59349. }
  59350. }
  59351. declare module BABYLON {
  59352. interface Scene {
  59353. /** @hidden (Backing field) */
  59354. _depthRenderer: {
  59355. [id: string]: DepthRenderer;
  59356. };
  59357. /**
  59358. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  59359. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  59360. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59361. * @returns the created depth renderer
  59362. */
  59363. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  59364. /**
  59365. * Disables a depth renderer for a given camera
  59366. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  59367. */
  59368. disableDepthRenderer(camera?: Nullable<Camera>): void;
  59369. }
  59370. /**
  59371. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  59372. * in several rendering techniques.
  59373. */
  59374. export class DepthRendererSceneComponent implements ISceneComponent {
  59375. /**
  59376. * The component name helpfull to identify the component in the list of scene components.
  59377. */
  59378. readonly name: string;
  59379. /**
  59380. * The scene the component belongs to.
  59381. */
  59382. scene: Scene;
  59383. /**
  59384. * Creates a new instance of the component for the given scene
  59385. * @param scene Defines the scene to register the component in
  59386. */
  59387. constructor(scene: Scene);
  59388. /**
  59389. * Registers the component in a given scene
  59390. */
  59391. register(): void;
  59392. /**
  59393. * Rebuilds the elements related to this component in case of
  59394. * context lost for instance.
  59395. */
  59396. rebuild(): void;
  59397. /**
  59398. * Disposes the component and the associated ressources
  59399. */
  59400. dispose(): void;
  59401. private _gatherRenderTargets;
  59402. private _gatherActiveCameraRenderTargets;
  59403. }
  59404. }
  59405. declare module BABYLON {
  59406. /** @hidden */
  59407. export var outlinePixelShader: {
  59408. name: string;
  59409. shader: string;
  59410. };
  59411. }
  59412. declare module BABYLON {
  59413. /** @hidden */
  59414. export var outlineVertexShader: {
  59415. name: string;
  59416. shader: string;
  59417. };
  59418. }
  59419. declare module BABYLON {
  59420. interface Scene {
  59421. /** @hidden */
  59422. _outlineRenderer: OutlineRenderer;
  59423. /**
  59424. * Gets the outline renderer associated with the scene
  59425. * @returns a OutlineRenderer
  59426. */
  59427. getOutlineRenderer(): OutlineRenderer;
  59428. }
  59429. interface AbstractMesh {
  59430. /** @hidden (Backing field) */
  59431. _renderOutline: boolean;
  59432. /**
  59433. * Gets or sets a boolean indicating if the outline must be rendered as well
  59434. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  59435. */
  59436. renderOutline: boolean;
  59437. /** @hidden (Backing field) */
  59438. _renderOverlay: boolean;
  59439. /**
  59440. * Gets or sets a boolean indicating if the overlay must be rendered as well
  59441. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  59442. */
  59443. renderOverlay: boolean;
  59444. }
  59445. /**
  59446. * This class is responsible to draw bothe outline/overlay of meshes.
  59447. * It should not be used directly but through the available method on mesh.
  59448. */
  59449. export class OutlineRenderer implements ISceneComponent {
  59450. /**
  59451. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  59452. */
  59453. private static _StencilReference;
  59454. /**
  59455. * The name of the component. Each component must have a unique name.
  59456. */
  59457. name: string;
  59458. /**
  59459. * The scene the component belongs to.
  59460. */
  59461. scene: Scene;
  59462. /**
  59463. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  59464. */
  59465. zOffset: number;
  59466. private _engine;
  59467. private _effect;
  59468. private _cachedDefines;
  59469. private _savedDepthWrite;
  59470. /**
  59471. * Instantiates a new outline renderer. (There could be only one per scene).
  59472. * @param scene Defines the scene it belongs to
  59473. */
  59474. constructor(scene: Scene);
  59475. /**
  59476. * Register the component to one instance of a scene.
  59477. */
  59478. register(): void;
  59479. /**
  59480. * Rebuilds the elements related to this component in case of
  59481. * context lost for instance.
  59482. */
  59483. rebuild(): void;
  59484. /**
  59485. * Disposes the component and the associated ressources.
  59486. */
  59487. dispose(): void;
  59488. /**
  59489. * Renders the outline in the canvas.
  59490. * @param subMesh Defines the sumesh to render
  59491. * @param batch Defines the batch of meshes in case of instances
  59492. * @param useOverlay Defines if the rendering is for the overlay or the outline
  59493. */
  59494. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  59495. /**
  59496. * Returns whether or not the outline renderer is ready for a given submesh.
  59497. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  59498. * @param subMesh Defines the submesh to check readyness for
  59499. * @param useInstances Defines wheter wee are trying to render instances or not
  59500. * @returns true if ready otherwise false
  59501. */
  59502. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59503. private _beforeRenderingMesh;
  59504. private _afterRenderingMesh;
  59505. }
  59506. }
  59507. declare module BABYLON {
  59508. /**
  59509. * Class used to manage multiple sprites of different sizes on the same spritesheet
  59510. * @see http://doc.babylonjs.com/babylon101/sprites
  59511. */
  59512. export class SpritePackedManager extends SpriteManager {
  59513. /** defines the packed manager's name */
  59514. name: string;
  59515. /**
  59516. * Creates a new sprite manager from a packed sprite sheet
  59517. * @param name defines the manager's name
  59518. * @param imgUrl defines the sprite sheet url
  59519. * @param capacity defines the maximum allowed number of sprites
  59520. * @param scene defines the hosting scene
  59521. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  59522. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  59523. * @param samplingMode defines the smapling mode to use with spritesheet
  59524. * @param fromPacked set to true; do not alter
  59525. */
  59526. constructor(
  59527. /** defines the packed manager's name */
  59528. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  59529. }
  59530. }
  59531. declare module BABYLON {
  59532. /**
  59533. * Defines the list of states available for a task inside a AssetsManager
  59534. */
  59535. export enum AssetTaskState {
  59536. /**
  59537. * Initialization
  59538. */
  59539. INIT = 0,
  59540. /**
  59541. * Running
  59542. */
  59543. RUNNING = 1,
  59544. /**
  59545. * Done
  59546. */
  59547. DONE = 2,
  59548. /**
  59549. * Error
  59550. */
  59551. ERROR = 3
  59552. }
  59553. /**
  59554. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  59555. */
  59556. export abstract class AbstractAssetTask {
  59557. /**
  59558. * Task name
  59559. */ name: string;
  59560. /**
  59561. * Callback called when the task is successful
  59562. */
  59563. onSuccess: (task: any) => void;
  59564. /**
  59565. * Callback called when the task is not successful
  59566. */
  59567. onError: (task: any, message?: string, exception?: any) => void;
  59568. /**
  59569. * Creates a new AssetsManager
  59570. * @param name defines the name of the task
  59571. */
  59572. constructor(
  59573. /**
  59574. * Task name
  59575. */ name: string);
  59576. private _isCompleted;
  59577. private _taskState;
  59578. private _errorObject;
  59579. /**
  59580. * Get if the task is completed
  59581. */
  59582. readonly isCompleted: boolean;
  59583. /**
  59584. * Gets the current state of the task
  59585. */
  59586. readonly taskState: AssetTaskState;
  59587. /**
  59588. * Gets the current error object (if task is in error)
  59589. */
  59590. readonly errorObject: {
  59591. message?: string;
  59592. exception?: any;
  59593. };
  59594. /**
  59595. * Internal only
  59596. * @hidden
  59597. */
  59598. _setErrorObject(message?: string, exception?: any): void;
  59599. /**
  59600. * Execute the current task
  59601. * @param scene defines the scene where you want your assets to be loaded
  59602. * @param onSuccess is a callback called when the task is successfully executed
  59603. * @param onError is a callback called if an error occurs
  59604. */
  59605. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59606. /**
  59607. * Execute the current task
  59608. * @param scene defines the scene where you want your assets to be loaded
  59609. * @param onSuccess is a callback called when the task is successfully executed
  59610. * @param onError is a callback called if an error occurs
  59611. */
  59612. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59613. /**
  59614. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  59615. * This can be used with failed tasks that have the reason for failure fixed.
  59616. */
  59617. reset(): void;
  59618. private onErrorCallback;
  59619. private onDoneCallback;
  59620. }
  59621. /**
  59622. * Define the interface used by progress events raised during assets loading
  59623. */
  59624. export interface IAssetsProgressEvent {
  59625. /**
  59626. * Defines the number of remaining tasks to process
  59627. */
  59628. remainingCount: number;
  59629. /**
  59630. * Defines the total number of tasks
  59631. */
  59632. totalCount: number;
  59633. /**
  59634. * Defines the task that was just processed
  59635. */
  59636. task: AbstractAssetTask;
  59637. }
  59638. /**
  59639. * Class used to share progress information about assets loading
  59640. */
  59641. export class AssetsProgressEvent implements IAssetsProgressEvent {
  59642. /**
  59643. * Defines the number of remaining tasks to process
  59644. */
  59645. remainingCount: number;
  59646. /**
  59647. * Defines the total number of tasks
  59648. */
  59649. totalCount: number;
  59650. /**
  59651. * Defines the task that was just processed
  59652. */
  59653. task: AbstractAssetTask;
  59654. /**
  59655. * Creates a AssetsProgressEvent
  59656. * @param remainingCount defines the number of remaining tasks to process
  59657. * @param totalCount defines the total number of tasks
  59658. * @param task defines the task that was just processed
  59659. */
  59660. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  59661. }
  59662. /**
  59663. * Define a task used by AssetsManager to load meshes
  59664. */
  59665. export class MeshAssetTask extends AbstractAssetTask {
  59666. /**
  59667. * Defines the name of the task
  59668. */
  59669. name: string;
  59670. /**
  59671. * Defines the list of mesh's names you want to load
  59672. */
  59673. meshesNames: any;
  59674. /**
  59675. * Defines the root url to use as a base to load your meshes and associated resources
  59676. */
  59677. rootUrl: string;
  59678. /**
  59679. * Defines the filename of the scene to load from
  59680. */
  59681. sceneFilename: string;
  59682. /**
  59683. * Gets the list of loaded meshes
  59684. */
  59685. loadedMeshes: Array<AbstractMesh>;
  59686. /**
  59687. * Gets the list of loaded particle systems
  59688. */
  59689. loadedParticleSystems: Array<IParticleSystem>;
  59690. /**
  59691. * Gets the list of loaded skeletons
  59692. */
  59693. loadedSkeletons: Array<Skeleton>;
  59694. /**
  59695. * Gets the list of loaded animation groups
  59696. */
  59697. loadedAnimationGroups: Array<AnimationGroup>;
  59698. /**
  59699. * Callback called when the task is successful
  59700. */
  59701. onSuccess: (task: MeshAssetTask) => void;
  59702. /**
  59703. * Callback called when the task is successful
  59704. */
  59705. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  59706. /**
  59707. * Creates a new MeshAssetTask
  59708. * @param name defines the name of the task
  59709. * @param meshesNames defines the list of mesh's names you want to load
  59710. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  59711. * @param sceneFilename defines the filename of the scene to load from
  59712. */
  59713. constructor(
  59714. /**
  59715. * Defines the name of the task
  59716. */
  59717. name: string,
  59718. /**
  59719. * Defines the list of mesh's names you want to load
  59720. */
  59721. meshesNames: any,
  59722. /**
  59723. * Defines the root url to use as a base to load your meshes and associated resources
  59724. */
  59725. rootUrl: string,
  59726. /**
  59727. * Defines the filename of the scene to load from
  59728. */
  59729. sceneFilename: string);
  59730. /**
  59731. * Execute the current task
  59732. * @param scene defines the scene where you want your assets to be loaded
  59733. * @param onSuccess is a callback called when the task is successfully executed
  59734. * @param onError is a callback called if an error occurs
  59735. */
  59736. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59737. }
  59738. /**
  59739. * Define a task used by AssetsManager to load text content
  59740. */
  59741. export class TextFileAssetTask extends AbstractAssetTask {
  59742. /**
  59743. * Defines the name of the task
  59744. */
  59745. name: string;
  59746. /**
  59747. * Defines the location of the file to load
  59748. */
  59749. url: string;
  59750. /**
  59751. * Gets the loaded text string
  59752. */
  59753. text: string;
  59754. /**
  59755. * Callback called when the task is successful
  59756. */
  59757. onSuccess: (task: TextFileAssetTask) => void;
  59758. /**
  59759. * Callback called when the task is successful
  59760. */
  59761. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  59762. /**
  59763. * Creates a new TextFileAssetTask object
  59764. * @param name defines the name of the task
  59765. * @param url defines the location of the file to load
  59766. */
  59767. constructor(
  59768. /**
  59769. * Defines the name of the task
  59770. */
  59771. name: string,
  59772. /**
  59773. * Defines the location of the file to load
  59774. */
  59775. url: string);
  59776. /**
  59777. * Execute the current task
  59778. * @param scene defines the scene where you want your assets to be loaded
  59779. * @param onSuccess is a callback called when the task is successfully executed
  59780. * @param onError is a callback called if an error occurs
  59781. */
  59782. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59783. }
  59784. /**
  59785. * Define a task used by AssetsManager to load binary data
  59786. */
  59787. export class BinaryFileAssetTask extends AbstractAssetTask {
  59788. /**
  59789. * Defines the name of the task
  59790. */
  59791. name: string;
  59792. /**
  59793. * Defines the location of the file to load
  59794. */
  59795. url: string;
  59796. /**
  59797. * Gets the lodaded data (as an array buffer)
  59798. */
  59799. data: ArrayBuffer;
  59800. /**
  59801. * Callback called when the task is successful
  59802. */
  59803. onSuccess: (task: BinaryFileAssetTask) => void;
  59804. /**
  59805. * Callback called when the task is successful
  59806. */
  59807. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  59808. /**
  59809. * Creates a new BinaryFileAssetTask object
  59810. * @param name defines the name of the new task
  59811. * @param url defines the location of the file to load
  59812. */
  59813. constructor(
  59814. /**
  59815. * Defines the name of the task
  59816. */
  59817. name: string,
  59818. /**
  59819. * Defines the location of the file to load
  59820. */
  59821. url: string);
  59822. /**
  59823. * Execute the current task
  59824. * @param scene defines the scene where you want your assets to be loaded
  59825. * @param onSuccess is a callback called when the task is successfully executed
  59826. * @param onError is a callback called if an error occurs
  59827. */
  59828. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59829. }
  59830. /**
  59831. * Define a task used by AssetsManager to load images
  59832. */
  59833. export class ImageAssetTask extends AbstractAssetTask {
  59834. /**
  59835. * Defines the name of the task
  59836. */
  59837. name: string;
  59838. /**
  59839. * Defines the location of the image to load
  59840. */
  59841. url: string;
  59842. /**
  59843. * Gets the loaded images
  59844. */
  59845. image: HTMLImageElement;
  59846. /**
  59847. * Callback called when the task is successful
  59848. */
  59849. onSuccess: (task: ImageAssetTask) => void;
  59850. /**
  59851. * Callback called when the task is successful
  59852. */
  59853. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  59854. /**
  59855. * Creates a new ImageAssetTask
  59856. * @param name defines the name of the task
  59857. * @param url defines the location of the image to load
  59858. */
  59859. constructor(
  59860. /**
  59861. * Defines the name of the task
  59862. */
  59863. name: string,
  59864. /**
  59865. * Defines the location of the image to load
  59866. */
  59867. url: string);
  59868. /**
  59869. * Execute the current task
  59870. * @param scene defines the scene where you want your assets to be loaded
  59871. * @param onSuccess is a callback called when the task is successfully executed
  59872. * @param onError is a callback called if an error occurs
  59873. */
  59874. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59875. }
  59876. /**
  59877. * Defines the interface used by texture loading tasks
  59878. */
  59879. export interface ITextureAssetTask<TEX extends BaseTexture> {
  59880. /**
  59881. * Gets the loaded texture
  59882. */
  59883. texture: TEX;
  59884. }
  59885. /**
  59886. * Define a task used by AssetsManager to load 2D textures
  59887. */
  59888. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  59889. /**
  59890. * Defines the name of the task
  59891. */
  59892. name: string;
  59893. /**
  59894. * Defines the location of the file to load
  59895. */
  59896. url: string;
  59897. /**
  59898. * Defines if mipmap should not be generated (default is false)
  59899. */
  59900. noMipmap?: boolean | undefined;
  59901. /**
  59902. * Defines if texture must be inverted on Y axis (default is false)
  59903. */
  59904. invertY?: boolean | undefined;
  59905. /**
  59906. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  59907. */
  59908. samplingMode: number;
  59909. /**
  59910. * Gets the loaded texture
  59911. */
  59912. texture: Texture;
  59913. /**
  59914. * Callback called when the task is successful
  59915. */
  59916. onSuccess: (task: TextureAssetTask) => void;
  59917. /**
  59918. * Callback called when the task is successful
  59919. */
  59920. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  59921. /**
  59922. * Creates a new TextureAssetTask object
  59923. * @param name defines the name of the task
  59924. * @param url defines the location of the file to load
  59925. * @param noMipmap defines if mipmap should not be generated (default is false)
  59926. * @param invertY defines if texture must be inverted on Y axis (default is false)
  59927. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  59928. */
  59929. constructor(
  59930. /**
  59931. * Defines the name of the task
  59932. */
  59933. name: string,
  59934. /**
  59935. * Defines the location of the file to load
  59936. */
  59937. url: string,
  59938. /**
  59939. * Defines if mipmap should not be generated (default is false)
  59940. */
  59941. noMipmap?: boolean | undefined,
  59942. /**
  59943. * Defines if texture must be inverted on Y axis (default is false)
  59944. */
  59945. invertY?: boolean | undefined,
  59946. /**
  59947. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  59948. */
  59949. samplingMode?: number);
  59950. /**
  59951. * Execute the current task
  59952. * @param scene defines the scene where you want your assets to be loaded
  59953. * @param onSuccess is a callback called when the task is successfully executed
  59954. * @param onError is a callback called if an error occurs
  59955. */
  59956. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59957. }
  59958. /**
  59959. * Define a task used by AssetsManager to load cube textures
  59960. */
  59961. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  59962. /**
  59963. * Defines the name of the task
  59964. */
  59965. name: string;
  59966. /**
  59967. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  59968. */
  59969. url: string;
  59970. /**
  59971. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  59972. */
  59973. extensions?: string[] | undefined;
  59974. /**
  59975. * Defines if mipmaps should not be generated (default is false)
  59976. */
  59977. noMipmap?: boolean | undefined;
  59978. /**
  59979. * Defines the explicit list of files (undefined by default)
  59980. */
  59981. files?: string[] | undefined;
  59982. /**
  59983. * Gets the loaded texture
  59984. */
  59985. texture: CubeTexture;
  59986. /**
  59987. * Callback called when the task is successful
  59988. */
  59989. onSuccess: (task: CubeTextureAssetTask) => void;
  59990. /**
  59991. * Callback called when the task is successful
  59992. */
  59993. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  59994. /**
  59995. * Creates a new CubeTextureAssetTask
  59996. * @param name defines the name of the task
  59997. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  59998. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  59999. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60000. * @param files defines the explicit list of files (undefined by default)
  60001. */
  60002. constructor(
  60003. /**
  60004. * Defines the name of the task
  60005. */
  60006. name: string,
  60007. /**
  60008. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60009. */
  60010. url: string,
  60011. /**
  60012. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60013. */
  60014. extensions?: string[] | undefined,
  60015. /**
  60016. * Defines if mipmaps should not be generated (default is false)
  60017. */
  60018. noMipmap?: boolean | undefined,
  60019. /**
  60020. * Defines the explicit list of files (undefined by default)
  60021. */
  60022. files?: string[] | undefined);
  60023. /**
  60024. * Execute the current task
  60025. * @param scene defines the scene where you want your assets to be loaded
  60026. * @param onSuccess is a callback called when the task is successfully executed
  60027. * @param onError is a callback called if an error occurs
  60028. */
  60029. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60030. }
  60031. /**
  60032. * Define a task used by AssetsManager to load HDR cube textures
  60033. */
  60034. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  60035. /**
  60036. * Defines the name of the task
  60037. */
  60038. name: string;
  60039. /**
  60040. * Defines the location of the file to load
  60041. */
  60042. url: string;
  60043. /**
  60044. * Defines the desired size (the more it increases the longer the generation will be)
  60045. */
  60046. size: number;
  60047. /**
  60048. * Defines if mipmaps should not be generated (default is false)
  60049. */
  60050. noMipmap: boolean;
  60051. /**
  60052. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60053. */
  60054. generateHarmonics: boolean;
  60055. /**
  60056. * 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)
  60057. */
  60058. gammaSpace: boolean;
  60059. /**
  60060. * Internal Use Only
  60061. */
  60062. reserved: boolean;
  60063. /**
  60064. * Gets the loaded texture
  60065. */
  60066. texture: HDRCubeTexture;
  60067. /**
  60068. * Callback called when the task is successful
  60069. */
  60070. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  60071. /**
  60072. * Callback called when the task is successful
  60073. */
  60074. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  60075. /**
  60076. * Creates a new HDRCubeTextureAssetTask object
  60077. * @param name defines the name of the task
  60078. * @param url defines the location of the file to load
  60079. * @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.
  60080. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60081. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60082. * @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)
  60083. * @param reserved Internal use only
  60084. */
  60085. constructor(
  60086. /**
  60087. * Defines the name of the task
  60088. */
  60089. name: string,
  60090. /**
  60091. * Defines the location of the file to load
  60092. */
  60093. url: string,
  60094. /**
  60095. * Defines the desired size (the more it increases the longer the generation will be)
  60096. */
  60097. size: number,
  60098. /**
  60099. * Defines if mipmaps should not be generated (default is false)
  60100. */
  60101. noMipmap?: boolean,
  60102. /**
  60103. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60104. */
  60105. generateHarmonics?: boolean,
  60106. /**
  60107. * 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)
  60108. */
  60109. gammaSpace?: boolean,
  60110. /**
  60111. * Internal Use Only
  60112. */
  60113. reserved?: boolean);
  60114. /**
  60115. * Execute the current task
  60116. * @param scene defines the scene where you want your assets to be loaded
  60117. * @param onSuccess is a callback called when the task is successfully executed
  60118. * @param onError is a callback called if an error occurs
  60119. */
  60120. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60121. }
  60122. /**
  60123. * Define a task used by AssetsManager to load Equirectangular cube textures
  60124. */
  60125. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  60126. /**
  60127. * Defines the name of the task
  60128. */
  60129. name: string;
  60130. /**
  60131. * Defines the location of the file to load
  60132. */
  60133. url: string;
  60134. /**
  60135. * Defines the desired size (the more it increases the longer the generation will be)
  60136. */
  60137. size: number;
  60138. /**
  60139. * Defines if mipmaps should not be generated (default is false)
  60140. */
  60141. noMipmap: boolean;
  60142. /**
  60143. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60144. * but the standard material would require them in Gamma space) (default is true)
  60145. */
  60146. gammaSpace: boolean;
  60147. /**
  60148. * Gets the loaded texture
  60149. */
  60150. texture: EquiRectangularCubeTexture;
  60151. /**
  60152. * Callback called when the task is successful
  60153. */
  60154. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  60155. /**
  60156. * Callback called when the task is successful
  60157. */
  60158. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  60159. /**
  60160. * Creates a new EquiRectangularCubeTextureAssetTask object
  60161. * @param name defines the name of the task
  60162. * @param url defines the location of the file to load
  60163. * @param size defines the desired size (the more it increases the longer the generation will be)
  60164. * If the size is omitted this implies you are using a preprocessed cubemap.
  60165. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60166. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  60167. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  60168. * (default is true)
  60169. */
  60170. constructor(
  60171. /**
  60172. * Defines the name of the task
  60173. */
  60174. name: string,
  60175. /**
  60176. * Defines the location of the file to load
  60177. */
  60178. url: string,
  60179. /**
  60180. * Defines the desired size (the more it increases the longer the generation will be)
  60181. */
  60182. size: number,
  60183. /**
  60184. * Defines if mipmaps should not be generated (default is false)
  60185. */
  60186. noMipmap?: boolean,
  60187. /**
  60188. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60189. * but the standard material would require them in Gamma space) (default is true)
  60190. */
  60191. gammaSpace?: boolean);
  60192. /**
  60193. * Execute the current task
  60194. * @param scene defines the scene where you want your assets to be loaded
  60195. * @param onSuccess is a callback called when the task is successfully executed
  60196. * @param onError is a callback called if an error occurs
  60197. */
  60198. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60199. }
  60200. /**
  60201. * This class can be used to easily import assets into a scene
  60202. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  60203. */
  60204. export class AssetsManager {
  60205. private _scene;
  60206. private _isLoading;
  60207. protected _tasks: AbstractAssetTask[];
  60208. protected _waitingTasksCount: number;
  60209. protected _totalTasksCount: number;
  60210. /**
  60211. * Callback called when all tasks are processed
  60212. */
  60213. onFinish: (tasks: AbstractAssetTask[]) => void;
  60214. /**
  60215. * Callback called when a task is successful
  60216. */
  60217. onTaskSuccess: (task: AbstractAssetTask) => void;
  60218. /**
  60219. * Callback called when a task had an error
  60220. */
  60221. onTaskError: (task: AbstractAssetTask) => void;
  60222. /**
  60223. * Callback called when a task is done (whatever the result is)
  60224. */
  60225. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  60226. /**
  60227. * Observable called when all tasks are processed
  60228. */
  60229. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  60230. /**
  60231. * Observable called when a task had an error
  60232. */
  60233. onTaskErrorObservable: Observable<AbstractAssetTask>;
  60234. /**
  60235. * Observable called when all tasks were executed
  60236. */
  60237. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  60238. /**
  60239. * Observable called when a task is done (whatever the result is)
  60240. */
  60241. onProgressObservable: Observable<IAssetsProgressEvent>;
  60242. /**
  60243. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  60244. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  60245. */
  60246. useDefaultLoadingScreen: boolean;
  60247. /**
  60248. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  60249. * when all assets have been downloaded.
  60250. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  60251. */
  60252. autoHideLoadingUI: boolean;
  60253. /**
  60254. * Creates a new AssetsManager
  60255. * @param scene defines the scene to work on
  60256. */
  60257. constructor(scene: Scene);
  60258. /**
  60259. * Add a MeshAssetTask to the list of active tasks
  60260. * @param taskName defines the name of the new task
  60261. * @param meshesNames defines the name of meshes to load
  60262. * @param rootUrl defines the root url to use to locate files
  60263. * @param sceneFilename defines the filename of the scene file
  60264. * @returns a new MeshAssetTask object
  60265. */
  60266. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  60267. /**
  60268. * Add a TextFileAssetTask to the list of active tasks
  60269. * @param taskName defines the name of the new task
  60270. * @param url defines the url of the file to load
  60271. * @returns a new TextFileAssetTask object
  60272. */
  60273. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  60274. /**
  60275. * Add a BinaryFileAssetTask to the list of active tasks
  60276. * @param taskName defines the name of the new task
  60277. * @param url defines the url of the file to load
  60278. * @returns a new BinaryFileAssetTask object
  60279. */
  60280. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  60281. /**
  60282. * Add a ImageAssetTask to the list of active tasks
  60283. * @param taskName defines the name of the new task
  60284. * @param url defines the url of the file to load
  60285. * @returns a new ImageAssetTask object
  60286. */
  60287. addImageTask(taskName: string, url: string): ImageAssetTask;
  60288. /**
  60289. * Add a TextureAssetTask to the list of active tasks
  60290. * @param taskName defines the name of the new task
  60291. * @param url defines the url of the file to load
  60292. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60293. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  60294. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60295. * @returns a new TextureAssetTask object
  60296. */
  60297. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  60298. /**
  60299. * Add a CubeTextureAssetTask to the list of active tasks
  60300. * @param taskName defines the name of the new task
  60301. * @param url defines the url of the file to load
  60302. * @param extensions defines the extension to use to load the cube map (can be null)
  60303. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60304. * @param files defines the list of files to load (can be null)
  60305. * @returns a new CubeTextureAssetTask object
  60306. */
  60307. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  60308. /**
  60309. *
  60310. * Add a HDRCubeTextureAssetTask to the list of active tasks
  60311. * @param taskName defines the name of the new task
  60312. * @param url defines the url of the file to load
  60313. * @param size defines the size you want for the cubemap (can be null)
  60314. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60315. * @param generateHarmonics defines if you want to automatically generate (true by default)
  60316. * @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)
  60317. * @param reserved Internal use only
  60318. * @returns a new HDRCubeTextureAssetTask object
  60319. */
  60320. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  60321. /**
  60322. *
  60323. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  60324. * @param taskName defines the name of the new task
  60325. * @param url defines the url of the file to load
  60326. * @param size defines the size you want for the cubemap (can be null)
  60327. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60328. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60329. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60330. * @returns a new EquiRectangularCubeTextureAssetTask object
  60331. */
  60332. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  60333. /**
  60334. * Remove a task from the assets manager.
  60335. * @param task the task to remove
  60336. */
  60337. removeTask(task: AbstractAssetTask): void;
  60338. private _decreaseWaitingTasksCount;
  60339. private _runTask;
  60340. /**
  60341. * Reset the AssetsManager and remove all tasks
  60342. * @return the current instance of the AssetsManager
  60343. */
  60344. reset(): AssetsManager;
  60345. /**
  60346. * Start the loading process
  60347. * @return the current instance of the AssetsManager
  60348. */
  60349. load(): AssetsManager;
  60350. /**
  60351. * Start the loading process as an async operation
  60352. * @return a promise returning the list of failed tasks
  60353. */
  60354. loadAsync(): Promise<void>;
  60355. }
  60356. }
  60357. declare module BABYLON {
  60358. /**
  60359. * Wrapper class for promise with external resolve and reject.
  60360. */
  60361. export class Deferred<T> {
  60362. /**
  60363. * The promise associated with this deferred object.
  60364. */
  60365. readonly promise: Promise<T>;
  60366. private _resolve;
  60367. private _reject;
  60368. /**
  60369. * The resolve method of the promise associated with this deferred object.
  60370. */
  60371. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  60372. /**
  60373. * The reject method of the promise associated with this deferred object.
  60374. */
  60375. readonly reject: (reason?: any) => void;
  60376. /**
  60377. * Constructor for this deferred object.
  60378. */
  60379. constructor();
  60380. }
  60381. }
  60382. declare module BABYLON {
  60383. /**
  60384. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  60385. */
  60386. export class MeshExploder {
  60387. private _centerMesh;
  60388. private _meshes;
  60389. private _meshesOrigins;
  60390. private _toCenterVectors;
  60391. private _scaledDirection;
  60392. private _newPosition;
  60393. private _centerPosition;
  60394. /**
  60395. * Explodes meshes from a center mesh.
  60396. * @param meshes The meshes to explode.
  60397. * @param centerMesh The mesh to be center of explosion.
  60398. */
  60399. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  60400. private _setCenterMesh;
  60401. /**
  60402. * Get class name
  60403. * @returns "MeshExploder"
  60404. */
  60405. getClassName(): string;
  60406. /**
  60407. * "Exploded meshes"
  60408. * @returns Array of meshes with the centerMesh at index 0.
  60409. */
  60410. getMeshes(): Array<Mesh>;
  60411. /**
  60412. * Explodes meshes giving a specific direction
  60413. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  60414. */
  60415. explode(direction?: number): void;
  60416. }
  60417. }
  60418. declare module BABYLON {
  60419. /**
  60420. * Class used to help managing file picking and drag'n'drop
  60421. */
  60422. export class FilesInput {
  60423. /**
  60424. * List of files ready to be loaded
  60425. */
  60426. static readonly FilesToLoad: {
  60427. [key: string]: File;
  60428. };
  60429. /**
  60430. * Callback called when a file is processed
  60431. */
  60432. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  60433. private _engine;
  60434. private _currentScene;
  60435. private _sceneLoadedCallback;
  60436. private _progressCallback;
  60437. private _additionalRenderLoopLogicCallback;
  60438. private _textureLoadingCallback;
  60439. private _startingProcessingFilesCallback;
  60440. private _onReloadCallback;
  60441. private _errorCallback;
  60442. private _elementToMonitor;
  60443. private _sceneFileToLoad;
  60444. private _filesToLoad;
  60445. /**
  60446. * Creates a new FilesInput
  60447. * @param engine defines the rendering engine
  60448. * @param scene defines the hosting scene
  60449. * @param sceneLoadedCallback callback called when scene is loaded
  60450. * @param progressCallback callback called to track progress
  60451. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  60452. * @param textureLoadingCallback callback called when a texture is loading
  60453. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  60454. * @param onReloadCallback callback called when a reload is requested
  60455. * @param errorCallback callback call if an error occurs
  60456. */
  60457. 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);
  60458. private _dragEnterHandler;
  60459. private _dragOverHandler;
  60460. private _dropHandler;
  60461. /**
  60462. * Calls this function to listen to drag'n'drop events on a specific DOM element
  60463. * @param elementToMonitor defines the DOM element to track
  60464. */
  60465. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  60466. /**
  60467. * Release all associated resources
  60468. */
  60469. dispose(): void;
  60470. private renderFunction;
  60471. private drag;
  60472. private drop;
  60473. private _traverseFolder;
  60474. private _processFiles;
  60475. /**
  60476. * Load files from a drop event
  60477. * @param event defines the drop event to use as source
  60478. */
  60479. loadFiles(event: any): void;
  60480. private _processReload;
  60481. /**
  60482. * Reload the current scene from the loaded files
  60483. */
  60484. reload(): void;
  60485. }
  60486. }
  60487. declare module BABYLON {
  60488. /**
  60489. * Defines the root class used to create scene optimization to use with SceneOptimizer
  60490. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60491. */
  60492. export class SceneOptimization {
  60493. /**
  60494. * Defines the priority of this optimization (0 by default which means first in the list)
  60495. */
  60496. priority: number;
  60497. /**
  60498. * Gets a string describing the action executed by the current optimization
  60499. * @returns description string
  60500. */
  60501. getDescription(): string;
  60502. /**
  60503. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60504. * @param scene defines the current scene where to apply this optimization
  60505. * @param optimizer defines the current optimizer
  60506. * @returns true if everything that can be done was applied
  60507. */
  60508. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60509. /**
  60510. * Creates the SceneOptimization object
  60511. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60512. * @param desc defines the description associated with the optimization
  60513. */
  60514. constructor(
  60515. /**
  60516. * Defines the priority of this optimization (0 by default which means first in the list)
  60517. */
  60518. priority?: number);
  60519. }
  60520. /**
  60521. * Defines an optimization used to reduce the size of render target textures
  60522. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60523. */
  60524. export class TextureOptimization extends SceneOptimization {
  60525. /**
  60526. * Defines the priority of this optimization (0 by default which means first in the list)
  60527. */
  60528. priority: number;
  60529. /**
  60530. * 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
  60531. */
  60532. maximumSize: number;
  60533. /**
  60534. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  60535. */
  60536. step: number;
  60537. /**
  60538. * Gets a string describing the action executed by the current optimization
  60539. * @returns description string
  60540. */
  60541. getDescription(): string;
  60542. /**
  60543. * Creates the TextureOptimization object
  60544. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60545. * @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
  60546. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  60547. */
  60548. constructor(
  60549. /**
  60550. * Defines the priority of this optimization (0 by default which means first in the list)
  60551. */
  60552. priority?: number,
  60553. /**
  60554. * 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
  60555. */
  60556. maximumSize?: number,
  60557. /**
  60558. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  60559. */
  60560. step?: number);
  60561. /**
  60562. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60563. * @param scene defines the current scene where to apply this optimization
  60564. * @param optimizer defines the current optimizer
  60565. * @returns true if everything that can be done was applied
  60566. */
  60567. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60568. }
  60569. /**
  60570. * Defines an optimization used to increase or decrease the rendering resolution
  60571. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60572. */
  60573. export class HardwareScalingOptimization extends SceneOptimization {
  60574. /**
  60575. * Defines the priority of this optimization (0 by default which means first in the list)
  60576. */
  60577. priority: number;
  60578. /**
  60579. * Defines the maximum scale to use (2 by default)
  60580. */
  60581. maximumScale: number;
  60582. /**
  60583. * Defines the step to use between two passes (0.5 by default)
  60584. */
  60585. step: number;
  60586. private _currentScale;
  60587. private _directionOffset;
  60588. /**
  60589. * Gets a string describing the action executed by the current optimization
  60590. * @return description string
  60591. */
  60592. getDescription(): string;
  60593. /**
  60594. * Creates the HardwareScalingOptimization object
  60595. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60596. * @param maximumScale defines the maximum scale to use (2 by default)
  60597. * @param step defines the step to use between two passes (0.5 by default)
  60598. */
  60599. constructor(
  60600. /**
  60601. * Defines the priority of this optimization (0 by default which means first in the list)
  60602. */
  60603. priority?: number,
  60604. /**
  60605. * Defines the maximum scale to use (2 by default)
  60606. */
  60607. maximumScale?: number,
  60608. /**
  60609. * Defines the step to use between two passes (0.5 by default)
  60610. */
  60611. step?: number);
  60612. /**
  60613. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60614. * @param scene defines the current scene where to apply this optimization
  60615. * @param optimizer defines the current optimizer
  60616. * @returns true if everything that can be done was applied
  60617. */
  60618. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60619. }
  60620. /**
  60621. * Defines an optimization used to remove shadows
  60622. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60623. */
  60624. export class ShadowsOptimization extends SceneOptimization {
  60625. /**
  60626. * Gets a string describing the action executed by the current optimization
  60627. * @return description string
  60628. */
  60629. getDescription(): string;
  60630. /**
  60631. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60632. * @param scene defines the current scene where to apply this optimization
  60633. * @param optimizer defines the current optimizer
  60634. * @returns true if everything that can be done was applied
  60635. */
  60636. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60637. }
  60638. /**
  60639. * Defines an optimization used to turn post-processes off
  60640. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60641. */
  60642. export class PostProcessesOptimization extends SceneOptimization {
  60643. /**
  60644. * Gets a string describing the action executed by the current optimization
  60645. * @return description string
  60646. */
  60647. getDescription(): string;
  60648. /**
  60649. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60650. * @param scene defines the current scene where to apply this optimization
  60651. * @param optimizer defines the current optimizer
  60652. * @returns true if everything that can be done was applied
  60653. */
  60654. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60655. }
  60656. /**
  60657. * Defines an optimization used to turn lens flares off
  60658. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60659. */
  60660. export class LensFlaresOptimization extends SceneOptimization {
  60661. /**
  60662. * Gets a string describing the action executed by the current optimization
  60663. * @return description string
  60664. */
  60665. getDescription(): string;
  60666. /**
  60667. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60668. * @param scene defines the current scene where to apply this optimization
  60669. * @param optimizer defines the current optimizer
  60670. * @returns true if everything that can be done was applied
  60671. */
  60672. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60673. }
  60674. /**
  60675. * Defines an optimization based on user defined callback.
  60676. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60677. */
  60678. export class CustomOptimization extends SceneOptimization {
  60679. /**
  60680. * Callback called to apply the custom optimization.
  60681. */
  60682. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  60683. /**
  60684. * Callback called to get custom description
  60685. */
  60686. onGetDescription: () => string;
  60687. /**
  60688. * Gets a string describing the action executed by the current optimization
  60689. * @returns description string
  60690. */
  60691. getDescription(): string;
  60692. /**
  60693. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60694. * @param scene defines the current scene where to apply this optimization
  60695. * @param optimizer defines the current optimizer
  60696. * @returns true if everything that can be done was applied
  60697. */
  60698. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60699. }
  60700. /**
  60701. * Defines an optimization used to turn particles off
  60702. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60703. */
  60704. export class ParticlesOptimization extends SceneOptimization {
  60705. /**
  60706. * Gets a string describing the action executed by the current optimization
  60707. * @return description string
  60708. */
  60709. getDescription(): string;
  60710. /**
  60711. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60712. * @param scene defines the current scene where to apply this optimization
  60713. * @param optimizer defines the current optimizer
  60714. * @returns true if everything that can be done was applied
  60715. */
  60716. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60717. }
  60718. /**
  60719. * Defines an optimization used to turn render targets off
  60720. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60721. */
  60722. export class RenderTargetsOptimization extends SceneOptimization {
  60723. /**
  60724. * Gets a string describing the action executed by the current optimization
  60725. * @return description string
  60726. */
  60727. getDescription(): string;
  60728. /**
  60729. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60730. * @param scene defines the current scene where to apply this optimization
  60731. * @param optimizer defines the current optimizer
  60732. * @returns true if everything that can be done was applied
  60733. */
  60734. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60735. }
  60736. /**
  60737. * Defines an optimization used to merge meshes with compatible materials
  60738. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60739. */
  60740. export class MergeMeshesOptimization extends SceneOptimization {
  60741. private static _UpdateSelectionTree;
  60742. /**
  60743. * Gets or sets a boolean which defines if optimization octree has to be updated
  60744. */
  60745. /**
  60746. * Gets or sets a boolean which defines if optimization octree has to be updated
  60747. */
  60748. static UpdateSelectionTree: boolean;
  60749. /**
  60750. * Gets a string describing the action executed by the current optimization
  60751. * @return description string
  60752. */
  60753. getDescription(): string;
  60754. private _canBeMerged;
  60755. /**
  60756. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60757. * @param scene defines the current scene where to apply this optimization
  60758. * @param optimizer defines the current optimizer
  60759. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  60760. * @returns true if everything that can be done was applied
  60761. */
  60762. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  60763. }
  60764. /**
  60765. * Defines a list of options used by SceneOptimizer
  60766. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60767. */
  60768. export class SceneOptimizerOptions {
  60769. /**
  60770. * Defines the target frame rate to reach (60 by default)
  60771. */
  60772. targetFrameRate: number;
  60773. /**
  60774. * Defines the interval between two checkes (2000ms by default)
  60775. */
  60776. trackerDuration: number;
  60777. /**
  60778. * Gets the list of optimizations to apply
  60779. */
  60780. optimizations: SceneOptimization[];
  60781. /**
  60782. * Creates a new list of options used by SceneOptimizer
  60783. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  60784. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  60785. */
  60786. constructor(
  60787. /**
  60788. * Defines the target frame rate to reach (60 by default)
  60789. */
  60790. targetFrameRate?: number,
  60791. /**
  60792. * Defines the interval between two checkes (2000ms by default)
  60793. */
  60794. trackerDuration?: number);
  60795. /**
  60796. * Add a new optimization
  60797. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  60798. * @returns the current SceneOptimizerOptions
  60799. */
  60800. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  60801. /**
  60802. * Add a new custom optimization
  60803. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  60804. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  60805. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60806. * @returns the current SceneOptimizerOptions
  60807. */
  60808. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  60809. /**
  60810. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  60811. * @param targetFrameRate defines the target frame rate (60 by default)
  60812. * @returns a SceneOptimizerOptions object
  60813. */
  60814. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  60815. /**
  60816. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  60817. * @param targetFrameRate defines the target frame rate (60 by default)
  60818. * @returns a SceneOptimizerOptions object
  60819. */
  60820. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  60821. /**
  60822. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  60823. * @param targetFrameRate defines the target frame rate (60 by default)
  60824. * @returns a SceneOptimizerOptions object
  60825. */
  60826. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  60827. }
  60828. /**
  60829. * Class used to run optimizations in order to reach a target frame rate
  60830. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60831. */
  60832. export class SceneOptimizer implements IDisposable {
  60833. private _isRunning;
  60834. private _options;
  60835. private _scene;
  60836. private _currentPriorityLevel;
  60837. private _targetFrameRate;
  60838. private _trackerDuration;
  60839. private _currentFrameRate;
  60840. private _sceneDisposeObserver;
  60841. private _improvementMode;
  60842. /**
  60843. * Defines an observable called when the optimizer reaches the target frame rate
  60844. */
  60845. onSuccessObservable: Observable<SceneOptimizer>;
  60846. /**
  60847. * Defines an observable called when the optimizer enables an optimization
  60848. */
  60849. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  60850. /**
  60851. * Defines an observable called when the optimizer is not able to reach the target frame rate
  60852. */
  60853. onFailureObservable: Observable<SceneOptimizer>;
  60854. /**
  60855. * Gets a boolean indicating if the optimizer is in improvement mode
  60856. */
  60857. readonly isInImprovementMode: boolean;
  60858. /**
  60859. * Gets the current priority level (0 at start)
  60860. */
  60861. readonly currentPriorityLevel: number;
  60862. /**
  60863. * Gets the current frame rate checked by the SceneOptimizer
  60864. */
  60865. readonly currentFrameRate: number;
  60866. /**
  60867. * Gets or sets the current target frame rate (60 by default)
  60868. */
  60869. /**
  60870. * Gets or sets the current target frame rate (60 by default)
  60871. */
  60872. targetFrameRate: number;
  60873. /**
  60874. * Gets or sets the current interval between two checks (every 2000ms by default)
  60875. */
  60876. /**
  60877. * Gets or sets the current interval between two checks (every 2000ms by default)
  60878. */
  60879. trackerDuration: number;
  60880. /**
  60881. * Gets the list of active optimizations
  60882. */
  60883. readonly optimizations: SceneOptimization[];
  60884. /**
  60885. * Creates a new SceneOptimizer
  60886. * @param scene defines the scene to work on
  60887. * @param options defines the options to use with the SceneOptimizer
  60888. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  60889. * @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)
  60890. */
  60891. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  60892. /**
  60893. * Stops the current optimizer
  60894. */
  60895. stop(): void;
  60896. /**
  60897. * Reset the optimizer to initial step (current priority level = 0)
  60898. */
  60899. reset(): void;
  60900. /**
  60901. * Start the optimizer. By default it will try to reach a specific framerate
  60902. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  60903. */
  60904. start(): void;
  60905. private _checkCurrentState;
  60906. /**
  60907. * Release all resources
  60908. */
  60909. dispose(): void;
  60910. /**
  60911. * Helper function to create a SceneOptimizer with one single line of code
  60912. * @param scene defines the scene to work on
  60913. * @param options defines the options to use with the SceneOptimizer
  60914. * @param onSuccess defines a callback to call on success
  60915. * @param onFailure defines a callback to call on failure
  60916. * @returns the new SceneOptimizer object
  60917. */
  60918. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  60919. }
  60920. }
  60921. declare module BABYLON {
  60922. /**
  60923. * Class used to serialize a scene into a string
  60924. */
  60925. export class SceneSerializer {
  60926. /**
  60927. * Clear cache used by a previous serialization
  60928. */
  60929. static ClearCache(): void;
  60930. /**
  60931. * Serialize a scene into a JSON compatible object
  60932. * @param scene defines the scene to serialize
  60933. * @returns a JSON compatible object
  60934. */
  60935. static Serialize(scene: Scene): any;
  60936. /**
  60937. * Serialize a mesh into a JSON compatible object
  60938. * @param toSerialize defines the mesh to serialize
  60939. * @param withParents defines if parents must be serialized as well
  60940. * @param withChildren defines if children must be serialized as well
  60941. * @returns a JSON compatible object
  60942. */
  60943. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  60944. }
  60945. }
  60946. declare module BABYLON {
  60947. /**
  60948. * Class used to host texture specific utilities
  60949. */
  60950. export class TextureTools {
  60951. /**
  60952. * Uses the GPU to create a copy texture rescaled at a given size
  60953. * @param texture Texture to copy from
  60954. * @param width defines the desired width
  60955. * @param height defines the desired height
  60956. * @param useBilinearMode defines if bilinear mode has to be used
  60957. * @return the generated texture
  60958. */
  60959. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  60960. }
  60961. }
  60962. declare module BABYLON {
  60963. /**
  60964. * This represents the different options available for the video capture.
  60965. */
  60966. export interface VideoRecorderOptions {
  60967. /** Defines the mime type of the video. */
  60968. mimeType: string;
  60969. /** Defines the FPS the video should be recorded at. */
  60970. fps: number;
  60971. /** Defines the chunk size for the recording data. */
  60972. recordChunckSize: number;
  60973. /** The audio tracks to attach to the recording. */
  60974. audioTracks?: MediaStreamTrack[];
  60975. }
  60976. /**
  60977. * This can help with recording videos from BabylonJS.
  60978. * This is based on the available WebRTC functionalities of the browser.
  60979. *
  60980. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  60981. */
  60982. export class VideoRecorder {
  60983. private static readonly _defaultOptions;
  60984. /**
  60985. * Returns whether or not the VideoRecorder is available in your browser.
  60986. * @param engine Defines the Babylon Engine.
  60987. * @returns true if supported otherwise false.
  60988. */
  60989. static IsSupported(engine: Engine): boolean;
  60990. private readonly _options;
  60991. private _canvas;
  60992. private _mediaRecorder;
  60993. private _recordedChunks;
  60994. private _fileName;
  60995. private _resolve;
  60996. private _reject;
  60997. /**
  60998. * True when a recording is already in progress.
  60999. */
  61000. readonly isRecording: boolean;
  61001. /**
  61002. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  61003. * @param engine Defines the BabylonJS Engine you wish to record.
  61004. * @param options Defines options that can be used to customize the capture.
  61005. */
  61006. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  61007. /**
  61008. * Stops the current recording before the default capture timeout passed in the startRecording function.
  61009. */
  61010. stopRecording(): void;
  61011. /**
  61012. * Starts recording the canvas for a max duration specified in parameters.
  61013. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  61014. * If null no automatic download will start and you can rely on the promise to get the data back.
  61015. * @param maxDuration Defines the maximum recording time in seconds.
  61016. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  61017. * @return A promise callback at the end of the recording with the video data in Blob.
  61018. */
  61019. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  61020. /**
  61021. * Releases internal resources used during the recording.
  61022. */
  61023. dispose(): void;
  61024. private _handleDataAvailable;
  61025. private _handleError;
  61026. private _handleStop;
  61027. }
  61028. }
  61029. declare module BABYLON {
  61030. /**
  61031. * Class containing a set of static utilities functions for screenshots
  61032. */
  61033. export class ScreenshotTools {
  61034. /**
  61035. * Captures a screenshot of the current rendering
  61036. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61037. * @param engine defines the rendering engine
  61038. * @param camera defines the source camera
  61039. * @param size This parameter can be set to a single number or to an object with the
  61040. * following (optional) properties: precision, width, height. If a single number is passed,
  61041. * it will be used for both width and height. If an object is passed, the screenshot size
  61042. * will be derived from the parameters. The precision property is a multiplier allowing
  61043. * rendering at a higher or lower resolution
  61044. * @param successCallback defines the callback receives a single parameter which contains the
  61045. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61046. * src parameter of an <img> to display it
  61047. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61048. * Check your browser for supported MIME types
  61049. */
  61050. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  61051. /**
  61052. * Captures a screenshot of the current rendering
  61053. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61054. * @param engine defines the rendering engine
  61055. * @param camera defines the source camera
  61056. * @param size This parameter can be set to a single number or to an object with the
  61057. * following (optional) properties: precision, width, height. If a single number is passed,
  61058. * it will be used for both width and height. If an object is passed, the screenshot size
  61059. * will be derived from the parameters. The precision property is a multiplier allowing
  61060. * rendering at a higher or lower resolution
  61061. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61062. * Check your browser for supported MIME types
  61063. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  61064. * to the src parameter of an <img> to display it
  61065. */
  61066. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  61067. /**
  61068. * Generates an image screenshot from the specified camera.
  61069. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61070. * @param engine The engine to use for rendering
  61071. * @param camera The camera to use for rendering
  61072. * @param size This parameter can be set to a single number or to an object with the
  61073. * following (optional) properties: precision, width, height. If a single number is passed,
  61074. * it will be used for both width and height. If an object is passed, the screenshot size
  61075. * will be derived from the parameters. The precision property is a multiplier allowing
  61076. * rendering at a higher or lower resolution
  61077. * @param successCallback The callback receives a single parameter which contains the
  61078. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61079. * src parameter of an <img> to display it
  61080. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61081. * Check your browser for supported MIME types
  61082. * @param samples Texture samples (default: 1)
  61083. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61084. * @param fileName A name for for the downloaded file.
  61085. */
  61086. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  61087. /**
  61088. * Generates an image screenshot from the specified camera.
  61089. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61090. * @param engine The engine to use for rendering
  61091. * @param camera The camera to use for rendering
  61092. * @param size This parameter can be set to a single number or to an object with the
  61093. * following (optional) properties: precision, width, height. If a single number is passed,
  61094. * it will be used for both width and height. If an object is passed, the screenshot size
  61095. * will be derived from the parameters. The precision property is a multiplier allowing
  61096. * rendering at a higher or lower resolution
  61097. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61098. * Check your browser for supported MIME types
  61099. * @param samples Texture samples (default: 1)
  61100. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61101. * @param fileName A name for for the downloaded file.
  61102. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  61103. * to the src parameter of an <img> to display it
  61104. */
  61105. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  61106. /**
  61107. * Gets height and width for screenshot size
  61108. * @private
  61109. */
  61110. private static _getScreenshotSize;
  61111. }
  61112. }
  61113. declare module BABYLON {
  61114. /**
  61115. * A cursor which tracks a point on a path
  61116. */
  61117. export class PathCursor {
  61118. private path;
  61119. /**
  61120. * Stores path cursor callbacks for when an onchange event is triggered
  61121. */
  61122. private _onchange;
  61123. /**
  61124. * The value of the path cursor
  61125. */
  61126. value: number;
  61127. /**
  61128. * The animation array of the path cursor
  61129. */
  61130. animations: Animation[];
  61131. /**
  61132. * Initializes the path cursor
  61133. * @param path The path to track
  61134. */
  61135. constructor(path: Path2);
  61136. /**
  61137. * Gets the cursor point on the path
  61138. * @returns A point on the path cursor at the cursor location
  61139. */
  61140. getPoint(): Vector3;
  61141. /**
  61142. * Moves the cursor ahead by the step amount
  61143. * @param step The amount to move the cursor forward
  61144. * @returns This path cursor
  61145. */
  61146. moveAhead(step?: number): PathCursor;
  61147. /**
  61148. * Moves the cursor behind by the step amount
  61149. * @param step The amount to move the cursor back
  61150. * @returns This path cursor
  61151. */
  61152. moveBack(step?: number): PathCursor;
  61153. /**
  61154. * Moves the cursor by the step amount
  61155. * If the step amount is greater than one, an exception is thrown
  61156. * @param step The amount to move the cursor
  61157. * @returns This path cursor
  61158. */
  61159. move(step: number): PathCursor;
  61160. /**
  61161. * Ensures that the value is limited between zero and one
  61162. * @returns This path cursor
  61163. */
  61164. private ensureLimits;
  61165. /**
  61166. * Runs onchange callbacks on change (used by the animation engine)
  61167. * @returns This path cursor
  61168. */
  61169. private raiseOnChange;
  61170. /**
  61171. * Executes a function on change
  61172. * @param f A path cursor onchange callback
  61173. * @returns This path cursor
  61174. */
  61175. onchange(f: (cursor: PathCursor) => void): PathCursor;
  61176. }
  61177. }
  61178. declare module BABYLON {
  61179. /** @hidden */
  61180. export var blurPixelShader: {
  61181. name: string;
  61182. shader: string;
  61183. };
  61184. }
  61185. declare module BABYLON {
  61186. /** @hidden */
  61187. export var pointCloudVertexDeclaration: {
  61188. name: string;
  61189. shader: string;
  61190. };
  61191. }
  61192. // Mixins
  61193. interface Window {
  61194. mozIndexedDB: IDBFactory;
  61195. webkitIndexedDB: IDBFactory;
  61196. msIndexedDB: IDBFactory;
  61197. webkitURL: typeof URL;
  61198. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  61199. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  61200. WebGLRenderingContext: WebGLRenderingContext;
  61201. MSGesture: MSGesture;
  61202. CANNON: any;
  61203. AudioContext: AudioContext;
  61204. webkitAudioContext: AudioContext;
  61205. PointerEvent: any;
  61206. Math: Math;
  61207. Uint8Array: Uint8ArrayConstructor;
  61208. Float32Array: Float32ArrayConstructor;
  61209. mozURL: typeof URL;
  61210. msURL: typeof URL;
  61211. VRFrameData: any; // WebVR, from specs 1.1
  61212. DracoDecoderModule: any;
  61213. setImmediate(handler: (...args: any[]) => void): number;
  61214. }
  61215. interface HTMLCanvasElement {
  61216. requestPointerLock(): void;
  61217. msRequestPointerLock?(): void;
  61218. mozRequestPointerLock?(): void;
  61219. webkitRequestPointerLock?(): void;
  61220. /** Track wether a record is in progress */
  61221. isRecording: boolean;
  61222. /** Capture Stream method defined by some browsers */
  61223. captureStream(fps?: number): MediaStream;
  61224. }
  61225. interface CanvasRenderingContext2D {
  61226. msImageSmoothingEnabled: boolean;
  61227. }
  61228. interface MouseEvent {
  61229. mozMovementX: number;
  61230. mozMovementY: number;
  61231. webkitMovementX: number;
  61232. webkitMovementY: number;
  61233. msMovementX: number;
  61234. msMovementY: number;
  61235. }
  61236. interface Navigator {
  61237. mozGetVRDevices: (any: any) => any;
  61238. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61239. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61240. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61241. webkitGetGamepads(): Gamepad[];
  61242. msGetGamepads(): Gamepad[];
  61243. webkitGamepads(): Gamepad[];
  61244. }
  61245. interface HTMLVideoElement {
  61246. mozSrcObject: any;
  61247. }
  61248. interface Math {
  61249. fround(x: number): number;
  61250. imul(a: number, b: number): number;
  61251. }
  61252. interface WebGLRenderingContext {
  61253. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  61254. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  61255. vertexAttribDivisor(index: number, divisor: number): void;
  61256. createVertexArray(): any;
  61257. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  61258. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  61259. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  61260. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  61261. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  61262. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  61263. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  61264. // Queries
  61265. createQuery(): WebGLQuery;
  61266. deleteQuery(query: WebGLQuery): void;
  61267. beginQuery(target: number, query: WebGLQuery): void;
  61268. endQuery(target: number): void;
  61269. getQueryParameter(query: WebGLQuery, pname: number): any;
  61270. getQuery(target: number, pname: number): any;
  61271. MAX_SAMPLES: number;
  61272. RGBA8: number;
  61273. READ_FRAMEBUFFER: number;
  61274. DRAW_FRAMEBUFFER: number;
  61275. UNIFORM_BUFFER: number;
  61276. HALF_FLOAT_OES: number;
  61277. RGBA16F: number;
  61278. RGBA32F: number;
  61279. R32F: number;
  61280. RG32F: number;
  61281. RGB32F: number;
  61282. R16F: number;
  61283. RG16F: number;
  61284. RGB16F: number;
  61285. RED: number;
  61286. RG: number;
  61287. R8: number;
  61288. RG8: number;
  61289. UNSIGNED_INT_24_8: number;
  61290. DEPTH24_STENCIL8: number;
  61291. /* Multiple Render Targets */
  61292. drawBuffers(buffers: number[]): void;
  61293. readBuffer(src: number): void;
  61294. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  61295. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  61296. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  61297. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  61298. // Occlusion Query
  61299. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  61300. ANY_SAMPLES_PASSED: number;
  61301. QUERY_RESULT_AVAILABLE: number;
  61302. QUERY_RESULT: number;
  61303. }
  61304. interface WebGLProgram {
  61305. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  61306. }
  61307. interface EXT_disjoint_timer_query {
  61308. QUERY_COUNTER_BITS_EXT: number;
  61309. TIME_ELAPSED_EXT: number;
  61310. TIMESTAMP_EXT: number;
  61311. GPU_DISJOINT_EXT: number;
  61312. QUERY_RESULT_EXT: number;
  61313. QUERY_RESULT_AVAILABLE_EXT: number;
  61314. queryCounterEXT(query: WebGLQuery, target: number): void;
  61315. createQueryEXT(): WebGLQuery;
  61316. beginQueryEXT(target: number, query: WebGLQuery): void;
  61317. endQueryEXT(target: number): void;
  61318. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  61319. deleteQueryEXT(query: WebGLQuery): void;
  61320. }
  61321. interface WebGLUniformLocation {
  61322. _currentState: any;
  61323. }
  61324. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  61325. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  61326. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  61327. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  61328. interface WebGLRenderingContext {
  61329. readonly RASTERIZER_DISCARD: number;
  61330. readonly DEPTH_COMPONENT24: number;
  61331. readonly TEXTURE_3D: number;
  61332. readonly TEXTURE_2D_ARRAY: number;
  61333. readonly TEXTURE_COMPARE_FUNC: number;
  61334. readonly TEXTURE_COMPARE_MODE: number;
  61335. readonly COMPARE_REF_TO_TEXTURE: number;
  61336. readonly TEXTURE_WRAP_R: number;
  61337. readonly HALF_FLOAT: number;
  61338. readonly RGB8: number;
  61339. readonly RED_INTEGER: number;
  61340. readonly RG_INTEGER: number;
  61341. readonly RGB_INTEGER: number;
  61342. readonly RGBA_INTEGER: number;
  61343. readonly R8_SNORM: number;
  61344. readonly RG8_SNORM: number;
  61345. readonly RGB8_SNORM: number;
  61346. readonly RGBA8_SNORM: number;
  61347. readonly R8I: number;
  61348. readonly RG8I: number;
  61349. readonly RGB8I: number;
  61350. readonly RGBA8I: number;
  61351. readonly R8UI: number;
  61352. readonly RG8UI: number;
  61353. readonly RGB8UI: number;
  61354. readonly RGBA8UI: number;
  61355. readonly R16I: number;
  61356. readonly RG16I: number;
  61357. readonly RGB16I: number;
  61358. readonly RGBA16I: number;
  61359. readonly R16UI: number;
  61360. readonly RG16UI: number;
  61361. readonly RGB16UI: number;
  61362. readonly RGBA16UI: number;
  61363. readonly R32I: number;
  61364. readonly RG32I: number;
  61365. readonly RGB32I: number;
  61366. readonly RGBA32I: number;
  61367. readonly R32UI: number;
  61368. readonly RG32UI: number;
  61369. readonly RGB32UI: number;
  61370. readonly RGBA32UI: number;
  61371. readonly RGB10_A2UI: number;
  61372. readonly R11F_G11F_B10F: number;
  61373. readonly RGB9_E5: number;
  61374. readonly RGB10_A2: number;
  61375. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  61376. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  61377. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  61378. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  61379. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  61380. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  61381. 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;
  61382. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  61383. readonly TRANSFORM_FEEDBACK: number;
  61384. readonly INTERLEAVED_ATTRIBS: number;
  61385. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  61386. createTransformFeedback(): WebGLTransformFeedback;
  61387. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  61388. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  61389. beginTransformFeedback(primitiveMode: number): void;
  61390. endTransformFeedback(): void;
  61391. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  61392. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61393. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61394. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61395. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  61396. }
  61397. interface ImageBitmap {
  61398. readonly width: number;
  61399. readonly height: number;
  61400. close(): void;
  61401. }
  61402. interface WebGLQuery extends WebGLObject {
  61403. }
  61404. declare var WebGLQuery: {
  61405. prototype: WebGLQuery;
  61406. new(): WebGLQuery;
  61407. };
  61408. interface WebGLSampler extends WebGLObject {
  61409. }
  61410. declare var WebGLSampler: {
  61411. prototype: WebGLSampler;
  61412. new(): WebGLSampler;
  61413. };
  61414. interface WebGLSync extends WebGLObject {
  61415. }
  61416. declare var WebGLSync: {
  61417. prototype: WebGLSync;
  61418. new(): WebGLSync;
  61419. };
  61420. interface WebGLTransformFeedback extends WebGLObject {
  61421. }
  61422. declare var WebGLTransformFeedback: {
  61423. prototype: WebGLTransformFeedback;
  61424. new(): WebGLTransformFeedback;
  61425. };
  61426. interface WebGLVertexArrayObject extends WebGLObject {
  61427. }
  61428. declare var WebGLVertexArrayObject: {
  61429. prototype: WebGLVertexArrayObject;
  61430. new(): WebGLVertexArrayObject;
  61431. };
  61432. // Type definitions for WebVR API
  61433. // Project: https://w3c.github.io/webvr/
  61434. // Definitions by: six a <https://github.com/lostfictions>
  61435. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  61436. interface VRDisplay extends EventTarget {
  61437. /**
  61438. * Dictionary of capabilities describing the VRDisplay.
  61439. */
  61440. readonly capabilities: VRDisplayCapabilities;
  61441. /**
  61442. * z-depth defining the far plane of the eye view frustum
  61443. * enables mapping of values in the render target depth
  61444. * attachment to scene coordinates. Initially set to 10000.0.
  61445. */
  61446. depthFar: number;
  61447. /**
  61448. * z-depth defining the near plane of the eye view frustum
  61449. * enables mapping of values in the render target depth
  61450. * attachment to scene coordinates. Initially set to 0.01.
  61451. */
  61452. depthNear: number;
  61453. /**
  61454. * An identifier for this distinct VRDisplay. Used as an
  61455. * association point in the Gamepad API.
  61456. */
  61457. readonly displayId: number;
  61458. /**
  61459. * A display name, a user-readable name identifying it.
  61460. */
  61461. readonly displayName: string;
  61462. readonly isConnected: boolean;
  61463. readonly isPresenting: boolean;
  61464. /**
  61465. * If this VRDisplay supports room-scale experiences, the optional
  61466. * stage attribute contains details on the room-scale parameters.
  61467. */
  61468. readonly stageParameters: VRStageParameters | null;
  61469. /**
  61470. * Passing the value returned by `requestAnimationFrame` to
  61471. * `cancelAnimationFrame` will unregister the callback.
  61472. * @param handle Define the hanle of the request to cancel
  61473. */
  61474. cancelAnimationFrame(handle: number): void;
  61475. /**
  61476. * Stops presenting to the VRDisplay.
  61477. * @returns a promise to know when it stopped
  61478. */
  61479. exitPresent(): Promise<void>;
  61480. /**
  61481. * Return the current VREyeParameters for the given eye.
  61482. * @param whichEye Define the eye we want the parameter for
  61483. * @returns the eye parameters
  61484. */
  61485. getEyeParameters(whichEye: string): VREyeParameters;
  61486. /**
  61487. * Populates the passed VRFrameData with the information required to render
  61488. * the current frame.
  61489. * @param frameData Define the data structure to populate
  61490. * @returns true if ok otherwise false
  61491. */
  61492. getFrameData(frameData: VRFrameData): boolean;
  61493. /**
  61494. * Get the layers currently being presented.
  61495. * @returns the list of VR layers
  61496. */
  61497. getLayers(): VRLayer[];
  61498. /**
  61499. * Return a VRPose containing the future predicted pose of the VRDisplay
  61500. * when the current frame will be presented. The value returned will not
  61501. * change until JavaScript has returned control to the browser.
  61502. *
  61503. * The VRPose will contain the position, orientation, velocity,
  61504. * and acceleration of each of these properties.
  61505. * @returns the pose object
  61506. */
  61507. getPose(): VRPose;
  61508. /**
  61509. * Return the current instantaneous pose of the VRDisplay, with no
  61510. * prediction applied.
  61511. * @returns the current instantaneous pose
  61512. */
  61513. getImmediatePose(): VRPose;
  61514. /**
  61515. * The callback passed to `requestAnimationFrame` will be called
  61516. * any time a new frame should be rendered. When the VRDisplay is
  61517. * presenting the callback will be called at the native refresh
  61518. * rate of the HMD. When not presenting this function acts
  61519. * identically to how window.requestAnimationFrame acts. Content should
  61520. * make no assumptions of frame rate or vsync behavior as the HMD runs
  61521. * asynchronously from other displays and at differing refresh rates.
  61522. * @param callback Define the eaction to run next frame
  61523. * @returns the request handle it
  61524. */
  61525. requestAnimationFrame(callback: FrameRequestCallback): number;
  61526. /**
  61527. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  61528. * Repeat calls while already presenting will update the VRLayers being displayed.
  61529. * @param layers Define the list of layer to present
  61530. * @returns a promise to know when the request has been fulfilled
  61531. */
  61532. requestPresent(layers: VRLayer[]): Promise<void>;
  61533. /**
  61534. * Reset the pose for this display, treating its current position and
  61535. * orientation as the "origin/zero" values. VRPose.position,
  61536. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  61537. * updated when calling resetPose(). This should be called in only
  61538. * sitting-space experiences.
  61539. */
  61540. resetPose(): void;
  61541. /**
  61542. * The VRLayer provided to the VRDisplay will be captured and presented
  61543. * in the HMD. Calling this function has the same effect on the source
  61544. * canvas as any other operation that uses its source image, and canvases
  61545. * created without preserveDrawingBuffer set to true will be cleared.
  61546. * @param pose Define the pose to submit
  61547. */
  61548. submitFrame(pose?: VRPose): void;
  61549. }
  61550. declare var VRDisplay: {
  61551. prototype: VRDisplay;
  61552. new(): VRDisplay;
  61553. };
  61554. interface VRLayer {
  61555. leftBounds?: number[] | Float32Array | null;
  61556. rightBounds?: number[] | Float32Array | null;
  61557. source?: HTMLCanvasElement | null;
  61558. }
  61559. interface VRDisplayCapabilities {
  61560. readonly canPresent: boolean;
  61561. readonly hasExternalDisplay: boolean;
  61562. readonly hasOrientation: boolean;
  61563. readonly hasPosition: boolean;
  61564. readonly maxLayers: number;
  61565. }
  61566. interface VREyeParameters {
  61567. /** @deprecated */
  61568. readonly fieldOfView: VRFieldOfView;
  61569. readonly offset: Float32Array;
  61570. readonly renderHeight: number;
  61571. readonly renderWidth: number;
  61572. }
  61573. interface VRFieldOfView {
  61574. readonly downDegrees: number;
  61575. readonly leftDegrees: number;
  61576. readonly rightDegrees: number;
  61577. readonly upDegrees: number;
  61578. }
  61579. interface VRFrameData {
  61580. readonly leftProjectionMatrix: Float32Array;
  61581. readonly leftViewMatrix: Float32Array;
  61582. readonly pose: VRPose;
  61583. readonly rightProjectionMatrix: Float32Array;
  61584. readonly rightViewMatrix: Float32Array;
  61585. readonly timestamp: number;
  61586. }
  61587. interface VRPose {
  61588. readonly angularAcceleration: Float32Array | null;
  61589. readonly angularVelocity: Float32Array | null;
  61590. readonly linearAcceleration: Float32Array | null;
  61591. readonly linearVelocity: Float32Array | null;
  61592. readonly orientation: Float32Array | null;
  61593. readonly position: Float32Array | null;
  61594. readonly timestamp: number;
  61595. }
  61596. interface VRStageParameters {
  61597. sittingToStandingTransform?: Float32Array;
  61598. sizeX?: number;
  61599. sizeY?: number;
  61600. }
  61601. interface Navigator {
  61602. getVRDisplays(): Promise<VRDisplay[]>;
  61603. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  61604. }
  61605. interface Window {
  61606. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  61607. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  61608. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  61609. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  61610. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  61611. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  61612. }
  61613. interface Gamepad {
  61614. readonly displayId: number;
  61615. }
  61616. type XRSessionMode =
  61617. | "inline"
  61618. | "immersive-vr"
  61619. | "immersive-ar";
  61620. type XRReferenceSpaceType =
  61621. | "viewer"
  61622. | "local"
  61623. | "local-floor"
  61624. | "bounded-floor"
  61625. | "unbounded";
  61626. type XREnvironmentBlendMode =
  61627. | "opaque"
  61628. | "additive"
  61629. | "alpha-blend";
  61630. type XRVisibilityState =
  61631. | "visible"
  61632. | "visible-blurred"
  61633. | "hidden";
  61634. type XRHandedness =
  61635. | "none"
  61636. | "left"
  61637. | "right";
  61638. type XRTargetRayMode =
  61639. | "gaze"
  61640. | "tracked-pointer"
  61641. | "screen";
  61642. type XREye =
  61643. | "none"
  61644. | "left"
  61645. | "right";
  61646. interface XRSpace extends EventTarget {
  61647. }
  61648. interface XRRenderState {
  61649. depthNear?: number;
  61650. depthFar?: number;
  61651. inlineVerticalFieldOfView?: number;
  61652. baseLayer?: XRWebGLLayer;
  61653. }
  61654. interface XRInputSource {
  61655. handedness: XRHandedness;
  61656. targetRayMode: XRTargetRayMode;
  61657. targetRaySpace: XRSpace;
  61658. gripSpace: XRSpace | undefined;
  61659. gamepad: Gamepad | undefined;
  61660. profiles: Array<string>;
  61661. }
  61662. interface XRSession {
  61663. addEventListener: Function;
  61664. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  61665. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  61666. requestAnimationFrame: Function;
  61667. end(): Promise<void>;
  61668. renderState: XRRenderState;
  61669. inputSources: Array<XRInputSource>;
  61670. }
  61671. interface XRReferenceSpace extends XRSpace {
  61672. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  61673. onreset: any;
  61674. }
  61675. interface XRFrame {
  61676. session: XRSession;
  61677. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  61678. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  61679. }
  61680. interface XRViewerPose extends XRPose {
  61681. views: Array<XRView>;
  61682. }
  61683. interface XRPose {
  61684. transform: XRRigidTransform;
  61685. emulatedPosition: boolean;
  61686. }
  61687. declare var XRWebGLLayer: {
  61688. prototype: XRWebGLLayer;
  61689. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  61690. };
  61691. interface XRWebGLLayer {
  61692. framebuffer: WebGLFramebuffer;
  61693. framebufferWidth: number;
  61694. framebufferHeight: number;
  61695. getViewport: Function;
  61696. }
  61697. interface XRRigidTransform {
  61698. position: DOMPointReadOnly;
  61699. orientation: DOMPointReadOnly;
  61700. matrix: Float32Array;
  61701. inverse: XRRigidTransform;
  61702. }
  61703. interface XRView {
  61704. eye: XREye;
  61705. projectionMatrix: Float32Array;
  61706. transform: XRRigidTransform;
  61707. }
  61708. interface XRInputSourceChangeEvent {
  61709. session: XRSession;
  61710. removed: Array<XRInputSource>;
  61711. added: Array<XRInputSource>;
  61712. }
  61713. declare module BABYLON.GUI {
  61714. /**
  61715. * Class used to specific a value and its associated unit
  61716. */
  61717. export class ValueAndUnit {
  61718. /** defines the unit to store */
  61719. unit: number;
  61720. /** defines a boolean indicating if the value can be negative */
  61721. negativeValueAllowed: boolean;
  61722. private _value;
  61723. private _originalUnit;
  61724. /**
  61725. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  61726. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61727. */
  61728. ignoreAdaptiveScaling: boolean;
  61729. /**
  61730. * Creates a new ValueAndUnit
  61731. * @param value defines the value to store
  61732. * @param unit defines the unit to store
  61733. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  61734. */
  61735. constructor(value: number,
  61736. /** defines the unit to store */
  61737. unit?: number,
  61738. /** defines a boolean indicating if the value can be negative */
  61739. negativeValueAllowed?: boolean);
  61740. /** Gets a boolean indicating if the value is a percentage */
  61741. readonly isPercentage: boolean;
  61742. /** Gets a boolean indicating if the value is store as pixel */
  61743. readonly isPixel: boolean;
  61744. /** Gets direct internal value */
  61745. readonly internalValue: number;
  61746. /**
  61747. * Gets value as pixel
  61748. * @param host defines the root host
  61749. * @param refValue defines the reference value for percentages
  61750. * @returns the value as pixel
  61751. */
  61752. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  61753. /**
  61754. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  61755. * @param value defines the value to store
  61756. * @param unit defines the unit to store
  61757. * @returns the current ValueAndUnit
  61758. */
  61759. updateInPlace(value: number, unit?: number): ValueAndUnit;
  61760. /**
  61761. * Gets the value accordingly to its unit
  61762. * @param host defines the root host
  61763. * @returns the value
  61764. */
  61765. getValue(host: AdvancedDynamicTexture): number;
  61766. /**
  61767. * Gets a string representation of the value
  61768. * @param host defines the root host
  61769. * @param decimals defines an optional number of decimals to display
  61770. * @returns a string
  61771. */
  61772. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  61773. /**
  61774. * Store a value parsed from a string
  61775. * @param source defines the source string
  61776. * @returns true if the value was successfully parsed
  61777. */
  61778. fromString(source: string | number): boolean;
  61779. private static _Regex;
  61780. private static _UNITMODE_PERCENTAGE;
  61781. private static _UNITMODE_PIXEL;
  61782. /** UNITMODE_PERCENTAGE */
  61783. static readonly UNITMODE_PERCENTAGE: number;
  61784. /** UNITMODE_PIXEL */
  61785. static readonly UNITMODE_PIXEL: number;
  61786. }
  61787. }
  61788. declare module BABYLON.GUI {
  61789. /**
  61790. * Define a style used by control to automatically setup properties based on a template.
  61791. * Only support font related properties so far
  61792. */
  61793. export class Style implements BABYLON.IDisposable {
  61794. private _fontFamily;
  61795. private _fontStyle;
  61796. private _fontWeight;
  61797. /** @hidden */
  61798. _host: AdvancedDynamicTexture;
  61799. /** @hidden */
  61800. _fontSize: ValueAndUnit;
  61801. /**
  61802. * BABYLON.Observable raised when the style values are changed
  61803. */
  61804. onChangedObservable: BABYLON.Observable<Style>;
  61805. /**
  61806. * Creates a new style object
  61807. * @param host defines the AdvancedDynamicTexture which hosts this style
  61808. */
  61809. constructor(host: AdvancedDynamicTexture);
  61810. /**
  61811. * Gets or sets the font size
  61812. */
  61813. fontSize: string | number;
  61814. /**
  61815. * Gets or sets the font family
  61816. */
  61817. fontFamily: string;
  61818. /**
  61819. * Gets or sets the font style
  61820. */
  61821. fontStyle: string;
  61822. /** Gets or sets font weight */
  61823. fontWeight: string;
  61824. /** Dispose all associated resources */
  61825. dispose(): void;
  61826. }
  61827. }
  61828. declare module BABYLON.GUI {
  61829. /**
  61830. * Class used to transport BABYLON.Vector2 information for pointer events
  61831. */
  61832. export class Vector2WithInfo extends BABYLON.Vector2 {
  61833. /** defines the current mouse button index */
  61834. buttonIndex: number;
  61835. /**
  61836. * Creates a new Vector2WithInfo
  61837. * @param source defines the vector2 data to transport
  61838. * @param buttonIndex defines the current mouse button index
  61839. */
  61840. constructor(source: BABYLON.Vector2,
  61841. /** defines the current mouse button index */
  61842. buttonIndex?: number);
  61843. }
  61844. /** Class used to provide 2D matrix features */
  61845. export class Matrix2D {
  61846. /** Gets the internal array of 6 floats used to store matrix data */
  61847. m: Float32Array;
  61848. /**
  61849. * Creates a new matrix
  61850. * @param m00 defines value for (0, 0)
  61851. * @param m01 defines value for (0, 1)
  61852. * @param m10 defines value for (1, 0)
  61853. * @param m11 defines value for (1, 1)
  61854. * @param m20 defines value for (2, 0)
  61855. * @param m21 defines value for (2, 1)
  61856. */
  61857. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  61858. /**
  61859. * Fills the matrix from direct values
  61860. * @param m00 defines value for (0, 0)
  61861. * @param m01 defines value for (0, 1)
  61862. * @param m10 defines value for (1, 0)
  61863. * @param m11 defines value for (1, 1)
  61864. * @param m20 defines value for (2, 0)
  61865. * @param m21 defines value for (2, 1)
  61866. * @returns the current modified matrix
  61867. */
  61868. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  61869. /**
  61870. * Gets matrix determinant
  61871. * @returns the determinant
  61872. */
  61873. determinant(): number;
  61874. /**
  61875. * Inverses the matrix and stores it in a target matrix
  61876. * @param result defines the target matrix
  61877. * @returns the current matrix
  61878. */
  61879. invertToRef(result: Matrix2D): Matrix2D;
  61880. /**
  61881. * Multiplies the current matrix with another one
  61882. * @param other defines the second operand
  61883. * @param result defines the target matrix
  61884. * @returns the current matrix
  61885. */
  61886. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  61887. /**
  61888. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  61889. * @param x defines the x coordinate to transform
  61890. * @param y defines the x coordinate to transform
  61891. * @param result defines the target vector2
  61892. * @returns the current matrix
  61893. */
  61894. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  61895. /**
  61896. * Creates an identity matrix
  61897. * @returns a new matrix
  61898. */
  61899. static Identity(): Matrix2D;
  61900. /**
  61901. * Creates a translation matrix and stores it in a target matrix
  61902. * @param x defines the x coordinate of the translation
  61903. * @param y defines the y coordinate of the translation
  61904. * @param result defines the target matrix
  61905. */
  61906. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  61907. /**
  61908. * Creates a scaling matrix and stores it in a target matrix
  61909. * @param x defines the x coordinate of the scaling
  61910. * @param y defines the y coordinate of the scaling
  61911. * @param result defines the target matrix
  61912. */
  61913. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  61914. /**
  61915. * Creates a rotation matrix and stores it in a target matrix
  61916. * @param angle defines the rotation angle
  61917. * @param result defines the target matrix
  61918. */
  61919. static RotationToRef(angle: number, result: Matrix2D): void;
  61920. private static _TempPreTranslationMatrix;
  61921. private static _TempPostTranslationMatrix;
  61922. private static _TempRotationMatrix;
  61923. private static _TempScalingMatrix;
  61924. private static _TempCompose0;
  61925. private static _TempCompose1;
  61926. private static _TempCompose2;
  61927. /**
  61928. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  61929. * @param tx defines the x coordinate of the translation
  61930. * @param ty defines the y coordinate of the translation
  61931. * @param angle defines the rotation angle
  61932. * @param scaleX defines the x coordinate of the scaling
  61933. * @param scaleY defines the y coordinate of the scaling
  61934. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  61935. * @param result defines the target matrix
  61936. */
  61937. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  61938. }
  61939. }
  61940. declare module BABYLON.GUI {
  61941. /**
  61942. * Class used to store 2D control sizes
  61943. */
  61944. export class Measure {
  61945. /** defines left coordinate */
  61946. left: number;
  61947. /** defines top coordinate */
  61948. top: number;
  61949. /** defines width dimension */
  61950. width: number;
  61951. /** defines height dimension */
  61952. height: number;
  61953. /**
  61954. * Creates a new measure
  61955. * @param left defines left coordinate
  61956. * @param top defines top coordinate
  61957. * @param width defines width dimension
  61958. * @param height defines height dimension
  61959. */
  61960. constructor(
  61961. /** defines left coordinate */
  61962. left: number,
  61963. /** defines top coordinate */
  61964. top: number,
  61965. /** defines width dimension */
  61966. width: number,
  61967. /** defines height dimension */
  61968. height: number);
  61969. /**
  61970. * Copy from another measure
  61971. * @param other defines the other measure to copy from
  61972. */
  61973. copyFrom(other: Measure): void;
  61974. /**
  61975. * Copy from a group of 4 floats
  61976. * @param left defines left coordinate
  61977. * @param top defines top coordinate
  61978. * @param width defines width dimension
  61979. * @param height defines height dimension
  61980. */
  61981. copyFromFloats(left: number, top: number, width: number, height: number): void;
  61982. /**
  61983. * Computes the axis aligned bounding box measure for two given measures
  61984. * @param a Input measure
  61985. * @param b Input measure
  61986. * @param result the resulting bounding measure
  61987. */
  61988. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  61989. /**
  61990. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  61991. * @param transform the matrix to transform the measure before computing the AABB
  61992. * @param result the resulting AABB
  61993. */
  61994. transformToRef(transform: Matrix2D, result: Measure): void;
  61995. /**
  61996. * Check equality between this measure and another one
  61997. * @param other defines the other measures
  61998. * @returns true if both measures are equals
  61999. */
  62000. isEqualsTo(other: Measure): boolean;
  62001. /**
  62002. * Creates an empty measure
  62003. * @returns a new measure
  62004. */
  62005. static Empty(): Measure;
  62006. }
  62007. }
  62008. declare module BABYLON.GUI {
  62009. /**
  62010. * Interface used to define a control that can receive focus
  62011. */
  62012. export interface IFocusableControl {
  62013. /**
  62014. * Function called when the control receives the focus
  62015. */
  62016. onFocus(): void;
  62017. /**
  62018. * Function called when the control loses the focus
  62019. */
  62020. onBlur(): void;
  62021. /**
  62022. * Function called to let the control handle keyboard events
  62023. * @param evt defines the current keyboard event
  62024. */
  62025. processKeyboard(evt: KeyboardEvent): void;
  62026. /**
  62027. * Function called to get the list of controls that should not steal the focus from this control
  62028. * @returns an array of controls
  62029. */
  62030. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  62031. }
  62032. /**
  62033. * Class used to create texture to support 2D GUI elements
  62034. * @see http://doc.babylonjs.com/how_to/gui
  62035. */
  62036. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  62037. private _isDirty;
  62038. private _renderObserver;
  62039. private _resizeObserver;
  62040. private _preKeyboardObserver;
  62041. private _pointerMoveObserver;
  62042. private _pointerObserver;
  62043. private _canvasPointerOutObserver;
  62044. private _background;
  62045. /** @hidden */
  62046. _rootContainer: Container;
  62047. /** @hidden */
  62048. _lastPickedControl: Control;
  62049. /** @hidden */
  62050. _lastControlOver: {
  62051. [pointerId: number]: Control;
  62052. };
  62053. /** @hidden */
  62054. _lastControlDown: {
  62055. [pointerId: number]: Control;
  62056. };
  62057. /** @hidden */
  62058. _capturingControl: {
  62059. [pointerId: number]: Control;
  62060. };
  62061. /** @hidden */
  62062. _shouldBlockPointer: boolean;
  62063. /** @hidden */
  62064. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  62065. /** @hidden */
  62066. _linkedControls: Control[];
  62067. private _isFullscreen;
  62068. private _fullscreenViewport;
  62069. private _idealWidth;
  62070. private _idealHeight;
  62071. private _useSmallestIdeal;
  62072. private _renderAtIdealSize;
  62073. private _focusedControl;
  62074. private _blockNextFocusCheck;
  62075. private _renderScale;
  62076. private _rootCanvas;
  62077. private _cursorChanged;
  62078. /**
  62079. * Define type to string to ensure compatibility across browsers
  62080. * Safari doesn't support DataTransfer constructor
  62081. */
  62082. private _clipboardData;
  62083. /**
  62084. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  62085. */
  62086. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  62087. /**
  62088. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  62089. */
  62090. onControlPickedObservable: BABYLON.Observable<Control>;
  62091. /**
  62092. * BABYLON.Observable event triggered before layout is evaluated
  62093. */
  62094. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62095. /**
  62096. * BABYLON.Observable event triggered after the layout was evaluated
  62097. */
  62098. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62099. /**
  62100. * BABYLON.Observable event triggered before the texture is rendered
  62101. */
  62102. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62103. /**
  62104. * BABYLON.Observable event triggered after the texture was rendered
  62105. */
  62106. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62107. /**
  62108. * Gets or sets a boolean defining if alpha is stored as premultiplied
  62109. */
  62110. premulAlpha: boolean;
  62111. /**
  62112. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  62113. * Useful when you want more antialiasing
  62114. */
  62115. renderScale: number;
  62116. /** Gets or sets the background color */
  62117. background: string;
  62118. /**
  62119. * Gets or sets the ideal width used to design controls.
  62120. * The GUI will then rescale everything accordingly
  62121. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62122. */
  62123. idealWidth: number;
  62124. /**
  62125. * Gets or sets the ideal height used to design controls.
  62126. * The GUI will then rescale everything accordingly
  62127. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62128. */
  62129. idealHeight: number;
  62130. /**
  62131. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  62132. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62133. */
  62134. useSmallestIdeal: boolean;
  62135. /**
  62136. * Gets or sets a boolean indicating if adaptive scaling must be used
  62137. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62138. */
  62139. renderAtIdealSize: boolean;
  62140. /**
  62141. * Gets the underlying layer used to render the texture when in fullscreen mode
  62142. */
  62143. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  62144. /**
  62145. * Gets the root container control
  62146. */
  62147. readonly rootContainer: Container;
  62148. /**
  62149. * Returns an array containing the root container.
  62150. * This is mostly used to let the Inspector introspects the ADT
  62151. * @returns an array containing the rootContainer
  62152. */
  62153. getChildren(): Array<Container>;
  62154. /**
  62155. * Will return all controls that are inside this texture
  62156. * @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
  62157. * @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
  62158. * @return all child controls
  62159. */
  62160. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  62161. /**
  62162. * Gets or sets the current focused control
  62163. */
  62164. focusedControl: BABYLON.Nullable<IFocusableControl>;
  62165. /**
  62166. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  62167. */
  62168. isForeground: boolean;
  62169. /**
  62170. * Gets or set information about clipboardData
  62171. */
  62172. clipboardData: string;
  62173. /**
  62174. * Creates a new AdvancedDynamicTexture
  62175. * @param name defines the name of the texture
  62176. * @param width defines the width of the texture
  62177. * @param height defines the height of the texture
  62178. * @param scene defines the hosting scene
  62179. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  62180. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  62181. */
  62182. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  62183. /**
  62184. * Get the current class name of the texture useful for serialization or dynamic coding.
  62185. * @returns "AdvancedDynamicTexture"
  62186. */
  62187. getClassName(): string;
  62188. /**
  62189. * Function used to execute a function on all controls
  62190. * @param func defines the function to execute
  62191. * @param container defines the container where controls belong. If null the root container will be used
  62192. */
  62193. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  62194. private _useInvalidateRectOptimization;
  62195. /**
  62196. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  62197. */
  62198. useInvalidateRectOptimization: boolean;
  62199. private _invalidatedRectangle;
  62200. /**
  62201. * Invalidates a rectangle area on the gui texture
  62202. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  62203. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  62204. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  62205. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  62206. */
  62207. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  62208. /**
  62209. * Marks the texture as dirty forcing a complete update
  62210. */
  62211. markAsDirty(): void;
  62212. /**
  62213. * Helper function used to create a new style
  62214. * @returns a new style
  62215. * @see http://doc.babylonjs.com/how_to/gui#styles
  62216. */
  62217. createStyle(): Style;
  62218. /**
  62219. * Adds a new control to the root container
  62220. * @param control defines the control to add
  62221. * @returns the current texture
  62222. */
  62223. addControl(control: Control): AdvancedDynamicTexture;
  62224. /**
  62225. * Removes a control from the root container
  62226. * @param control defines the control to remove
  62227. * @returns the current texture
  62228. */
  62229. removeControl(control: Control): AdvancedDynamicTexture;
  62230. /**
  62231. * Release all resources
  62232. */
  62233. dispose(): void;
  62234. private _onResize;
  62235. /** @hidden */
  62236. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  62237. /**
  62238. * Get screen coordinates for a vector3
  62239. * @param position defines the position to project
  62240. * @param worldMatrix defines the world matrix to use
  62241. * @returns the projected position
  62242. */
  62243. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  62244. private _checkUpdate;
  62245. private _clearMeasure;
  62246. private _render;
  62247. /** @hidden */
  62248. _changeCursor(cursor: string): void;
  62249. /** @hidden */
  62250. _registerLastControlDown(control: Control, pointerId: number): void;
  62251. private _doPicking;
  62252. /** @hidden */
  62253. _cleanControlAfterRemovalFromList(list: {
  62254. [pointerId: number]: Control;
  62255. }, control: Control): void;
  62256. /** @hidden */
  62257. _cleanControlAfterRemoval(control: Control): void;
  62258. /** Attach to all scene events required to support pointer events */
  62259. attach(): void;
  62260. /** @hidden */
  62261. private onClipboardCopy;
  62262. /** @hidden */
  62263. private onClipboardCut;
  62264. /** @hidden */
  62265. private onClipboardPaste;
  62266. /**
  62267. * Register the clipboard Events onto the canvas
  62268. */
  62269. registerClipboardEvents(): void;
  62270. /**
  62271. * Unregister the clipboard Events from the canvas
  62272. */
  62273. unRegisterClipboardEvents(): void;
  62274. /**
  62275. * Connect the texture to a hosting mesh to enable interactions
  62276. * @param mesh defines the mesh to attach to
  62277. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  62278. */
  62279. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  62280. /**
  62281. * Move the focus to a specific control
  62282. * @param control defines the control which will receive the focus
  62283. */
  62284. moveFocusToControl(control: IFocusableControl): void;
  62285. private _manageFocus;
  62286. private _attachToOnPointerOut;
  62287. /**
  62288. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  62289. * @param mesh defines the mesh which will receive the texture
  62290. * @param width defines the texture width (1024 by default)
  62291. * @param height defines the texture height (1024 by default)
  62292. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  62293. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  62294. * @returns a new AdvancedDynamicTexture
  62295. */
  62296. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  62297. /**
  62298. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  62299. * In this mode the texture will rely on a layer for its rendering.
  62300. * This allows it to be treated like any other layer.
  62301. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  62302. * LayerMask is set through advancedTexture.layer.layerMask
  62303. * @param name defines name for the texture
  62304. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  62305. * @param scene defines the hsoting scene
  62306. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  62307. * @returns a new AdvancedDynamicTexture
  62308. */
  62309. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  62310. }
  62311. }
  62312. declare module BABYLON.GUI {
  62313. /**
  62314. * Root class used for all 2D controls
  62315. * @see http://doc.babylonjs.com/how_to/gui#controls
  62316. */
  62317. export class Control {
  62318. /** defines the name of the control */
  62319. name?: string | undefined;
  62320. /**
  62321. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  62322. */
  62323. static AllowAlphaInheritance: boolean;
  62324. private _alpha;
  62325. private _alphaSet;
  62326. private _zIndex;
  62327. /** @hidden */
  62328. _host: AdvancedDynamicTexture;
  62329. /** Gets or sets the control parent */
  62330. parent: BABYLON.Nullable<Container>;
  62331. /** @hidden */
  62332. _currentMeasure: Measure;
  62333. private _fontFamily;
  62334. private _fontStyle;
  62335. private _fontWeight;
  62336. private _fontSize;
  62337. private _font;
  62338. /** @hidden */
  62339. _width: ValueAndUnit;
  62340. /** @hidden */
  62341. _height: ValueAndUnit;
  62342. /** @hidden */
  62343. protected _fontOffset: {
  62344. ascent: number;
  62345. height: number;
  62346. descent: number;
  62347. };
  62348. private _color;
  62349. private _style;
  62350. private _styleObserver;
  62351. /** @hidden */
  62352. protected _horizontalAlignment: number;
  62353. /** @hidden */
  62354. protected _verticalAlignment: number;
  62355. /** @hidden */
  62356. protected _isDirty: boolean;
  62357. /** @hidden */
  62358. protected _wasDirty: boolean;
  62359. /** @hidden */
  62360. _tempParentMeasure: Measure;
  62361. /** @hidden */
  62362. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  62363. /** @hidden */
  62364. protected _cachedParentMeasure: Measure;
  62365. private _paddingLeft;
  62366. private _paddingRight;
  62367. private _paddingTop;
  62368. private _paddingBottom;
  62369. /** @hidden */
  62370. _left: ValueAndUnit;
  62371. /** @hidden */
  62372. _top: ValueAndUnit;
  62373. private _scaleX;
  62374. private _scaleY;
  62375. private _rotation;
  62376. private _transformCenterX;
  62377. private _transformCenterY;
  62378. /** @hidden */
  62379. _transformMatrix: Matrix2D;
  62380. /** @hidden */
  62381. protected _invertTransformMatrix: Matrix2D;
  62382. /** @hidden */
  62383. protected _transformedPosition: BABYLON.Vector2;
  62384. private _isMatrixDirty;
  62385. private _cachedOffsetX;
  62386. private _cachedOffsetY;
  62387. private _isVisible;
  62388. private _isHighlighted;
  62389. /** @hidden */
  62390. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62391. private _fontSet;
  62392. private _dummyVector2;
  62393. private _downCount;
  62394. private _enterCount;
  62395. private _doNotRender;
  62396. private _downPointerIds;
  62397. protected _isEnabled: boolean;
  62398. protected _disabledColor: string;
  62399. /** @hidden */
  62400. protected _rebuildLayout: boolean;
  62401. /** @hidden */
  62402. _isClipped: boolean;
  62403. /** @hidden */
  62404. _tag: any;
  62405. /**
  62406. * 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
  62407. */
  62408. uniqueId: number;
  62409. /**
  62410. * Gets or sets an object used to store user defined information for the node
  62411. */
  62412. metadata: any;
  62413. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  62414. isHitTestVisible: boolean;
  62415. /** Gets or sets a boolean indicating if the control can block pointer events */
  62416. isPointerBlocker: boolean;
  62417. /** Gets or sets a boolean indicating if the control can be focusable */
  62418. isFocusInvisible: boolean;
  62419. /**
  62420. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  62421. * 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
  62422. */
  62423. clipChildren: boolean;
  62424. /**
  62425. * Gets or sets a boolean indicating that control content must be clipped
  62426. * 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
  62427. */
  62428. clipContent: boolean;
  62429. /**
  62430. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  62431. */
  62432. useBitmapCache: boolean;
  62433. private _cacheData;
  62434. private _shadowOffsetX;
  62435. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  62436. shadowOffsetX: number;
  62437. private _shadowOffsetY;
  62438. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  62439. shadowOffsetY: number;
  62440. private _shadowBlur;
  62441. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  62442. shadowBlur: number;
  62443. private _shadowColor;
  62444. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  62445. shadowColor: string;
  62446. /** Gets or sets the cursor to use when the control is hovered */
  62447. hoverCursor: string;
  62448. /** @hidden */
  62449. protected _linkOffsetX: ValueAndUnit;
  62450. /** @hidden */
  62451. protected _linkOffsetY: ValueAndUnit;
  62452. /** Gets the control type name */
  62453. readonly typeName: string;
  62454. /**
  62455. * Get the current class name of the control.
  62456. * @returns current class name
  62457. */
  62458. getClassName(): string;
  62459. /**
  62460. * An event triggered when the pointer move over the control.
  62461. */
  62462. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  62463. /**
  62464. * An event triggered when the pointer move out of the control.
  62465. */
  62466. onPointerOutObservable: BABYLON.Observable<Control>;
  62467. /**
  62468. * An event triggered when the pointer taps the control
  62469. */
  62470. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  62471. /**
  62472. * An event triggered when pointer up
  62473. */
  62474. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  62475. /**
  62476. * An event triggered when a control is clicked on
  62477. */
  62478. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  62479. /**
  62480. * An event triggered when pointer enters the control
  62481. */
  62482. onPointerEnterObservable: BABYLON.Observable<Control>;
  62483. /**
  62484. * An event triggered when the control is marked as dirty
  62485. */
  62486. onDirtyObservable: BABYLON.Observable<Control>;
  62487. /**
  62488. * An event triggered before drawing the control
  62489. */
  62490. onBeforeDrawObservable: BABYLON.Observable<Control>;
  62491. /**
  62492. * An event triggered after the control was drawn
  62493. */
  62494. onAfterDrawObservable: BABYLON.Observable<Control>;
  62495. /**
  62496. * Get the hosting AdvancedDynamicTexture
  62497. */
  62498. readonly host: AdvancedDynamicTexture;
  62499. /** Gets or set information about font offsets (used to render and align text) */
  62500. fontOffset: {
  62501. ascent: number;
  62502. height: number;
  62503. descent: number;
  62504. };
  62505. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  62506. alpha: number;
  62507. /**
  62508. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  62509. */
  62510. isHighlighted: boolean;
  62511. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  62512. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62513. */
  62514. scaleX: number;
  62515. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  62516. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62517. */
  62518. scaleY: number;
  62519. /** Gets or sets the rotation angle (0 by default)
  62520. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62521. */
  62522. rotation: number;
  62523. /** Gets or sets the transformation center on Y axis (0 by default)
  62524. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62525. */
  62526. transformCenterY: number;
  62527. /** Gets or sets the transformation center on X axis (0 by default)
  62528. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62529. */
  62530. transformCenterX: number;
  62531. /**
  62532. * Gets or sets the horizontal alignment
  62533. * @see http://doc.babylonjs.com/how_to/gui#alignments
  62534. */
  62535. horizontalAlignment: number;
  62536. /**
  62537. * Gets or sets the vertical alignment
  62538. * @see http://doc.babylonjs.com/how_to/gui#alignments
  62539. */
  62540. verticalAlignment: number;
  62541. /**
  62542. * Gets or sets control width
  62543. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62544. */
  62545. width: string | number;
  62546. /**
  62547. * Gets or sets the control width in pixel
  62548. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62549. */
  62550. widthInPixels: number;
  62551. /**
  62552. * Gets or sets control height
  62553. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62554. */
  62555. height: string | number;
  62556. /**
  62557. * Gets or sets control height in pixel
  62558. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62559. */
  62560. heightInPixels: number;
  62561. /** Gets or set font family */
  62562. fontFamily: string;
  62563. /** Gets or sets font style */
  62564. fontStyle: string;
  62565. /** Gets or sets font weight */
  62566. fontWeight: string;
  62567. /**
  62568. * Gets or sets style
  62569. * @see http://doc.babylonjs.com/how_to/gui#styles
  62570. */
  62571. style: BABYLON.Nullable<Style>;
  62572. /** @hidden */
  62573. readonly _isFontSizeInPercentage: boolean;
  62574. /** Gets or sets font size in pixels */
  62575. fontSizeInPixels: number;
  62576. /** Gets or sets font size */
  62577. fontSize: string | number;
  62578. /** Gets or sets foreground color */
  62579. color: string;
  62580. /** Gets or sets z index which is used to reorder controls on the z axis */
  62581. zIndex: number;
  62582. /** Gets or sets a boolean indicating if the control can be rendered */
  62583. notRenderable: boolean;
  62584. /** Gets or sets a boolean indicating if the control is visible */
  62585. isVisible: boolean;
  62586. /** Gets a boolean indicating that the control needs to update its rendering */
  62587. readonly isDirty: boolean;
  62588. /**
  62589. * Gets the current linked mesh (or null if none)
  62590. */
  62591. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62592. /**
  62593. * Gets or sets a value indicating the padding to use on the left of the control
  62594. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62595. */
  62596. paddingLeft: string | number;
  62597. /**
  62598. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  62599. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62600. */
  62601. paddingLeftInPixels: number;
  62602. /**
  62603. * Gets or sets a value indicating the padding to use on the right of the control
  62604. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62605. */
  62606. paddingRight: string | number;
  62607. /**
  62608. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  62609. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62610. */
  62611. paddingRightInPixels: number;
  62612. /**
  62613. * Gets or sets a value indicating the padding to use on the top of the control
  62614. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62615. */
  62616. paddingTop: string | number;
  62617. /**
  62618. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  62619. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62620. */
  62621. paddingTopInPixels: number;
  62622. /**
  62623. * Gets or sets a value indicating the padding to use on the bottom of the control
  62624. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62625. */
  62626. paddingBottom: string | number;
  62627. /**
  62628. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  62629. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62630. */
  62631. paddingBottomInPixels: number;
  62632. /**
  62633. * Gets or sets a value indicating the left coordinate of the control
  62634. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62635. */
  62636. left: string | number;
  62637. /**
  62638. * Gets or sets a value indicating the left coordinate in pixels of the control
  62639. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62640. */
  62641. leftInPixels: number;
  62642. /**
  62643. * Gets or sets a value indicating the top coordinate of the control
  62644. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62645. */
  62646. top: string | number;
  62647. /**
  62648. * Gets or sets a value indicating the top coordinate in pixels of the control
  62649. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62650. */
  62651. topInPixels: number;
  62652. /**
  62653. * Gets or sets a value indicating the offset on X axis to the linked mesh
  62654. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62655. */
  62656. linkOffsetX: string | number;
  62657. /**
  62658. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  62659. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62660. */
  62661. linkOffsetXInPixels: number;
  62662. /**
  62663. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  62664. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62665. */
  62666. linkOffsetY: string | number;
  62667. /**
  62668. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  62669. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62670. */
  62671. linkOffsetYInPixels: number;
  62672. /** Gets the center coordinate on X axis */
  62673. readonly centerX: number;
  62674. /** Gets the center coordinate on Y axis */
  62675. readonly centerY: number;
  62676. /** Gets or sets if control is Enabled*/
  62677. isEnabled: boolean;
  62678. /** Gets or sets background color of control if it's disabled*/
  62679. disabledColor: string;
  62680. /**
  62681. * Creates a new control
  62682. * @param name defines the name of the control
  62683. */
  62684. constructor(
  62685. /** defines the name of the control */
  62686. name?: string | undefined);
  62687. /** @hidden */
  62688. protected _getTypeName(): string;
  62689. /**
  62690. * Gets the first ascendant in the hierarchy of the given type
  62691. * @param className defines the required type
  62692. * @returns the ascendant or null if not found
  62693. */
  62694. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  62695. /** @hidden */
  62696. _resetFontCache(): void;
  62697. /**
  62698. * Determines if a container is an ascendant of the current control
  62699. * @param container defines the container to look for
  62700. * @returns true if the container is one of the ascendant of the control
  62701. */
  62702. isAscendant(container: Control): boolean;
  62703. /**
  62704. * Gets coordinates in local control space
  62705. * @param globalCoordinates defines the coordinates to transform
  62706. * @returns the new coordinates in local space
  62707. */
  62708. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  62709. /**
  62710. * Gets coordinates in local control space
  62711. * @param globalCoordinates defines the coordinates to transform
  62712. * @param result defines the target vector2 where to store the result
  62713. * @returns the current control
  62714. */
  62715. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  62716. /**
  62717. * Gets coordinates in parent local control space
  62718. * @param globalCoordinates defines the coordinates to transform
  62719. * @returns the new coordinates in parent local space
  62720. */
  62721. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  62722. /**
  62723. * Move the current control to a vector3 position projected onto the screen.
  62724. * @param position defines the target position
  62725. * @param scene defines the hosting scene
  62726. */
  62727. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  62728. /** @hidden */
  62729. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  62730. /**
  62731. * Will return all controls that have this control as ascendant
  62732. * @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
  62733. * @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
  62734. * @return all child controls
  62735. */
  62736. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  62737. /**
  62738. * Link current control with a target mesh
  62739. * @param mesh defines the mesh to link with
  62740. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62741. */
  62742. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  62743. /** @hidden */
  62744. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  62745. /** @hidden */
  62746. _offsetLeft(offset: number): void;
  62747. /** @hidden */
  62748. _offsetTop(offset: number): void;
  62749. /** @hidden */
  62750. _markMatrixAsDirty(): void;
  62751. /** @hidden */
  62752. _flagDescendantsAsMatrixDirty(): void;
  62753. /** @hidden */
  62754. _intersectsRect(rect: Measure): boolean;
  62755. /** @hidden */
  62756. protected invalidateRect(): void;
  62757. /** @hidden */
  62758. _markAsDirty(force?: boolean): void;
  62759. /** @hidden */
  62760. _markAllAsDirty(): void;
  62761. /** @hidden */
  62762. _link(host: AdvancedDynamicTexture): void;
  62763. /** @hidden */
  62764. protected _transform(context?: CanvasRenderingContext2D): void;
  62765. /** @hidden */
  62766. _renderHighlight(context: CanvasRenderingContext2D): void;
  62767. /** @hidden */
  62768. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  62769. /** @hidden */
  62770. protected _applyStates(context: CanvasRenderingContext2D): void;
  62771. /** @hidden */
  62772. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  62773. /** @hidden */
  62774. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62775. protected _evaluateClippingState(parentMeasure: Measure): void;
  62776. /** @hidden */
  62777. _measure(): void;
  62778. /** @hidden */
  62779. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62780. /** @hidden */
  62781. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62782. /** @hidden */
  62783. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62784. /** @hidden */
  62785. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  62786. private static _ClipMeasure;
  62787. private _tmpMeasureA;
  62788. private _clip;
  62789. /** @hidden */
  62790. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  62791. /** @hidden */
  62792. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  62793. /**
  62794. * Tests if a given coordinates belong to the current control
  62795. * @param x defines x coordinate to test
  62796. * @param y defines y coordinate to test
  62797. * @returns true if the coordinates are inside the control
  62798. */
  62799. contains(x: number, y: number): boolean;
  62800. /** @hidden */
  62801. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  62802. /** @hidden */
  62803. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  62804. /** @hidden */
  62805. _onPointerEnter(target: Control): boolean;
  62806. /** @hidden */
  62807. _onPointerOut(target: Control, force?: boolean): void;
  62808. /** @hidden */
  62809. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62810. /** @hidden */
  62811. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62812. /** @hidden */
  62813. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  62814. /** @hidden */
  62815. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  62816. private _prepareFont;
  62817. /** Releases associated resources */
  62818. dispose(): void;
  62819. private static _HORIZONTAL_ALIGNMENT_LEFT;
  62820. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  62821. private static _HORIZONTAL_ALIGNMENT_CENTER;
  62822. private static _VERTICAL_ALIGNMENT_TOP;
  62823. private static _VERTICAL_ALIGNMENT_BOTTOM;
  62824. private static _VERTICAL_ALIGNMENT_CENTER;
  62825. /** HORIZONTAL_ALIGNMENT_LEFT */
  62826. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  62827. /** HORIZONTAL_ALIGNMENT_RIGHT */
  62828. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  62829. /** HORIZONTAL_ALIGNMENT_CENTER */
  62830. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  62831. /** VERTICAL_ALIGNMENT_TOP */
  62832. static readonly VERTICAL_ALIGNMENT_TOP: number;
  62833. /** VERTICAL_ALIGNMENT_BOTTOM */
  62834. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  62835. /** VERTICAL_ALIGNMENT_CENTER */
  62836. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  62837. private static _FontHeightSizes;
  62838. /** @hidden */
  62839. static _GetFontOffset(font: string): {
  62840. ascent: number;
  62841. height: number;
  62842. descent: number;
  62843. };
  62844. /**
  62845. * Creates a stack panel that can be used to render headers
  62846. * @param control defines the control to associate with the header
  62847. * @param text defines the text of the header
  62848. * @param size defines the size of the header
  62849. * @param options defines options used to configure the header
  62850. * @returns a new StackPanel
  62851. * @ignore
  62852. * @hidden
  62853. */
  62854. static AddHeader: (control: Control, text: string, size: string | number, options: {
  62855. isHorizontal: boolean;
  62856. controlFirst: boolean;
  62857. }) => any;
  62858. /** @hidden */
  62859. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  62860. }
  62861. }
  62862. declare module BABYLON.GUI {
  62863. /**
  62864. * Root class for 2D containers
  62865. * @see http://doc.babylonjs.com/how_to/gui#containers
  62866. */
  62867. export class Container extends Control {
  62868. name?: string | undefined;
  62869. /** @hidden */
  62870. protected _children: Control[];
  62871. /** @hidden */
  62872. protected _measureForChildren: Measure;
  62873. /** @hidden */
  62874. protected _background: string;
  62875. /** @hidden */
  62876. protected _adaptWidthToChildren: boolean;
  62877. /** @hidden */
  62878. protected _adaptHeightToChildren: boolean;
  62879. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  62880. adaptHeightToChildren: boolean;
  62881. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  62882. adaptWidthToChildren: boolean;
  62883. /** Gets or sets background color */
  62884. background: string;
  62885. /** Gets the list of children */
  62886. readonly children: Control[];
  62887. /**
  62888. * Creates a new Container
  62889. * @param name defines the name of the container
  62890. */
  62891. constructor(name?: string | undefined);
  62892. protected _getTypeName(): string;
  62893. _flagDescendantsAsMatrixDirty(): void;
  62894. /**
  62895. * Gets a child using its name
  62896. * @param name defines the child name to look for
  62897. * @returns the child control if found
  62898. */
  62899. getChildByName(name: string): BABYLON.Nullable<Control>;
  62900. /**
  62901. * Gets a child using its type and its name
  62902. * @param name defines the child name to look for
  62903. * @param type defines the child type to look for
  62904. * @returns the child control if found
  62905. */
  62906. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  62907. /**
  62908. * Search for a specific control in children
  62909. * @param control defines the control to look for
  62910. * @returns true if the control is in child list
  62911. */
  62912. containsControl(control: Control): boolean;
  62913. /**
  62914. * Adds a new control to the current container
  62915. * @param control defines the control to add
  62916. * @returns the current container
  62917. */
  62918. addControl(control: BABYLON.Nullable<Control>): Container;
  62919. /**
  62920. * Removes all controls from the current container
  62921. * @returns the current container
  62922. */
  62923. clearControls(): Container;
  62924. /**
  62925. * Removes a control from the current container
  62926. * @param control defines the control to remove
  62927. * @returns the current container
  62928. */
  62929. removeControl(control: Control): Container;
  62930. /** @hidden */
  62931. _reOrderControl(control: Control): void;
  62932. /** @hidden */
  62933. _offsetLeft(offset: number): void;
  62934. /** @hidden */
  62935. _offsetTop(offset: number): void;
  62936. /** @hidden */
  62937. _markAllAsDirty(): void;
  62938. /** @hidden */
  62939. protected _localDraw(context: CanvasRenderingContext2D): void;
  62940. /** @hidden */
  62941. _link(host: AdvancedDynamicTexture): void;
  62942. /** @hidden */
  62943. protected _beforeLayout(): void;
  62944. /** @hidden */
  62945. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62946. /** @hidden */
  62947. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  62948. protected _postMeasure(): void;
  62949. /** @hidden */
  62950. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  62951. /** @hidden */
  62952. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  62953. /** @hidden */
  62954. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  62955. /** @hidden */
  62956. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62957. /** Releases associated resources */
  62958. dispose(): void;
  62959. }
  62960. }
  62961. declare module BABYLON.GUI {
  62962. /** Class used to create rectangle container */
  62963. export class Rectangle extends Container {
  62964. name?: string | undefined;
  62965. private _thickness;
  62966. private _cornerRadius;
  62967. /** Gets or sets border thickness */
  62968. thickness: number;
  62969. /** Gets or sets the corner radius angle */
  62970. cornerRadius: number;
  62971. /**
  62972. * Creates a new Rectangle
  62973. * @param name defines the control name
  62974. */
  62975. constructor(name?: string | undefined);
  62976. protected _getTypeName(): string;
  62977. protected _localDraw(context: CanvasRenderingContext2D): void;
  62978. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62979. private _drawRoundedRect;
  62980. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  62981. }
  62982. }
  62983. declare module BABYLON.GUI {
  62984. /**
  62985. * Enum that determines the text-wrapping mode to use.
  62986. */
  62987. export enum TextWrapping {
  62988. /**
  62989. * Clip the text when it's larger than Control.width; this is the default mode.
  62990. */
  62991. Clip = 0,
  62992. /**
  62993. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  62994. */
  62995. WordWrap = 1,
  62996. /**
  62997. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  62998. */
  62999. Ellipsis = 2
  63000. }
  63001. /**
  63002. * Class used to create text block control
  63003. */
  63004. export class TextBlock extends Control {
  63005. /**
  63006. * Defines the name of the control
  63007. */
  63008. name?: string | undefined;
  63009. private _text;
  63010. private _textWrapping;
  63011. private _textHorizontalAlignment;
  63012. private _textVerticalAlignment;
  63013. private _lines;
  63014. private _resizeToFit;
  63015. private _lineSpacing;
  63016. private _outlineWidth;
  63017. private _outlineColor;
  63018. /**
  63019. * An event triggered after the text is changed
  63020. */
  63021. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  63022. /**
  63023. * An event triggered after the text was broken up into lines
  63024. */
  63025. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  63026. /**
  63027. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  63028. */
  63029. readonly lines: any[];
  63030. /**
  63031. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  63032. */
  63033. /**
  63034. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  63035. */
  63036. resizeToFit: boolean;
  63037. /**
  63038. * Gets or sets a boolean indicating if text must be wrapped
  63039. */
  63040. /**
  63041. * Gets or sets a boolean indicating if text must be wrapped
  63042. */
  63043. textWrapping: TextWrapping | boolean;
  63044. /**
  63045. * Gets or sets text to display
  63046. */
  63047. /**
  63048. * Gets or sets text to display
  63049. */
  63050. text: string;
  63051. /**
  63052. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  63053. */
  63054. /**
  63055. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  63056. */
  63057. textHorizontalAlignment: number;
  63058. /**
  63059. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  63060. */
  63061. /**
  63062. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  63063. */
  63064. textVerticalAlignment: number;
  63065. /**
  63066. * Gets or sets line spacing value
  63067. */
  63068. /**
  63069. * Gets or sets line spacing value
  63070. */
  63071. lineSpacing: string | number;
  63072. /**
  63073. * Gets or sets outlineWidth of the text to display
  63074. */
  63075. /**
  63076. * Gets or sets outlineWidth of the text to display
  63077. */
  63078. outlineWidth: number;
  63079. /**
  63080. * Gets or sets outlineColor of the text to display
  63081. */
  63082. /**
  63083. * Gets or sets outlineColor of the text to display
  63084. */
  63085. outlineColor: string;
  63086. /**
  63087. * Creates a new TextBlock object
  63088. * @param name defines the name of the control
  63089. * @param text defines the text to display (emptry string by default)
  63090. */
  63091. constructor(
  63092. /**
  63093. * Defines the name of the control
  63094. */
  63095. name?: string | undefined, text?: string);
  63096. protected _getTypeName(): string;
  63097. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63098. private _drawText;
  63099. /** @hidden */
  63100. _draw(context: CanvasRenderingContext2D): void;
  63101. protected _applyStates(context: CanvasRenderingContext2D): void;
  63102. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  63103. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  63104. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  63105. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  63106. protected _renderLines(context: CanvasRenderingContext2D): void;
  63107. /**
  63108. * Given a width constraint applied on the text block, find the expected height
  63109. * @returns expected height
  63110. */
  63111. computeExpectedHeight(): number;
  63112. dispose(): void;
  63113. }
  63114. }
  63115. declare module BABYLON.GUI {
  63116. /**
  63117. * Class used to create 2D images
  63118. */
  63119. export class Image extends Control {
  63120. name?: string | undefined;
  63121. private static _WorkingCanvas;
  63122. private _domImage;
  63123. private _imageWidth;
  63124. private _imageHeight;
  63125. private _loaded;
  63126. private _stretch;
  63127. private _source;
  63128. private _autoScale;
  63129. private _sourceLeft;
  63130. private _sourceTop;
  63131. private _sourceWidth;
  63132. private _sourceHeight;
  63133. private _cellWidth;
  63134. private _cellHeight;
  63135. private _cellId;
  63136. private _populateNinePatchSlicesFromImage;
  63137. private _sliceLeft;
  63138. private _sliceRight;
  63139. private _sliceTop;
  63140. private _sliceBottom;
  63141. private _detectPointerOnOpaqueOnly;
  63142. /**
  63143. * BABYLON.Observable notified when the content is loaded
  63144. */
  63145. onImageLoadedObservable: BABYLON.Observable<Image>;
  63146. /**
  63147. * Gets a boolean indicating that the content is loaded
  63148. */
  63149. readonly isLoaded: boolean;
  63150. /**
  63151. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  63152. */
  63153. populateNinePatchSlicesFromImage: boolean;
  63154. /**
  63155. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  63156. * Beware using this as this will comsume more memory as the image has to be stored twice
  63157. */
  63158. detectPointerOnOpaqueOnly: boolean;
  63159. /**
  63160. * Gets or sets the left value for slicing (9-patch)
  63161. */
  63162. sliceLeft: number;
  63163. /**
  63164. * Gets or sets the right value for slicing (9-patch)
  63165. */
  63166. sliceRight: number;
  63167. /**
  63168. * Gets or sets the top value for slicing (9-patch)
  63169. */
  63170. sliceTop: number;
  63171. /**
  63172. * Gets or sets the bottom value for slicing (9-patch)
  63173. */
  63174. sliceBottom: number;
  63175. /**
  63176. * Gets or sets the left coordinate in the source image
  63177. */
  63178. sourceLeft: number;
  63179. /**
  63180. * Gets or sets the top coordinate in the source image
  63181. */
  63182. sourceTop: number;
  63183. /**
  63184. * Gets or sets the width to capture in the source image
  63185. */
  63186. sourceWidth: number;
  63187. /**
  63188. * Gets or sets the height to capture in the source image
  63189. */
  63190. sourceHeight: number;
  63191. /**
  63192. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  63193. * @see http://doc.babylonjs.com/how_to/gui#image
  63194. */
  63195. autoScale: boolean;
  63196. /** Gets or sets the streching mode used by the image */
  63197. stretch: number;
  63198. /**
  63199. * Gets or sets the internal DOM image used to render the control
  63200. */
  63201. domImage: HTMLImageElement;
  63202. private _onImageLoaded;
  63203. private _extractNinePatchSliceDataFromImage;
  63204. /**
  63205. * Gets or sets image source url
  63206. */
  63207. source: BABYLON.Nullable<string>;
  63208. /**
  63209. * Gets or sets the cell width to use when animation sheet is enabled
  63210. * @see http://doc.babylonjs.com/how_to/gui#image
  63211. */
  63212. cellWidth: number;
  63213. /**
  63214. * Gets or sets the cell height to use when animation sheet is enabled
  63215. * @see http://doc.babylonjs.com/how_to/gui#image
  63216. */
  63217. cellHeight: number;
  63218. /**
  63219. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  63220. * @see http://doc.babylonjs.com/how_to/gui#image
  63221. */
  63222. cellId: number;
  63223. /**
  63224. * Creates a new Image
  63225. * @param name defines the control name
  63226. * @param url defines the image url
  63227. */
  63228. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  63229. /**
  63230. * Tests if a given coordinates belong to the current control
  63231. * @param x defines x coordinate to test
  63232. * @param y defines y coordinate to test
  63233. * @returns true if the coordinates are inside the control
  63234. */
  63235. contains(x: number, y: number): boolean;
  63236. protected _getTypeName(): string;
  63237. /** Force the control to synchronize with its content */
  63238. synchronizeSizeWithContent(): void;
  63239. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63240. private _prepareWorkingCanvasForOpaqueDetection;
  63241. private _drawImage;
  63242. _draw(context: CanvasRenderingContext2D): void;
  63243. private _renderCornerPatch;
  63244. private _renderNinePatch;
  63245. dispose(): void;
  63246. /** STRETCH_NONE */
  63247. static readonly STRETCH_NONE: number;
  63248. /** STRETCH_FILL */
  63249. static readonly STRETCH_FILL: number;
  63250. /** STRETCH_UNIFORM */
  63251. static readonly STRETCH_UNIFORM: number;
  63252. /** STRETCH_EXTEND */
  63253. static readonly STRETCH_EXTEND: number;
  63254. /** NINE_PATCH */
  63255. static readonly STRETCH_NINE_PATCH: number;
  63256. }
  63257. }
  63258. declare module BABYLON.GUI {
  63259. /**
  63260. * Class used to create 2D buttons
  63261. */
  63262. export class Button extends Rectangle {
  63263. name?: string | undefined;
  63264. /**
  63265. * Function called to generate a pointer enter animation
  63266. */
  63267. pointerEnterAnimation: () => void;
  63268. /**
  63269. * Function called to generate a pointer out animation
  63270. */
  63271. pointerOutAnimation: () => void;
  63272. /**
  63273. * Function called to generate a pointer down animation
  63274. */
  63275. pointerDownAnimation: () => void;
  63276. /**
  63277. * Function called to generate a pointer up animation
  63278. */
  63279. pointerUpAnimation: () => void;
  63280. /**
  63281. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  63282. */
  63283. delegatePickingToChildren: boolean;
  63284. private _image;
  63285. /**
  63286. * Returns the image part of the button (if any)
  63287. */
  63288. readonly image: BABYLON.Nullable<Image>;
  63289. private _textBlock;
  63290. /**
  63291. * Returns the image part of the button (if any)
  63292. */
  63293. readonly textBlock: BABYLON.Nullable<TextBlock>;
  63294. /**
  63295. * Creates a new Button
  63296. * @param name defines the name of the button
  63297. */
  63298. constructor(name?: string | undefined);
  63299. protected _getTypeName(): string;
  63300. /** @hidden */
  63301. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63302. /** @hidden */
  63303. _onPointerEnter(target: Control): boolean;
  63304. /** @hidden */
  63305. _onPointerOut(target: Control, force?: boolean): void;
  63306. /** @hidden */
  63307. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63308. /** @hidden */
  63309. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63310. /**
  63311. * Creates a new button made with an image and a text
  63312. * @param name defines the name of the button
  63313. * @param text defines the text of the button
  63314. * @param imageUrl defines the url of the image
  63315. * @returns a new Button
  63316. */
  63317. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  63318. /**
  63319. * Creates a new button made with an image
  63320. * @param name defines the name of the button
  63321. * @param imageUrl defines the url of the image
  63322. * @returns a new Button
  63323. */
  63324. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  63325. /**
  63326. * Creates a new button made with a text
  63327. * @param name defines the name of the button
  63328. * @param text defines the text of the button
  63329. * @returns a new Button
  63330. */
  63331. static CreateSimpleButton(name: string, text: string): Button;
  63332. /**
  63333. * Creates a new button made with an image and a centered text
  63334. * @param name defines the name of the button
  63335. * @param text defines the text of the button
  63336. * @param imageUrl defines the url of the image
  63337. * @returns a new Button
  63338. */
  63339. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  63340. }
  63341. }
  63342. declare module BABYLON.GUI {
  63343. /**
  63344. * Class used to create a 2D stack panel container
  63345. */
  63346. export class StackPanel extends Container {
  63347. name?: string | undefined;
  63348. private _isVertical;
  63349. private _manualWidth;
  63350. private _manualHeight;
  63351. private _doNotTrackManualChanges;
  63352. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  63353. isVertical: boolean;
  63354. /**
  63355. * Gets or sets panel width.
  63356. * This value should not be set when in horizontal mode as it will be computed automatically
  63357. */
  63358. width: string | number;
  63359. /**
  63360. * Gets or sets panel height.
  63361. * This value should not be set when in vertical mode as it will be computed automatically
  63362. */
  63363. height: string | number;
  63364. /**
  63365. * Creates a new StackPanel
  63366. * @param name defines control name
  63367. */
  63368. constructor(name?: string | undefined);
  63369. protected _getTypeName(): string;
  63370. /** @hidden */
  63371. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63372. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63373. protected _postMeasure(): void;
  63374. }
  63375. }
  63376. declare module BABYLON.GUI {
  63377. /**
  63378. * Class used to represent a 2D checkbox
  63379. */
  63380. export class Checkbox extends Control {
  63381. name?: string | undefined;
  63382. private _isChecked;
  63383. private _background;
  63384. private _checkSizeRatio;
  63385. private _thickness;
  63386. /** Gets or sets border thickness */
  63387. thickness: number;
  63388. /**
  63389. * BABYLON.Observable raised when isChecked property changes
  63390. */
  63391. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  63392. /** Gets or sets a value indicating the ratio between overall size and check size */
  63393. checkSizeRatio: number;
  63394. /** Gets or sets background color */
  63395. background: string;
  63396. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  63397. isChecked: boolean;
  63398. /**
  63399. * Creates a new CheckBox
  63400. * @param name defines the control name
  63401. */
  63402. constructor(name?: string | undefined);
  63403. protected _getTypeName(): string;
  63404. /** @hidden */
  63405. _draw(context: CanvasRenderingContext2D): void;
  63406. /** @hidden */
  63407. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63408. /**
  63409. * Utility function to easily create a checkbox with a header
  63410. * @param title defines the label to use for the header
  63411. * @param onValueChanged defines the callback to call when value changes
  63412. * @returns a StackPanel containing the checkbox and a textBlock
  63413. */
  63414. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  63415. }
  63416. }
  63417. declare module BABYLON.GUI {
  63418. /**
  63419. * Class used to store key control properties
  63420. */
  63421. export class KeyPropertySet {
  63422. /** Width */
  63423. width?: string;
  63424. /** Height */
  63425. height?: string;
  63426. /** Left padding */
  63427. paddingLeft?: string;
  63428. /** Right padding */
  63429. paddingRight?: string;
  63430. /** Top padding */
  63431. paddingTop?: string;
  63432. /** Bottom padding */
  63433. paddingBottom?: string;
  63434. /** Foreground color */
  63435. color?: string;
  63436. /** Background color */
  63437. background?: string;
  63438. }
  63439. /**
  63440. * Class used to create virtual keyboard
  63441. */
  63442. export class VirtualKeyboard extends StackPanel {
  63443. /** BABYLON.Observable raised when a key is pressed */
  63444. onKeyPressObservable: BABYLON.Observable<string>;
  63445. /** Gets or sets default key button width */
  63446. defaultButtonWidth: string;
  63447. /** Gets or sets default key button height */
  63448. defaultButtonHeight: string;
  63449. /** Gets or sets default key button left padding */
  63450. defaultButtonPaddingLeft: string;
  63451. /** Gets or sets default key button right padding */
  63452. defaultButtonPaddingRight: string;
  63453. /** Gets or sets default key button top padding */
  63454. defaultButtonPaddingTop: string;
  63455. /** Gets or sets default key button bottom padding */
  63456. defaultButtonPaddingBottom: string;
  63457. /** Gets or sets default key button foreground color */
  63458. defaultButtonColor: string;
  63459. /** Gets or sets default key button background color */
  63460. defaultButtonBackground: string;
  63461. /** Gets or sets shift button foreground color */
  63462. shiftButtonColor: string;
  63463. /** Gets or sets shift button thickness*/
  63464. selectedShiftThickness: number;
  63465. /** Gets shift key state */
  63466. shiftState: number;
  63467. protected _getTypeName(): string;
  63468. private _createKey;
  63469. /**
  63470. * Adds a new row of keys
  63471. * @param keys defines the list of keys to add
  63472. * @param propertySets defines the associated property sets
  63473. */
  63474. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  63475. /**
  63476. * Set the shift key to a specific state
  63477. * @param shiftState defines the new shift state
  63478. */
  63479. applyShiftState(shiftState: number): void;
  63480. private _currentlyConnectedInputText;
  63481. private _connectedInputTexts;
  63482. private _onKeyPressObserver;
  63483. /** Gets the input text control currently attached to the keyboard */
  63484. readonly connectedInputText: BABYLON.Nullable<InputText>;
  63485. /**
  63486. * Connects the keyboard with an input text control
  63487. *
  63488. * @param input defines the target control
  63489. */
  63490. connect(input: InputText): void;
  63491. /**
  63492. * Disconnects the keyboard from connected InputText controls
  63493. *
  63494. * @param input optionally defines a target control, otherwise all are disconnected
  63495. */
  63496. disconnect(input?: InputText): void;
  63497. private _removeConnectedInputObservables;
  63498. /**
  63499. * Release all resources
  63500. */
  63501. dispose(): void;
  63502. /**
  63503. * Creates a new keyboard using a default layout
  63504. *
  63505. * @param name defines control name
  63506. * @returns a new VirtualKeyboard
  63507. */
  63508. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  63509. }
  63510. }
  63511. declare module BABYLON.GUI {
  63512. /**
  63513. * Class used to create input text control
  63514. */
  63515. export class InputText extends Control implements IFocusableControl {
  63516. name?: string | undefined;
  63517. private _text;
  63518. private _placeholderText;
  63519. private _background;
  63520. private _focusedBackground;
  63521. private _focusedColor;
  63522. private _placeholderColor;
  63523. private _thickness;
  63524. private _margin;
  63525. private _autoStretchWidth;
  63526. private _maxWidth;
  63527. private _isFocused;
  63528. private _blinkTimeout;
  63529. private _blinkIsEven;
  63530. private _cursorOffset;
  63531. private _scrollLeft;
  63532. private _textWidth;
  63533. private _clickedCoordinate;
  63534. private _deadKey;
  63535. private _addKey;
  63536. private _currentKey;
  63537. private _isTextHighlightOn;
  63538. private _textHighlightColor;
  63539. private _highligherOpacity;
  63540. private _highlightedText;
  63541. private _startHighlightIndex;
  63542. private _endHighlightIndex;
  63543. private _cursorIndex;
  63544. private _onFocusSelectAll;
  63545. private _isPointerDown;
  63546. private _onClipboardObserver;
  63547. private _onPointerDblTapObserver;
  63548. /** @hidden */
  63549. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  63550. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  63551. promptMessage: string;
  63552. /** Force disable prompt on mobile device */
  63553. disableMobilePrompt: boolean;
  63554. /** BABYLON.Observable raised when the text changes */
  63555. onTextChangedObservable: BABYLON.Observable<InputText>;
  63556. /** BABYLON.Observable raised just before an entered character is to be added */
  63557. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  63558. /** BABYLON.Observable raised when the control gets the focus */
  63559. onFocusObservable: BABYLON.Observable<InputText>;
  63560. /** BABYLON.Observable raised when the control loses the focus */
  63561. onBlurObservable: BABYLON.Observable<InputText>;
  63562. /**Observable raised when the text is highlighted */
  63563. onTextHighlightObservable: BABYLON.Observable<InputText>;
  63564. /**Observable raised when copy event is triggered */
  63565. onTextCopyObservable: BABYLON.Observable<InputText>;
  63566. /** BABYLON.Observable raised when cut event is triggered */
  63567. onTextCutObservable: BABYLON.Observable<InputText>;
  63568. /** BABYLON.Observable raised when paste event is triggered */
  63569. onTextPasteObservable: BABYLON.Observable<InputText>;
  63570. /** BABYLON.Observable raised when a key event was processed */
  63571. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  63572. /** Gets or sets the maximum width allowed by the control */
  63573. maxWidth: string | number;
  63574. /** Gets the maximum width allowed by the control in pixels */
  63575. readonly maxWidthInPixels: number;
  63576. /** Gets or sets the text highlighter transparency; default: 0.4 */
  63577. highligherOpacity: number;
  63578. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  63579. onFocusSelectAll: boolean;
  63580. /** Gets or sets the text hightlight color */
  63581. textHighlightColor: string;
  63582. /** Gets or sets control margin */
  63583. margin: string;
  63584. /** Gets control margin in pixels */
  63585. readonly marginInPixels: number;
  63586. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  63587. autoStretchWidth: boolean;
  63588. /** Gets or sets border thickness */
  63589. thickness: number;
  63590. /** Gets or sets the background color when focused */
  63591. focusedBackground: string;
  63592. /** Gets or sets the background color when focused */
  63593. focusedColor: string;
  63594. /** Gets or sets the background color */
  63595. background: string;
  63596. /** Gets or sets the placeholder color */
  63597. placeholderColor: string;
  63598. /** Gets or sets the text displayed when the control is empty */
  63599. placeholderText: string;
  63600. /** Gets or sets the dead key flag */
  63601. deadKey: boolean;
  63602. /** Gets or sets the highlight text */
  63603. highlightedText: string;
  63604. /** Gets or sets if the current key should be added */
  63605. addKey: boolean;
  63606. /** Gets or sets the value of the current key being entered */
  63607. currentKey: string;
  63608. /** Gets or sets the text displayed in the control */
  63609. text: string;
  63610. /** Gets or sets control width */
  63611. width: string | number;
  63612. /**
  63613. * Creates a new InputText
  63614. * @param name defines the control name
  63615. * @param text defines the text of the control
  63616. */
  63617. constructor(name?: string | undefined, text?: string);
  63618. /** @hidden */
  63619. onBlur(): void;
  63620. /** @hidden */
  63621. onFocus(): void;
  63622. protected _getTypeName(): string;
  63623. /**
  63624. * Function called to get the list of controls that should not steal the focus from this control
  63625. * @returns an array of controls
  63626. */
  63627. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  63628. /** @hidden */
  63629. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  63630. /** @hidden */
  63631. private _updateValueFromCursorIndex;
  63632. /** @hidden */
  63633. private _processDblClick;
  63634. /** @hidden */
  63635. private _selectAllText;
  63636. /**
  63637. * Handles the keyboard event
  63638. * @param evt Defines the KeyboardEvent
  63639. */
  63640. processKeyboard(evt: KeyboardEvent): void;
  63641. /** @hidden */
  63642. private _onCopyText;
  63643. /** @hidden */
  63644. private _onCutText;
  63645. /** @hidden */
  63646. private _onPasteText;
  63647. _draw(context: CanvasRenderingContext2D): void;
  63648. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63649. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  63650. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63651. protected _beforeRenderText(text: string): string;
  63652. dispose(): void;
  63653. }
  63654. }
  63655. declare module BABYLON.GUI {
  63656. /**
  63657. * Class used to create a 2D grid container
  63658. */
  63659. export class Grid extends Container {
  63660. name?: string | undefined;
  63661. private _rowDefinitions;
  63662. private _columnDefinitions;
  63663. private _cells;
  63664. private _childControls;
  63665. /**
  63666. * Gets the number of columns
  63667. */
  63668. readonly columnCount: number;
  63669. /**
  63670. * Gets the number of rows
  63671. */
  63672. readonly rowCount: number;
  63673. /** Gets the list of children */
  63674. readonly children: Control[];
  63675. /** Gets the list of cells (e.g. the containers) */
  63676. readonly cells: {
  63677. [key: string]: Container;
  63678. };
  63679. /**
  63680. * Gets the definition of a specific row
  63681. * @param index defines the index of the row
  63682. * @returns the row definition
  63683. */
  63684. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  63685. /**
  63686. * Gets the definition of a specific column
  63687. * @param index defines the index of the column
  63688. * @returns the column definition
  63689. */
  63690. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  63691. /**
  63692. * Adds a new row to the grid
  63693. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  63694. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  63695. * @returns the current grid
  63696. */
  63697. addRowDefinition(height: number, isPixel?: boolean): Grid;
  63698. /**
  63699. * Adds a new column to the grid
  63700. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  63701. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  63702. * @returns the current grid
  63703. */
  63704. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  63705. /**
  63706. * Update a row definition
  63707. * @param index defines the index of the row to update
  63708. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  63709. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  63710. * @returns the current grid
  63711. */
  63712. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  63713. /**
  63714. * Update a column definition
  63715. * @param index defines the index of the column to update
  63716. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  63717. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  63718. * @returns the current grid
  63719. */
  63720. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  63721. /**
  63722. * Gets the list of children stored in a specific cell
  63723. * @param row defines the row to check
  63724. * @param column defines the column to check
  63725. * @returns the list of controls
  63726. */
  63727. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  63728. /**
  63729. * Gets a string representing the child cell info (row x column)
  63730. * @param child defines the control to get info from
  63731. * @returns a string containing the child cell info (row x column)
  63732. */
  63733. getChildCellInfo(child: Control): string;
  63734. private _removeCell;
  63735. private _offsetCell;
  63736. /**
  63737. * Remove a column definition at specified index
  63738. * @param index defines the index of the column to remove
  63739. * @returns the current grid
  63740. */
  63741. removeColumnDefinition(index: number): Grid;
  63742. /**
  63743. * Remove a row definition at specified index
  63744. * @param index defines the index of the row to remove
  63745. * @returns the current grid
  63746. */
  63747. removeRowDefinition(index: number): Grid;
  63748. /**
  63749. * Adds a new control to the current grid
  63750. * @param control defines the control to add
  63751. * @param row defines the row where to add the control (0 by default)
  63752. * @param column defines the column where to add the control (0 by default)
  63753. * @returns the current grid
  63754. */
  63755. addControl(control: Control, row?: number, column?: number): Grid;
  63756. /**
  63757. * Removes a control from the current container
  63758. * @param control defines the control to remove
  63759. * @returns the current container
  63760. */
  63761. removeControl(control: Control): Container;
  63762. /**
  63763. * Creates a new Grid
  63764. * @param name defines control name
  63765. */
  63766. constructor(name?: string | undefined);
  63767. protected _getTypeName(): string;
  63768. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  63769. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63770. _flagDescendantsAsMatrixDirty(): void;
  63771. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  63772. /** Releases associated resources */
  63773. dispose(): void;
  63774. }
  63775. }
  63776. declare module BABYLON.GUI {
  63777. /** Class used to create color pickers */
  63778. export class ColorPicker extends Control {
  63779. name?: string | undefined;
  63780. private static _Epsilon;
  63781. private _colorWheelCanvas;
  63782. private _value;
  63783. private _tmpColor;
  63784. private _pointerStartedOnSquare;
  63785. private _pointerStartedOnWheel;
  63786. private _squareLeft;
  63787. private _squareTop;
  63788. private _squareSize;
  63789. private _h;
  63790. private _s;
  63791. private _v;
  63792. private _lastPointerDownID;
  63793. /**
  63794. * BABYLON.Observable raised when the value changes
  63795. */
  63796. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  63797. /** Gets or sets the color of the color picker */
  63798. value: BABYLON.Color3;
  63799. /**
  63800. * Gets or sets control width
  63801. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63802. */
  63803. width: string | number;
  63804. /**
  63805. * Gets or sets control height
  63806. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63807. */
  63808. /** Gets or sets control height */
  63809. height: string | number;
  63810. /** Gets or sets control size */
  63811. size: string | number;
  63812. /**
  63813. * Creates a new ColorPicker
  63814. * @param name defines the control name
  63815. */
  63816. constructor(name?: string | undefined);
  63817. protected _getTypeName(): string;
  63818. /** @hidden */
  63819. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63820. private _updateSquareProps;
  63821. private _drawGradientSquare;
  63822. private _drawCircle;
  63823. private _createColorWheelCanvas;
  63824. /** @hidden */
  63825. _draw(context: CanvasRenderingContext2D): void;
  63826. private _pointerIsDown;
  63827. private _updateValueFromPointer;
  63828. private _isPointOnSquare;
  63829. private _isPointOnWheel;
  63830. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63831. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  63832. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63833. /**
  63834. * This function expands the color picker by creating a color picker dialog with manual
  63835. * color value input and the ability to save colors into an array to be used later in
  63836. * subsequent launches of the dialogue.
  63837. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  63838. * @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.
  63839. * @returns picked color as a hex string and the saved colors array as hex strings.
  63840. */
  63841. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  63842. pickerWidth?: string;
  63843. pickerHeight?: string;
  63844. headerHeight?: string;
  63845. lastColor?: string;
  63846. swatchLimit?: number;
  63847. numSwatchesPerLine?: number;
  63848. savedColors?: Array<string>;
  63849. }): Promise<{
  63850. savedColors?: string[];
  63851. pickedColor: string;
  63852. }>;
  63853. }
  63854. }
  63855. declare module BABYLON.GUI {
  63856. /** Class used to create 2D ellipse containers */
  63857. export class Ellipse extends Container {
  63858. name?: string | undefined;
  63859. private _thickness;
  63860. /** Gets or sets border thickness */
  63861. thickness: number;
  63862. /**
  63863. * Creates a new Ellipse
  63864. * @param name defines the control name
  63865. */
  63866. constructor(name?: string | undefined);
  63867. protected _getTypeName(): string;
  63868. protected _localDraw(context: CanvasRenderingContext2D): void;
  63869. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63870. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  63871. }
  63872. }
  63873. declare module BABYLON.GUI {
  63874. /**
  63875. * Class used to create a password control
  63876. */
  63877. export class InputPassword extends InputText {
  63878. protected _beforeRenderText(text: string): string;
  63879. }
  63880. }
  63881. declare module BABYLON.GUI {
  63882. /** Class used to render 2D lines */
  63883. export class Line extends Control {
  63884. name?: string | undefined;
  63885. private _lineWidth;
  63886. private _x1;
  63887. private _y1;
  63888. private _x2;
  63889. private _y2;
  63890. private _dash;
  63891. private _connectedControl;
  63892. private _connectedControlDirtyObserver;
  63893. /** Gets or sets the dash pattern */
  63894. dash: Array<number>;
  63895. /** Gets or sets the control connected with the line end */
  63896. connectedControl: Control;
  63897. /** Gets or sets start coordinates on X axis */
  63898. x1: string | number;
  63899. /** Gets or sets start coordinates on Y axis */
  63900. y1: string | number;
  63901. /** Gets or sets end coordinates on X axis */
  63902. x2: string | number;
  63903. /** Gets or sets end coordinates on Y axis */
  63904. y2: string | number;
  63905. /** Gets or sets line width */
  63906. lineWidth: number;
  63907. /** Gets or sets horizontal alignment */
  63908. horizontalAlignment: number;
  63909. /** Gets or sets vertical alignment */
  63910. verticalAlignment: number;
  63911. private readonly _effectiveX2;
  63912. private readonly _effectiveY2;
  63913. /**
  63914. * Creates a new Line
  63915. * @param name defines the control name
  63916. */
  63917. constructor(name?: string | undefined);
  63918. protected _getTypeName(): string;
  63919. _draw(context: CanvasRenderingContext2D): void;
  63920. _measure(): void;
  63921. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63922. /**
  63923. * Move one end of the line given 3D cartesian coordinates.
  63924. * @param position Targeted world position
  63925. * @param scene BABYLON.Scene
  63926. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  63927. */
  63928. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  63929. /**
  63930. * Move one end of the line to a position in screen absolute space.
  63931. * @param projectedPosition Position in screen absolute space (X, Y)
  63932. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  63933. */
  63934. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  63935. }
  63936. }
  63937. declare module BABYLON.GUI {
  63938. /**
  63939. * Class used to store a point for a MultiLine object.
  63940. * The point can be pure 2D coordinates, a mesh or a control
  63941. */
  63942. export class MultiLinePoint {
  63943. private _multiLine;
  63944. private _x;
  63945. private _y;
  63946. private _control;
  63947. private _mesh;
  63948. private _controlObserver;
  63949. private _meshObserver;
  63950. /** @hidden */
  63951. _point: BABYLON.Vector2;
  63952. /**
  63953. * Creates a new MultiLinePoint
  63954. * @param multiLine defines the source MultiLine object
  63955. */
  63956. constructor(multiLine: MultiLine);
  63957. /** Gets or sets x coordinate */
  63958. x: string | number;
  63959. /** Gets or sets y coordinate */
  63960. y: string | number;
  63961. /** Gets or sets the control associated with this point */
  63962. control: BABYLON.Nullable<Control>;
  63963. /** Gets or sets the mesh associated with this point */
  63964. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63965. /** Resets links */
  63966. resetLinks(): void;
  63967. /**
  63968. * Gets a translation vector
  63969. * @returns the translation vector
  63970. */
  63971. translate(): BABYLON.Vector2;
  63972. private _translatePoint;
  63973. /** Release associated resources */
  63974. dispose(): void;
  63975. }
  63976. }
  63977. declare module BABYLON.GUI {
  63978. /**
  63979. * Class used to create multi line control
  63980. */
  63981. export class MultiLine extends Control {
  63982. name?: string | undefined;
  63983. private _lineWidth;
  63984. private _dash;
  63985. private _points;
  63986. private _minX;
  63987. private _minY;
  63988. private _maxX;
  63989. private _maxY;
  63990. /**
  63991. * Creates a new MultiLine
  63992. * @param name defines the control name
  63993. */
  63994. constructor(name?: string | undefined);
  63995. /** Gets or sets dash pattern */
  63996. dash: Array<number>;
  63997. /**
  63998. * Gets point stored at specified index
  63999. * @param index defines the index to look for
  64000. * @returns the requested point if found
  64001. */
  64002. getAt(index: number): MultiLinePoint;
  64003. /** Function called when a point is updated */
  64004. onPointUpdate: () => void;
  64005. /**
  64006. * Adds new points to the point collection
  64007. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  64008. * @returns the list of created MultiLinePoint
  64009. */
  64010. add(...items: (AbstractMesh | Control | {
  64011. x: string | number;
  64012. y: string | number;
  64013. })[]): MultiLinePoint[];
  64014. /**
  64015. * Adds a new point to the point collection
  64016. * @param item defines the item (mesh, control or 2d coordiantes) to add
  64017. * @returns the created MultiLinePoint
  64018. */
  64019. push(item?: (AbstractMesh | Control | {
  64020. x: string | number;
  64021. y: string | number;
  64022. })): MultiLinePoint;
  64023. /**
  64024. * Remove a specific value or point from the active point collection
  64025. * @param value defines the value or point to remove
  64026. */
  64027. remove(value: number | MultiLinePoint): void;
  64028. /**
  64029. * Resets this object to initial state (no point)
  64030. */
  64031. reset(): void;
  64032. /**
  64033. * Resets all links
  64034. */
  64035. resetLinks(): void;
  64036. /** Gets or sets line width */
  64037. lineWidth: number;
  64038. horizontalAlignment: number;
  64039. verticalAlignment: number;
  64040. protected _getTypeName(): string;
  64041. _draw(context: CanvasRenderingContext2D): void;
  64042. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64043. _measure(): void;
  64044. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64045. dispose(): void;
  64046. }
  64047. }
  64048. declare module BABYLON.GUI {
  64049. /**
  64050. * Class used to create radio button controls
  64051. */
  64052. export class RadioButton extends Control {
  64053. name?: string | undefined;
  64054. private _isChecked;
  64055. private _background;
  64056. private _checkSizeRatio;
  64057. private _thickness;
  64058. /** Gets or sets border thickness */
  64059. thickness: number;
  64060. /** Gets or sets group name */
  64061. group: string;
  64062. /** BABYLON.Observable raised when isChecked is changed */
  64063. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  64064. /** Gets or sets a value indicating the ratio between overall size and check size */
  64065. checkSizeRatio: number;
  64066. /** Gets or sets background color */
  64067. background: string;
  64068. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  64069. isChecked: boolean;
  64070. /**
  64071. * Creates a new RadioButton
  64072. * @param name defines the control name
  64073. */
  64074. constructor(name?: string | undefined);
  64075. protected _getTypeName(): string;
  64076. _draw(context: CanvasRenderingContext2D): void;
  64077. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64078. /**
  64079. * Utility function to easily create a radio button with a header
  64080. * @param title defines the label to use for the header
  64081. * @param group defines the group to use for the radio button
  64082. * @param isChecked defines the initial state of the radio button
  64083. * @param onValueChanged defines the callback to call when value changes
  64084. * @returns a StackPanel containing the radio button and a textBlock
  64085. */
  64086. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  64087. }
  64088. }
  64089. declare module BABYLON.GUI {
  64090. /**
  64091. * Class used to create slider controls
  64092. */
  64093. export class BaseSlider extends Control {
  64094. name?: string | undefined;
  64095. protected _thumbWidth: ValueAndUnit;
  64096. private _minimum;
  64097. private _maximum;
  64098. private _value;
  64099. private _isVertical;
  64100. protected _barOffset: ValueAndUnit;
  64101. private _isThumbClamped;
  64102. protected _displayThumb: boolean;
  64103. private _step;
  64104. private _lastPointerDownID;
  64105. protected _effectiveBarOffset: number;
  64106. protected _renderLeft: number;
  64107. protected _renderTop: number;
  64108. protected _renderWidth: number;
  64109. protected _renderHeight: number;
  64110. protected _backgroundBoxLength: number;
  64111. protected _backgroundBoxThickness: number;
  64112. protected _effectiveThumbThickness: number;
  64113. /** BABYLON.Observable raised when the sldier value changes */
  64114. onValueChangedObservable: BABYLON.Observable<number>;
  64115. /** Gets or sets a boolean indicating if the thumb must be rendered */
  64116. displayThumb: boolean;
  64117. /** Gets or sets a step to apply to values (0 by default) */
  64118. step: number;
  64119. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  64120. barOffset: string | number;
  64121. /** Gets main bar offset in pixels*/
  64122. readonly barOffsetInPixels: number;
  64123. /** Gets or sets thumb width */
  64124. thumbWidth: string | number;
  64125. /** Gets thumb width in pixels */
  64126. readonly thumbWidthInPixels: number;
  64127. /** Gets or sets minimum value */
  64128. minimum: number;
  64129. /** Gets or sets maximum value */
  64130. maximum: number;
  64131. /** Gets or sets current value */
  64132. value: number;
  64133. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  64134. isVertical: boolean;
  64135. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  64136. isThumbClamped: boolean;
  64137. /**
  64138. * Creates a new BaseSlider
  64139. * @param name defines the control name
  64140. */
  64141. constructor(name?: string | undefined);
  64142. protected _getTypeName(): string;
  64143. protected _getThumbPosition(): number;
  64144. protected _getThumbThickness(type: string): number;
  64145. protected _prepareRenderingData(type: string): void;
  64146. private _pointerIsDown;
  64147. /** @hidden */
  64148. protected _updateValueFromPointer(x: number, y: number): void;
  64149. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64150. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64151. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64152. }
  64153. }
  64154. declare module BABYLON.GUI {
  64155. /**
  64156. * Class used to create slider controls
  64157. */
  64158. export class Slider extends BaseSlider {
  64159. name?: string | undefined;
  64160. private _background;
  64161. private _borderColor;
  64162. private _isThumbCircle;
  64163. protected _displayValueBar: boolean;
  64164. /** Gets or sets a boolean indicating if the value bar must be rendered */
  64165. displayValueBar: boolean;
  64166. /** Gets or sets border color */
  64167. borderColor: string;
  64168. /** Gets or sets background color */
  64169. background: string;
  64170. /** Gets or sets a boolean indicating if the thumb should be round or square */
  64171. isThumbCircle: boolean;
  64172. /**
  64173. * Creates a new Slider
  64174. * @param name defines the control name
  64175. */
  64176. constructor(name?: string | undefined);
  64177. protected _getTypeName(): string;
  64178. _draw(context: CanvasRenderingContext2D): void;
  64179. }
  64180. }
  64181. declare module BABYLON.GUI {
  64182. /** Class used to create a RadioGroup
  64183. * which contains groups of radio buttons
  64184. */
  64185. export class SelectorGroup {
  64186. /** name of SelectorGroup */
  64187. name: string;
  64188. private _groupPanel;
  64189. private _selectors;
  64190. private _groupHeader;
  64191. /**
  64192. * Creates a new SelectorGroup
  64193. * @param name of group, used as a group heading
  64194. */
  64195. constructor(
  64196. /** name of SelectorGroup */
  64197. name: string);
  64198. /** Gets the groupPanel of the SelectorGroup */
  64199. readonly groupPanel: StackPanel;
  64200. /** Gets the selectors array */
  64201. readonly selectors: StackPanel[];
  64202. /** Gets and sets the group header */
  64203. header: string;
  64204. /** @hidden */
  64205. private _addGroupHeader;
  64206. /** @hidden*/
  64207. _getSelector(selectorNb: number): StackPanel | undefined;
  64208. /** Removes the selector at the given position
  64209. * @param selectorNb the position of the selector within the group
  64210. */
  64211. removeSelector(selectorNb: number): void;
  64212. }
  64213. /** Class used to create a CheckboxGroup
  64214. * which contains groups of checkbox buttons
  64215. */
  64216. export class CheckboxGroup extends SelectorGroup {
  64217. /** Adds a checkbox as a control
  64218. * @param text is the label for the selector
  64219. * @param func is the function called when the Selector is checked
  64220. * @param checked is true when Selector is checked
  64221. */
  64222. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  64223. /** @hidden */
  64224. _setSelectorLabel(selectorNb: number, label: string): void;
  64225. /** @hidden */
  64226. _setSelectorLabelColor(selectorNb: number, color: string): void;
  64227. /** @hidden */
  64228. _setSelectorButtonColor(selectorNb: number, color: string): void;
  64229. /** @hidden */
  64230. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  64231. }
  64232. /** Class used to create a RadioGroup
  64233. * which contains groups of radio buttons
  64234. */
  64235. export class RadioGroup extends SelectorGroup {
  64236. private _selectNb;
  64237. /** Adds a radio button as a control
  64238. * @param label is the label for the selector
  64239. * @param func is the function called when the Selector is checked
  64240. * @param checked is true when Selector is checked
  64241. */
  64242. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  64243. /** @hidden */
  64244. _setSelectorLabel(selectorNb: number, label: string): void;
  64245. /** @hidden */
  64246. _setSelectorLabelColor(selectorNb: number, color: string): void;
  64247. /** @hidden */
  64248. _setSelectorButtonColor(selectorNb: number, color: string): void;
  64249. /** @hidden */
  64250. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  64251. }
  64252. /** Class used to create a SliderGroup
  64253. * which contains groups of slider buttons
  64254. */
  64255. export class SliderGroup extends SelectorGroup {
  64256. /**
  64257. * Adds a slider to the SelectorGroup
  64258. * @param label is the label for the SliderBar
  64259. * @param func is the function called when the Slider moves
  64260. * @param unit is a string describing the units used, eg degrees or metres
  64261. * @param min is the minimum value for the Slider
  64262. * @param max is the maximum value for the Slider
  64263. * @param value is the start value for the Slider between min and max
  64264. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  64265. */
  64266. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  64267. /** @hidden */
  64268. _setSelectorLabel(selectorNb: number, label: string): void;
  64269. /** @hidden */
  64270. _setSelectorLabelColor(selectorNb: number, color: string): void;
  64271. /** @hidden */
  64272. _setSelectorButtonColor(selectorNb: number, color: string): void;
  64273. /** @hidden */
  64274. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  64275. }
  64276. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  64277. * @see http://doc.babylonjs.com/how_to/selector
  64278. */
  64279. export class SelectionPanel extends Rectangle {
  64280. /** name of SelectionPanel */
  64281. name: string;
  64282. /** an array of SelectionGroups */
  64283. groups: SelectorGroup[];
  64284. private _panel;
  64285. private _buttonColor;
  64286. private _buttonBackground;
  64287. private _headerColor;
  64288. private _barColor;
  64289. private _barHeight;
  64290. private _spacerHeight;
  64291. private _labelColor;
  64292. private _groups;
  64293. private _bars;
  64294. /**
  64295. * Creates a new SelectionPanel
  64296. * @param name of SelectionPanel
  64297. * @param groups is an array of SelectionGroups
  64298. */
  64299. constructor(
  64300. /** name of SelectionPanel */
  64301. name: string,
  64302. /** an array of SelectionGroups */
  64303. groups?: SelectorGroup[]);
  64304. protected _getTypeName(): string;
  64305. /** Gets or sets the headerColor */
  64306. headerColor: string;
  64307. private _setHeaderColor;
  64308. /** Gets or sets the button color */
  64309. buttonColor: string;
  64310. private _setbuttonColor;
  64311. /** Gets or sets the label color */
  64312. labelColor: string;
  64313. private _setLabelColor;
  64314. /** Gets or sets the button background */
  64315. buttonBackground: string;
  64316. private _setButtonBackground;
  64317. /** Gets or sets the color of separator bar */
  64318. barColor: string;
  64319. private _setBarColor;
  64320. /** Gets or sets the height of separator bar */
  64321. barHeight: string;
  64322. private _setBarHeight;
  64323. /** Gets or sets the height of spacers*/
  64324. spacerHeight: string;
  64325. private _setSpacerHeight;
  64326. /** Adds a bar between groups */
  64327. private _addSpacer;
  64328. /** Add a group to the selection panel
  64329. * @param group is the selector group to add
  64330. */
  64331. addGroup(group: SelectorGroup): void;
  64332. /** Remove the group from the given position
  64333. * @param groupNb is the position of the group in the list
  64334. */
  64335. removeGroup(groupNb: number): void;
  64336. /** Change a group header label
  64337. * @param label is the new group header label
  64338. * @param groupNb is the number of the group to relabel
  64339. * */
  64340. setHeaderName(label: string, groupNb: number): void;
  64341. /** Change selector label to the one given
  64342. * @param label is the new selector label
  64343. * @param groupNb is the number of the groupcontaining the selector
  64344. * @param selectorNb is the number of the selector within a group to relabel
  64345. * */
  64346. relabel(label: string, groupNb: number, selectorNb: number): void;
  64347. /** For a given group position remove the selector at the given position
  64348. * @param groupNb is the number of the group to remove the selector from
  64349. * @param selectorNb is the number of the selector within the group
  64350. */
  64351. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  64352. /** For a given group position of correct type add a checkbox button
  64353. * @param groupNb is the number of the group to remove the selector from
  64354. * @param label is the label for the selector
  64355. * @param func is the function called when the Selector is checked
  64356. * @param checked is true when Selector is checked
  64357. */
  64358. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  64359. /** For a given group position of correct type add a radio button
  64360. * @param groupNb is the number of the group to remove the selector from
  64361. * @param label is the label for the selector
  64362. * @param func is the function called when the Selector is checked
  64363. * @param checked is true when Selector is checked
  64364. */
  64365. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  64366. /**
  64367. * For a given slider group add a slider
  64368. * @param groupNb is the number of the group to add the slider to
  64369. * @param label is the label for the Slider
  64370. * @param func is the function called when the Slider moves
  64371. * @param unit is a string describing the units used, eg degrees or metres
  64372. * @param min is the minimum value for the Slider
  64373. * @param max is the maximum value for the Slider
  64374. * @param value is the start value for the Slider between min and max
  64375. * @param onVal is the function used to format the value displayed, eg radians to degrees
  64376. */
  64377. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  64378. }
  64379. }
  64380. declare module BABYLON.GUI {
  64381. /**
  64382. * Class used to hold a the container for ScrollViewer
  64383. * @hidden
  64384. */
  64385. export class _ScrollViewerWindow extends Container {
  64386. parentClientWidth: number;
  64387. parentClientHeight: number;
  64388. /**
  64389. * Creates a new ScrollViewerWindow
  64390. * @param name of ScrollViewerWindow
  64391. */
  64392. constructor(name?: string);
  64393. protected _getTypeName(): string;
  64394. /** @hidden */
  64395. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64396. protected _postMeasure(): void;
  64397. }
  64398. }
  64399. declare module BABYLON.GUI {
  64400. /**
  64401. * Class used to create slider controls
  64402. */
  64403. export class ScrollBar extends BaseSlider {
  64404. name?: string | undefined;
  64405. private _background;
  64406. private _borderColor;
  64407. private _thumbMeasure;
  64408. /** Gets or sets border color */
  64409. borderColor: string;
  64410. /** Gets or sets background color */
  64411. background: string;
  64412. /**
  64413. * Creates a new Slider
  64414. * @param name defines the control name
  64415. */
  64416. constructor(name?: string | undefined);
  64417. protected _getTypeName(): string;
  64418. protected _getThumbThickness(): number;
  64419. _draw(context: CanvasRenderingContext2D): void;
  64420. private _first;
  64421. private _originX;
  64422. private _originY;
  64423. /** @hidden */
  64424. protected _updateValueFromPointer(x: number, y: number): void;
  64425. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64426. }
  64427. }
  64428. declare module BABYLON.GUI {
  64429. /**
  64430. * Class used to hold a viewer window and sliders in a grid
  64431. */
  64432. export class ScrollViewer extends Rectangle {
  64433. private _grid;
  64434. private _horizontalBarSpace;
  64435. private _verticalBarSpace;
  64436. private _dragSpace;
  64437. private _horizontalBar;
  64438. private _verticalBar;
  64439. private _barColor;
  64440. private _barBackground;
  64441. private _barSize;
  64442. private _endLeft;
  64443. private _endTop;
  64444. private _window;
  64445. private _pointerIsOver;
  64446. private _wheelPrecision;
  64447. private _onPointerObserver;
  64448. private _clientWidth;
  64449. private _clientHeight;
  64450. /**
  64451. * Gets the horizontal scrollbar
  64452. */
  64453. readonly horizontalBar: ScrollBar;
  64454. /**
  64455. * Gets the vertical scrollbar
  64456. */
  64457. readonly verticalBar: ScrollBar;
  64458. /**
  64459. * Adds a new control to the current container
  64460. * @param control defines the control to add
  64461. * @returns the current container
  64462. */
  64463. addControl(control: BABYLON.Nullable<Control>): Container;
  64464. /**
  64465. * Removes a control from the current container
  64466. * @param control defines the control to remove
  64467. * @returns the current container
  64468. */
  64469. removeControl(control: Control): Container;
  64470. /** Gets the list of children */
  64471. readonly children: Control[];
  64472. _flagDescendantsAsMatrixDirty(): void;
  64473. /**
  64474. * Creates a new ScrollViewer
  64475. * @param name of ScrollViewer
  64476. */
  64477. constructor(name?: string);
  64478. /** Reset the scroll viewer window to initial size */
  64479. resetWindow(): void;
  64480. protected _getTypeName(): string;
  64481. private _buildClientSizes;
  64482. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64483. protected _postMeasure(): void;
  64484. /**
  64485. * Gets or sets the mouse wheel precision
  64486. * from 0 to 1 with a default value of 0.05
  64487. * */
  64488. wheelPrecision: number;
  64489. /** Gets or sets the bar color */
  64490. barColor: string;
  64491. /** Gets or sets the size of the bar */
  64492. barSize: number;
  64493. /** Gets or sets the bar background */
  64494. barBackground: string;
  64495. /** @hidden */
  64496. private _updateScroller;
  64497. _link(host: AdvancedDynamicTexture): void;
  64498. /** @hidden */
  64499. private _attachWheel;
  64500. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64501. /** Releases associated resources */
  64502. dispose(): void;
  64503. }
  64504. }
  64505. declare module BABYLON.GUI {
  64506. /** Class used to render a grid */
  64507. export class DisplayGrid extends Control {
  64508. name?: string | undefined;
  64509. private _cellWidth;
  64510. private _cellHeight;
  64511. private _minorLineTickness;
  64512. private _minorLineColor;
  64513. private _majorLineTickness;
  64514. private _majorLineColor;
  64515. private _majorLineFrequency;
  64516. private _background;
  64517. private _displayMajorLines;
  64518. private _displayMinorLines;
  64519. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  64520. displayMinorLines: boolean;
  64521. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  64522. displayMajorLines: boolean;
  64523. /** Gets or sets background color (Black by default) */
  64524. background: string;
  64525. /** Gets or sets the width of each cell (20 by default) */
  64526. cellWidth: number;
  64527. /** Gets or sets the height of each cell (20 by default) */
  64528. cellHeight: number;
  64529. /** Gets or sets the tickness of minor lines (1 by default) */
  64530. minorLineTickness: number;
  64531. /** Gets or sets the color of minor lines (DarkGray by default) */
  64532. minorLineColor: string;
  64533. /** Gets or sets the tickness of major lines (2 by default) */
  64534. majorLineTickness: number;
  64535. /** Gets or sets the color of major lines (White by default) */
  64536. majorLineColor: string;
  64537. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  64538. majorLineFrequency: number;
  64539. /**
  64540. * Creates a new GridDisplayRectangle
  64541. * @param name defines the control name
  64542. */
  64543. constructor(name?: string | undefined);
  64544. _draw(context: CanvasRenderingContext2D): void;
  64545. protected _getTypeName(): string;
  64546. }
  64547. }
  64548. declare module BABYLON.GUI {
  64549. /**
  64550. * Class used to create slider controls based on images
  64551. */
  64552. export class ImageBasedSlider extends BaseSlider {
  64553. name?: string | undefined;
  64554. private _backgroundImage;
  64555. private _thumbImage;
  64556. private _valueBarImage;
  64557. private _tempMeasure;
  64558. displayThumb: boolean;
  64559. /**
  64560. * Gets or sets the image used to render the background
  64561. */
  64562. backgroundImage: Image;
  64563. /**
  64564. * Gets or sets the image used to render the value bar
  64565. */
  64566. valueBarImage: Image;
  64567. /**
  64568. * Gets or sets the image used to render the thumb
  64569. */
  64570. thumbImage: Image;
  64571. /**
  64572. * Creates a new ImageBasedSlider
  64573. * @param name defines the control name
  64574. */
  64575. constructor(name?: string | undefined);
  64576. protected _getTypeName(): string;
  64577. _draw(context: CanvasRenderingContext2D): void;
  64578. }
  64579. }
  64580. declare module BABYLON.GUI {
  64581. /**
  64582. * Forcing an export so that this code will execute
  64583. * @hidden
  64584. */
  64585. const name = "Statics";
  64586. }
  64587. declare module BABYLON.GUI {
  64588. /**
  64589. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  64590. */
  64591. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  64592. /**
  64593. * Define the instrumented AdvancedDynamicTexture.
  64594. */
  64595. texture: AdvancedDynamicTexture;
  64596. private _captureRenderTime;
  64597. private _renderTime;
  64598. private _captureLayoutTime;
  64599. private _layoutTime;
  64600. private _onBeginRenderObserver;
  64601. private _onEndRenderObserver;
  64602. private _onBeginLayoutObserver;
  64603. private _onEndLayoutObserver;
  64604. /**
  64605. * Gets the perf counter used to capture render time
  64606. */
  64607. readonly renderTimeCounter: BABYLON.PerfCounter;
  64608. /**
  64609. * Gets the perf counter used to capture layout time
  64610. */
  64611. readonly layoutTimeCounter: BABYLON.PerfCounter;
  64612. /**
  64613. * Enable or disable the render time capture
  64614. */
  64615. captureRenderTime: boolean;
  64616. /**
  64617. * Enable or disable the layout time capture
  64618. */
  64619. captureLayoutTime: boolean;
  64620. /**
  64621. * Instantiates a new advanced dynamic texture instrumentation.
  64622. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  64623. * @param texture Defines the AdvancedDynamicTexture to instrument
  64624. */
  64625. constructor(
  64626. /**
  64627. * Define the instrumented AdvancedDynamicTexture.
  64628. */
  64629. texture: AdvancedDynamicTexture);
  64630. /**
  64631. * Dispose and release associated resources.
  64632. */
  64633. dispose(): void;
  64634. }
  64635. }
  64636. declare module BABYLON.GUI {
  64637. /**
  64638. * Class used to create containers for controls
  64639. */
  64640. export class Container3D extends Control3D {
  64641. private _blockLayout;
  64642. /**
  64643. * Gets the list of child controls
  64644. */
  64645. protected _children: Control3D[];
  64646. /**
  64647. * Gets the list of child controls
  64648. */
  64649. readonly children: Array<Control3D>;
  64650. /**
  64651. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  64652. * This is helpful to optimize layout operation when adding multiple children in a row
  64653. */
  64654. blockLayout: boolean;
  64655. /**
  64656. * Creates a new container
  64657. * @param name defines the container name
  64658. */
  64659. constructor(name?: string);
  64660. /**
  64661. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  64662. * @returns the current container
  64663. */
  64664. updateLayout(): Container3D;
  64665. /**
  64666. * Gets a boolean indicating if the given control is in the children of this control
  64667. * @param control defines the control to check
  64668. * @returns true if the control is in the child list
  64669. */
  64670. containsControl(control: Control3D): boolean;
  64671. /**
  64672. * Adds a control to the children of this control
  64673. * @param control defines the control to add
  64674. * @returns the current container
  64675. */
  64676. addControl(control: Control3D): Container3D;
  64677. /**
  64678. * This function will be called everytime a new control is added
  64679. */
  64680. protected _arrangeChildren(): void;
  64681. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  64682. /**
  64683. * Removes a control from the children of this control
  64684. * @param control defines the control to remove
  64685. * @returns the current container
  64686. */
  64687. removeControl(control: Control3D): Container3D;
  64688. protected _getTypeName(): string;
  64689. /**
  64690. * Releases all associated resources
  64691. */
  64692. dispose(): void;
  64693. /** Control rotation will remain unchanged */
  64694. static readonly UNSET_ORIENTATION: number;
  64695. /** Control will rotate to make it look at sphere central axis */
  64696. static readonly FACEORIGIN_ORIENTATION: number;
  64697. /** Control will rotate to make it look back at sphere central axis */
  64698. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  64699. /** Control will rotate to look at z axis (0, 0, 1) */
  64700. static readonly FACEFORWARD_ORIENTATION: number;
  64701. /** Control will rotate to look at negative z axis (0, 0, -1) */
  64702. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  64703. }
  64704. }
  64705. declare module BABYLON.GUI {
  64706. /**
  64707. * Class used to manage 3D user interface
  64708. * @see http://doc.babylonjs.com/how_to/gui3d
  64709. */
  64710. export class GUI3DManager implements BABYLON.IDisposable {
  64711. private _scene;
  64712. private _sceneDisposeObserver;
  64713. private _utilityLayer;
  64714. private _rootContainer;
  64715. private _pointerObserver;
  64716. private _pointerOutObserver;
  64717. /** @hidden */
  64718. _lastPickedControl: Control3D;
  64719. /** @hidden */
  64720. _lastControlOver: {
  64721. [pointerId: number]: Control3D;
  64722. };
  64723. /** @hidden */
  64724. _lastControlDown: {
  64725. [pointerId: number]: Control3D;
  64726. };
  64727. /**
  64728. * BABYLON.Observable raised when the point picked by the pointer events changed
  64729. */
  64730. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  64731. /** @hidden */
  64732. _sharedMaterials: {
  64733. [key: string]: BABYLON.Material;
  64734. };
  64735. /** Gets the hosting scene */
  64736. readonly scene: BABYLON.Scene;
  64737. /** Gets associated utility layer */
  64738. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  64739. /**
  64740. * Creates a new GUI3DManager
  64741. * @param scene
  64742. */
  64743. constructor(scene?: BABYLON.Scene);
  64744. private _handlePointerOut;
  64745. private _doPicking;
  64746. /**
  64747. * Gets the root container
  64748. */
  64749. readonly rootContainer: Container3D;
  64750. /**
  64751. * Gets a boolean indicating if the given control is in the root child list
  64752. * @param control defines the control to check
  64753. * @returns true if the control is in the root child list
  64754. */
  64755. containsControl(control: Control3D): boolean;
  64756. /**
  64757. * Adds a control to the root child list
  64758. * @param control defines the control to add
  64759. * @returns the current manager
  64760. */
  64761. addControl(control: Control3D): GUI3DManager;
  64762. /**
  64763. * Removes a control from the root child list
  64764. * @param control defines the control to remove
  64765. * @returns the current container
  64766. */
  64767. removeControl(control: Control3D): GUI3DManager;
  64768. /**
  64769. * Releases all associated resources
  64770. */
  64771. dispose(): void;
  64772. }
  64773. }
  64774. declare module BABYLON.GUI {
  64775. /**
  64776. * Class used to transport BABYLON.Vector3 information for pointer events
  64777. */
  64778. export class Vector3WithInfo extends BABYLON.Vector3 {
  64779. /** defines the current mouse button index */
  64780. buttonIndex: number;
  64781. /**
  64782. * Creates a new Vector3WithInfo
  64783. * @param source defines the vector3 data to transport
  64784. * @param buttonIndex defines the current mouse button index
  64785. */
  64786. constructor(source: BABYLON.Vector3,
  64787. /** defines the current mouse button index */
  64788. buttonIndex?: number);
  64789. }
  64790. }
  64791. declare module BABYLON.GUI {
  64792. /**
  64793. * Class used as base class for controls
  64794. */
  64795. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  64796. /** Defines the control name */
  64797. name?: string | undefined;
  64798. /** @hidden */
  64799. _host: GUI3DManager;
  64800. private _node;
  64801. private _downCount;
  64802. private _enterCount;
  64803. private _downPointerIds;
  64804. private _isVisible;
  64805. /** Gets or sets the control position in world space */
  64806. position: BABYLON.Vector3;
  64807. /** Gets or sets the control scaling in world space */
  64808. scaling: BABYLON.Vector3;
  64809. /** Callback used to start pointer enter animation */
  64810. pointerEnterAnimation: () => void;
  64811. /** Callback used to start pointer out animation */
  64812. pointerOutAnimation: () => void;
  64813. /** Callback used to start pointer down animation */
  64814. pointerDownAnimation: () => void;
  64815. /** Callback used to start pointer up animation */
  64816. pointerUpAnimation: () => void;
  64817. /**
  64818. * An event triggered when the pointer move over the control
  64819. */
  64820. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  64821. /**
  64822. * An event triggered when the pointer move out of the control
  64823. */
  64824. onPointerOutObservable: BABYLON.Observable<Control3D>;
  64825. /**
  64826. * An event triggered when the pointer taps the control
  64827. */
  64828. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  64829. /**
  64830. * An event triggered when pointer is up
  64831. */
  64832. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  64833. /**
  64834. * An event triggered when a control is clicked on (with a mouse)
  64835. */
  64836. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  64837. /**
  64838. * An event triggered when pointer enters the control
  64839. */
  64840. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  64841. /**
  64842. * Gets or sets the parent container
  64843. */
  64844. parent: BABYLON.Nullable<Container3D>;
  64845. private _behaviors;
  64846. /**
  64847. * Gets the list of attached behaviors
  64848. * @see http://doc.babylonjs.com/features/behaviour
  64849. */
  64850. readonly behaviors: BABYLON.Behavior<Control3D>[];
  64851. /**
  64852. * Attach a behavior to the control
  64853. * @see http://doc.babylonjs.com/features/behaviour
  64854. * @param behavior defines the behavior to attach
  64855. * @returns the current control
  64856. */
  64857. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  64858. /**
  64859. * Remove an attached behavior
  64860. * @see http://doc.babylonjs.com/features/behaviour
  64861. * @param behavior defines the behavior to attach
  64862. * @returns the current control
  64863. */
  64864. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  64865. /**
  64866. * Gets an attached behavior by name
  64867. * @param name defines the name of the behavior to look for
  64868. * @see http://doc.babylonjs.com/features/behaviour
  64869. * @returns null if behavior was not found else the requested behavior
  64870. */
  64871. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  64872. /** Gets or sets a boolean indicating if the control is visible */
  64873. isVisible: boolean;
  64874. /**
  64875. * Creates a new control
  64876. * @param name defines the control name
  64877. */
  64878. constructor(
  64879. /** Defines the control name */
  64880. name?: string | undefined);
  64881. /**
  64882. * Gets a string representing the class name
  64883. */
  64884. readonly typeName: string;
  64885. /**
  64886. * Get the current class name of the control.
  64887. * @returns current class name
  64888. */
  64889. getClassName(): string;
  64890. protected _getTypeName(): string;
  64891. /**
  64892. * Gets the transform node used by this control
  64893. */
  64894. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  64895. /**
  64896. * Gets the mesh used to render this control
  64897. */
  64898. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64899. /**
  64900. * Link the control as child of the given node
  64901. * @param node defines the node to link to. Use null to unlink the control
  64902. * @returns the current control
  64903. */
  64904. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  64905. /** @hidden **/
  64906. _prepareNode(scene: BABYLON.Scene): void;
  64907. /**
  64908. * Node creation.
  64909. * Can be overriden by children
  64910. * @param scene defines the scene where the node must be attached
  64911. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  64912. */
  64913. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  64914. /**
  64915. * Affect a material to the given mesh
  64916. * @param mesh defines the mesh which will represent the control
  64917. */
  64918. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  64919. /** @hidden */
  64920. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  64921. /** @hidden */
  64922. _onPointerEnter(target: Control3D): boolean;
  64923. /** @hidden */
  64924. _onPointerOut(target: Control3D): void;
  64925. /** @hidden */
  64926. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  64927. /** @hidden */
  64928. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64929. /** @hidden */
  64930. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  64931. /** @hidden */
  64932. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  64933. /** @hidden */
  64934. _disposeNode(): void;
  64935. /**
  64936. * Releases all associated resources
  64937. */
  64938. dispose(): void;
  64939. }
  64940. }
  64941. declare module BABYLON.GUI {
  64942. /**
  64943. * Class used as a root to all buttons
  64944. */
  64945. export class AbstractButton3D extends Control3D {
  64946. /**
  64947. * Creates a new button
  64948. * @param name defines the control name
  64949. */
  64950. constructor(name?: string);
  64951. protected _getTypeName(): string;
  64952. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  64953. }
  64954. }
  64955. declare module BABYLON.GUI {
  64956. /**
  64957. * Class used to create a button in 3D
  64958. */
  64959. export class Button3D extends AbstractButton3D {
  64960. /** @hidden */
  64961. protected _currentMaterial: BABYLON.Material;
  64962. private _facadeTexture;
  64963. private _content;
  64964. private _contentResolution;
  64965. private _contentScaleRatio;
  64966. /**
  64967. * Gets or sets the texture resolution used to render content (512 by default)
  64968. */
  64969. contentResolution: BABYLON.int;
  64970. /**
  64971. * Gets or sets the texture scale ratio used to render content (2 by default)
  64972. */
  64973. contentScaleRatio: number;
  64974. protected _disposeFacadeTexture(): void;
  64975. protected _resetContent(): void;
  64976. /**
  64977. * Creates a new button
  64978. * @param name defines the control name
  64979. */
  64980. constructor(name?: string);
  64981. /**
  64982. * Gets or sets the GUI 2D content used to display the button's facade
  64983. */
  64984. content: Control;
  64985. /**
  64986. * Apply the facade texture (created from the content property).
  64987. * This function can be overloaded by child classes
  64988. * @param facadeTexture defines the AdvancedDynamicTexture to use
  64989. */
  64990. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  64991. protected _getTypeName(): string;
  64992. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  64993. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  64994. /**
  64995. * Releases all associated resources
  64996. */
  64997. dispose(): void;
  64998. }
  64999. }
  65000. declare module BABYLON.GUI {
  65001. /**
  65002. * Abstract class used to create a container panel deployed on the surface of a volume
  65003. */
  65004. export abstract class VolumeBasedPanel extends Container3D {
  65005. private _columns;
  65006. private _rows;
  65007. private _rowThenColum;
  65008. private _orientation;
  65009. protected _cellWidth: number;
  65010. protected _cellHeight: number;
  65011. /**
  65012. * Gets or sets the distance between elements
  65013. */
  65014. margin: number;
  65015. /**
  65016. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  65017. * | Value | Type | Description |
  65018. * | ----- | ----------------------------------- | ----------- |
  65019. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  65020. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  65021. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  65022. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  65023. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  65024. */
  65025. orientation: number;
  65026. /**
  65027. * Gets or sets the number of columns requested (10 by default).
  65028. * The panel will automatically compute the number of rows based on number of child controls.
  65029. */
  65030. columns: BABYLON.int;
  65031. /**
  65032. * Gets or sets a the number of rows requested.
  65033. * The panel will automatically compute the number of columns based on number of child controls.
  65034. */
  65035. rows: BABYLON.int;
  65036. /**
  65037. * Creates new VolumeBasedPanel
  65038. */
  65039. constructor();
  65040. protected _arrangeChildren(): void;
  65041. /** Child classes must implement this function to provide correct control positioning */
  65042. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65043. /** Child classes can implement this function to provide additional processing */
  65044. protected _finalProcessing(): void;
  65045. }
  65046. }
  65047. declare module BABYLON.GUI {
  65048. /**
  65049. * Class used to create a container panel deployed on the surface of a cylinder
  65050. */
  65051. export class CylinderPanel extends VolumeBasedPanel {
  65052. private _radius;
  65053. /**
  65054. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  65055. */
  65056. radius: BABYLON.float;
  65057. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65058. private _cylindricalMapping;
  65059. }
  65060. }
  65061. declare module BABYLON.GUI {
  65062. /** @hidden */
  65063. export var fluentVertexShader: {
  65064. name: string;
  65065. shader: string;
  65066. };
  65067. }
  65068. declare module BABYLON.GUI {
  65069. /** @hidden */
  65070. export var fluentPixelShader: {
  65071. name: string;
  65072. shader: string;
  65073. };
  65074. }
  65075. declare module BABYLON.GUI {
  65076. /** @hidden */
  65077. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  65078. INNERGLOW: boolean;
  65079. BORDER: boolean;
  65080. HOVERLIGHT: boolean;
  65081. TEXTURE: boolean;
  65082. constructor();
  65083. }
  65084. /**
  65085. * Class used to render controls with fluent desgin
  65086. */
  65087. export class FluentMaterial extends BABYLON.PushMaterial {
  65088. /**
  65089. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  65090. */
  65091. innerGlowColorIntensity: number;
  65092. /**
  65093. * Gets or sets the inner glow color (white by default)
  65094. */
  65095. innerGlowColor: BABYLON.Color3;
  65096. /**
  65097. * Gets or sets alpha value (default is 1.0)
  65098. */
  65099. alpha: number;
  65100. /**
  65101. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  65102. */
  65103. albedoColor: BABYLON.Color3;
  65104. /**
  65105. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  65106. */
  65107. renderBorders: boolean;
  65108. /**
  65109. * Gets or sets border width (default is 0.5)
  65110. */
  65111. borderWidth: number;
  65112. /**
  65113. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  65114. */
  65115. edgeSmoothingValue: number;
  65116. /**
  65117. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  65118. */
  65119. borderMinValue: number;
  65120. /**
  65121. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  65122. */
  65123. renderHoverLight: boolean;
  65124. /**
  65125. * Gets or sets the radius used to render the hover light (default is 1.0)
  65126. */
  65127. hoverRadius: number;
  65128. /**
  65129. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  65130. */
  65131. hoverColor: BABYLON.Color4;
  65132. /**
  65133. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  65134. */
  65135. hoverPosition: BABYLON.Vector3;
  65136. private _albedoTexture;
  65137. /** Gets or sets the texture to use for albedo color */
  65138. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  65139. /**
  65140. * Creates a new Fluent material
  65141. * @param name defines the name of the material
  65142. * @param scene defines the hosting scene
  65143. */
  65144. constructor(name: string, scene: BABYLON.Scene);
  65145. needAlphaBlending(): boolean;
  65146. needAlphaTesting(): boolean;
  65147. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  65148. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  65149. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  65150. getActiveTextures(): BABYLON.BaseTexture[];
  65151. hasTexture(texture: BABYLON.BaseTexture): boolean;
  65152. dispose(forceDisposeEffect?: boolean): void;
  65153. clone(name: string): FluentMaterial;
  65154. serialize(): any;
  65155. getClassName(): string;
  65156. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  65157. }
  65158. }
  65159. declare module BABYLON.GUI {
  65160. /**
  65161. * Class used to create a holographic button in 3D
  65162. */
  65163. export class HolographicButton extends Button3D {
  65164. private _backPlate;
  65165. private _textPlate;
  65166. private _frontPlate;
  65167. private _text;
  65168. private _imageUrl;
  65169. private _shareMaterials;
  65170. private _frontMaterial;
  65171. private _backMaterial;
  65172. private _plateMaterial;
  65173. private _pickedPointObserver;
  65174. private _tooltipFade;
  65175. private _tooltipTextBlock;
  65176. private _tooltipTexture;
  65177. private _tooltipMesh;
  65178. private _tooltipHoverObserver;
  65179. private _tooltipOutObserver;
  65180. private _disposeTooltip;
  65181. /**
  65182. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  65183. */
  65184. tooltipText: BABYLON.Nullable<string>;
  65185. /**
  65186. * Gets or sets text for the button
  65187. */
  65188. text: string;
  65189. /**
  65190. * Gets or sets the image url for the button
  65191. */
  65192. imageUrl: string;
  65193. /**
  65194. * Gets the back material used by this button
  65195. */
  65196. readonly backMaterial: FluentMaterial;
  65197. /**
  65198. * Gets the front material used by this button
  65199. */
  65200. readonly frontMaterial: FluentMaterial;
  65201. /**
  65202. * Gets the plate material used by this button
  65203. */
  65204. readonly plateMaterial: BABYLON.StandardMaterial;
  65205. /**
  65206. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  65207. */
  65208. readonly shareMaterials: boolean;
  65209. /**
  65210. * Creates a new button
  65211. * @param name defines the control name
  65212. */
  65213. constructor(name?: string, shareMaterials?: boolean);
  65214. protected _getTypeName(): string;
  65215. private _rebuildContent;
  65216. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65217. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  65218. private _createBackMaterial;
  65219. private _createFrontMaterial;
  65220. private _createPlateMaterial;
  65221. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  65222. /**
  65223. * Releases all associated resources
  65224. */
  65225. dispose(): void;
  65226. }
  65227. }
  65228. declare module BABYLON.GUI {
  65229. /**
  65230. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  65231. */
  65232. export class MeshButton3D extends Button3D {
  65233. /** @hidden */
  65234. protected _currentMesh: BABYLON.Mesh;
  65235. /**
  65236. * Creates a new 3D button based on a mesh
  65237. * @param mesh mesh to become a 3D button
  65238. * @param name defines the control name
  65239. */
  65240. constructor(mesh: BABYLON.Mesh, name?: string);
  65241. protected _getTypeName(): string;
  65242. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65243. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  65244. }
  65245. }
  65246. declare module BABYLON.GUI {
  65247. /**
  65248. * Class used to create a container panel deployed on the surface of a plane
  65249. */
  65250. export class PlanePanel extends VolumeBasedPanel {
  65251. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65252. }
  65253. }
  65254. declare module BABYLON.GUI {
  65255. /**
  65256. * Class used to create a container panel where items get randomized planar mapping
  65257. */
  65258. export class ScatterPanel extends VolumeBasedPanel {
  65259. private _iteration;
  65260. /**
  65261. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  65262. */
  65263. iteration: BABYLON.float;
  65264. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65265. private _scatterMapping;
  65266. protected _finalProcessing(): void;
  65267. }
  65268. }
  65269. declare module BABYLON.GUI {
  65270. /**
  65271. * Class used to create a container panel deployed on the surface of a sphere
  65272. */
  65273. export class SpherePanel extends VolumeBasedPanel {
  65274. private _radius;
  65275. /**
  65276. * Gets or sets the radius of the sphere where to project controls (5 by default)
  65277. */
  65278. radius: BABYLON.float;
  65279. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65280. private _sphericalMapping;
  65281. }
  65282. }
  65283. declare module BABYLON.GUI {
  65284. /**
  65285. * Class used to create a stack panel in 3D on XY plane
  65286. */
  65287. export class StackPanel3D extends Container3D {
  65288. private _isVertical;
  65289. /**
  65290. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  65291. */
  65292. isVertical: boolean;
  65293. /**
  65294. * Gets or sets the distance between elements
  65295. */
  65296. margin: number;
  65297. /**
  65298. * Creates new StackPanel
  65299. * @param isVertical
  65300. */
  65301. constructor(isVertical?: boolean);
  65302. protected _arrangeChildren(): void;
  65303. }
  65304. }
  65305. declare module BABYLON {
  65306. /**
  65307. * Mode that determines the coordinate system to use.
  65308. */
  65309. export enum GLTFLoaderCoordinateSystemMode {
  65310. /**
  65311. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  65312. */
  65313. AUTO = 0,
  65314. /**
  65315. * Sets the useRightHandedSystem flag on the scene.
  65316. */
  65317. FORCE_RIGHT_HANDED = 1
  65318. }
  65319. /**
  65320. * Mode that determines what animations will start.
  65321. */
  65322. export enum GLTFLoaderAnimationStartMode {
  65323. /**
  65324. * No animation will start.
  65325. */
  65326. NONE = 0,
  65327. /**
  65328. * The first animation will start.
  65329. */
  65330. FIRST = 1,
  65331. /**
  65332. * All animations will start.
  65333. */
  65334. ALL = 2
  65335. }
  65336. /**
  65337. * Interface that contains the data for the glTF asset.
  65338. */
  65339. export interface IGLTFLoaderData {
  65340. /**
  65341. * Object that represents the glTF JSON.
  65342. */
  65343. json: Object;
  65344. /**
  65345. * The BIN chunk of a binary glTF.
  65346. */
  65347. bin: Nullable<ArrayBufferView>;
  65348. }
  65349. /**
  65350. * Interface for extending the loader.
  65351. */
  65352. export interface IGLTFLoaderExtension {
  65353. /**
  65354. * The name of this extension.
  65355. */
  65356. readonly name: string;
  65357. /**
  65358. * Defines whether this extension is enabled.
  65359. */
  65360. enabled: boolean;
  65361. }
  65362. /**
  65363. * Loader state.
  65364. */
  65365. export enum GLTFLoaderState {
  65366. /**
  65367. * The asset is loading.
  65368. */
  65369. LOADING = 0,
  65370. /**
  65371. * The asset is ready for rendering.
  65372. */
  65373. READY = 1,
  65374. /**
  65375. * The asset is completely loaded.
  65376. */
  65377. COMPLETE = 2
  65378. }
  65379. /** @hidden */
  65380. export interface IGLTFLoader extends IDisposable {
  65381. readonly state: Nullable<GLTFLoaderState>;
  65382. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  65383. meshes: AbstractMesh[];
  65384. particleSystems: IParticleSystem[];
  65385. skeletons: Skeleton[];
  65386. animationGroups: AnimationGroup[];
  65387. }>;
  65388. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  65389. }
  65390. /**
  65391. * File loader for loading glTF files into a scene.
  65392. */
  65393. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  65394. /** @hidden */
  65395. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  65396. /** @hidden */
  65397. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  65398. /**
  65399. * Raised when the asset has been parsed
  65400. */
  65401. onParsedObservable: Observable<IGLTFLoaderData>;
  65402. private _onParsedObserver;
  65403. /**
  65404. * Raised when the asset has been parsed
  65405. */
  65406. onParsed: (loaderData: IGLTFLoaderData) => void;
  65407. /**
  65408. * 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.
  65409. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  65410. * Defaults to true.
  65411. * @hidden
  65412. */
  65413. static IncrementalLoading: boolean;
  65414. /**
  65415. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  65416. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  65417. * @hidden
  65418. */
  65419. static HomogeneousCoordinates: boolean;
  65420. /**
  65421. * The coordinate system mode. Defaults to AUTO.
  65422. */
  65423. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  65424. /**
  65425. * The animation start mode. Defaults to FIRST.
  65426. */
  65427. animationStartMode: GLTFLoaderAnimationStartMode;
  65428. /**
  65429. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  65430. */
  65431. compileMaterials: boolean;
  65432. /**
  65433. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  65434. */
  65435. useClipPlane: boolean;
  65436. /**
  65437. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  65438. */
  65439. compileShadowGenerators: boolean;
  65440. /**
  65441. * Defines if the Alpha blended materials are only applied as coverage.
  65442. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  65443. * If true, no extra effects are applied to transparent pixels.
  65444. */
  65445. transparencyAsCoverage: boolean;
  65446. /**
  65447. * Function called before loading a url referenced by the asset.
  65448. */
  65449. preprocessUrlAsync: (url: string) => Promise<string>;
  65450. /**
  65451. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  65452. */
  65453. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  65454. private _onMeshLoadedObserver;
  65455. /**
  65456. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  65457. */
  65458. onMeshLoaded: (mesh: AbstractMesh) => void;
  65459. /**
  65460. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  65461. */
  65462. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  65463. private _onTextureLoadedObserver;
  65464. /**
  65465. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  65466. */
  65467. onTextureLoaded: (texture: BaseTexture) => void;
  65468. /**
  65469. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  65470. */
  65471. readonly onMaterialLoadedObservable: Observable<Material>;
  65472. private _onMaterialLoadedObserver;
  65473. /**
  65474. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  65475. */
  65476. onMaterialLoaded: (material: Material) => void;
  65477. /**
  65478. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  65479. */
  65480. readonly onCameraLoadedObservable: Observable<Camera>;
  65481. private _onCameraLoadedObserver;
  65482. /**
  65483. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  65484. */
  65485. onCameraLoaded: (camera: Camera) => void;
  65486. /**
  65487. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  65488. * For assets with LODs, raised when all of the LODs are complete.
  65489. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  65490. */
  65491. readonly onCompleteObservable: Observable<void>;
  65492. private _onCompleteObserver;
  65493. /**
  65494. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  65495. * For assets with LODs, raised when all of the LODs are complete.
  65496. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  65497. */
  65498. onComplete: () => void;
  65499. /**
  65500. * Observable raised when an error occurs.
  65501. */
  65502. readonly onErrorObservable: Observable<any>;
  65503. private _onErrorObserver;
  65504. /**
  65505. * Callback raised when an error occurs.
  65506. */
  65507. onError: (reason: any) => void;
  65508. /**
  65509. * Observable raised after the loader is disposed.
  65510. */
  65511. readonly onDisposeObservable: Observable<void>;
  65512. private _onDisposeObserver;
  65513. /**
  65514. * Callback raised after the loader is disposed.
  65515. */
  65516. onDispose: () => void;
  65517. /**
  65518. * Observable raised after a loader extension is created.
  65519. * Set additional options for a loader extension in this event.
  65520. */
  65521. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  65522. private _onExtensionLoadedObserver;
  65523. /**
  65524. * Callback raised after a loader extension is created.
  65525. */
  65526. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  65527. /**
  65528. * Defines if the loader logging is enabled.
  65529. */
  65530. loggingEnabled: boolean;
  65531. /**
  65532. * Defines if the loader should capture performance counters.
  65533. */
  65534. capturePerformanceCounters: boolean;
  65535. /**
  65536. * Defines if the loader should validate the asset.
  65537. */
  65538. validate: boolean;
  65539. /**
  65540. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  65541. */
  65542. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  65543. private _onValidatedObserver;
  65544. /**
  65545. * Callback raised after a loader extension is created.
  65546. */
  65547. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  65548. private _loader;
  65549. /**
  65550. * Name of the loader ("gltf")
  65551. */
  65552. name: string;
  65553. /**
  65554. * Supported file extensions of the loader (.gltf, .glb)
  65555. */
  65556. extensions: ISceneLoaderPluginExtensions;
  65557. /**
  65558. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  65559. */
  65560. dispose(): void;
  65561. /** @hidden */
  65562. _clear(): void;
  65563. /**
  65564. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  65565. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  65566. * @param scene the scene the meshes should be added to
  65567. * @param data the glTF data to load
  65568. * @param rootUrl root url to load from
  65569. * @param onProgress event that fires when loading progress has occured
  65570. * @param fileName Defines the name of the file to load
  65571. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  65572. */
  65573. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  65574. meshes: AbstractMesh[];
  65575. particleSystems: IParticleSystem[];
  65576. skeletons: Skeleton[];
  65577. animationGroups: AnimationGroup[];
  65578. }>;
  65579. /**
  65580. * Imports all objects from the loaded glTF data and adds them to the scene
  65581. * @param scene the scene the objects should be added to
  65582. * @param data the glTF data to load
  65583. * @param rootUrl root url to load from
  65584. * @param onProgress event that fires when loading progress has occured
  65585. * @param fileName Defines the name of the file to load
  65586. * @returns a promise which completes when objects have been loaded to the scene
  65587. */
  65588. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  65589. /**
  65590. * Load into an asset container.
  65591. * @param scene The scene to load into
  65592. * @param data The data to import
  65593. * @param rootUrl The root url for scene and resources
  65594. * @param onProgress The callback when the load progresses
  65595. * @param fileName Defines the name of the file to load
  65596. * @returns The loaded asset container
  65597. */
  65598. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  65599. /**
  65600. * If the data string can be loaded directly.
  65601. * @param data string contianing the file data
  65602. * @returns if the data can be loaded directly
  65603. */
  65604. canDirectLoad(data: string): boolean;
  65605. /**
  65606. * Rewrites a url by combining a root url and response url.
  65607. */
  65608. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  65609. /**
  65610. * Instantiates a glTF file loader plugin.
  65611. * @returns the created plugin
  65612. */
  65613. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  65614. /**
  65615. * The loader state or null if the loader is not active.
  65616. */
  65617. readonly loaderState: Nullable<GLTFLoaderState>;
  65618. /**
  65619. * Returns a promise that resolves when the asset is completely loaded.
  65620. * @returns a promise that resolves when the asset is completely loaded.
  65621. */
  65622. whenCompleteAsync(): Promise<void>;
  65623. private _parseAsync;
  65624. private _validateAsync;
  65625. private _getLoader;
  65626. private _unpackBinary;
  65627. private _unpackBinaryV1;
  65628. private _unpackBinaryV2;
  65629. private static _parseVersion;
  65630. private static _compareVersion;
  65631. private static _decodeBufferToText;
  65632. private static readonly _logSpaces;
  65633. private _logIndentLevel;
  65634. private _loggingEnabled;
  65635. /** @hidden */
  65636. _log: (message: string) => void;
  65637. /** @hidden */
  65638. _logOpen(message: string): void;
  65639. /** @hidden */
  65640. _logClose(): void;
  65641. private _logEnabled;
  65642. private _logDisabled;
  65643. private _capturePerformanceCounters;
  65644. /** @hidden */
  65645. _startPerformanceCounter: (counterName: string) => void;
  65646. /** @hidden */
  65647. _endPerformanceCounter: (counterName: string) => void;
  65648. private _startPerformanceCounterEnabled;
  65649. private _startPerformanceCounterDisabled;
  65650. private _endPerformanceCounterEnabled;
  65651. private _endPerformanceCounterDisabled;
  65652. }
  65653. }
  65654. declare module BABYLON.GLTF1 {
  65655. /**
  65656. * Enums
  65657. * @hidden
  65658. */
  65659. export enum EComponentType {
  65660. BYTE = 5120,
  65661. UNSIGNED_BYTE = 5121,
  65662. SHORT = 5122,
  65663. UNSIGNED_SHORT = 5123,
  65664. FLOAT = 5126
  65665. }
  65666. /** @hidden */
  65667. export enum EShaderType {
  65668. FRAGMENT = 35632,
  65669. VERTEX = 35633
  65670. }
  65671. /** @hidden */
  65672. export enum EParameterType {
  65673. BYTE = 5120,
  65674. UNSIGNED_BYTE = 5121,
  65675. SHORT = 5122,
  65676. UNSIGNED_SHORT = 5123,
  65677. INT = 5124,
  65678. UNSIGNED_INT = 5125,
  65679. FLOAT = 5126,
  65680. FLOAT_VEC2 = 35664,
  65681. FLOAT_VEC3 = 35665,
  65682. FLOAT_VEC4 = 35666,
  65683. INT_VEC2 = 35667,
  65684. INT_VEC3 = 35668,
  65685. INT_VEC4 = 35669,
  65686. BOOL = 35670,
  65687. BOOL_VEC2 = 35671,
  65688. BOOL_VEC3 = 35672,
  65689. BOOL_VEC4 = 35673,
  65690. FLOAT_MAT2 = 35674,
  65691. FLOAT_MAT3 = 35675,
  65692. FLOAT_MAT4 = 35676,
  65693. SAMPLER_2D = 35678
  65694. }
  65695. /** @hidden */
  65696. export enum ETextureWrapMode {
  65697. CLAMP_TO_EDGE = 33071,
  65698. MIRRORED_REPEAT = 33648,
  65699. REPEAT = 10497
  65700. }
  65701. /** @hidden */
  65702. export enum ETextureFilterType {
  65703. NEAREST = 9728,
  65704. LINEAR = 9728,
  65705. NEAREST_MIPMAP_NEAREST = 9984,
  65706. LINEAR_MIPMAP_NEAREST = 9985,
  65707. NEAREST_MIPMAP_LINEAR = 9986,
  65708. LINEAR_MIPMAP_LINEAR = 9987
  65709. }
  65710. /** @hidden */
  65711. export enum ETextureFormat {
  65712. ALPHA = 6406,
  65713. RGB = 6407,
  65714. RGBA = 6408,
  65715. LUMINANCE = 6409,
  65716. LUMINANCE_ALPHA = 6410
  65717. }
  65718. /** @hidden */
  65719. export enum ECullingType {
  65720. FRONT = 1028,
  65721. BACK = 1029,
  65722. FRONT_AND_BACK = 1032
  65723. }
  65724. /** @hidden */
  65725. export enum EBlendingFunction {
  65726. ZERO = 0,
  65727. ONE = 1,
  65728. SRC_COLOR = 768,
  65729. ONE_MINUS_SRC_COLOR = 769,
  65730. DST_COLOR = 774,
  65731. ONE_MINUS_DST_COLOR = 775,
  65732. SRC_ALPHA = 770,
  65733. ONE_MINUS_SRC_ALPHA = 771,
  65734. DST_ALPHA = 772,
  65735. ONE_MINUS_DST_ALPHA = 773,
  65736. CONSTANT_COLOR = 32769,
  65737. ONE_MINUS_CONSTANT_COLOR = 32770,
  65738. CONSTANT_ALPHA = 32771,
  65739. ONE_MINUS_CONSTANT_ALPHA = 32772,
  65740. SRC_ALPHA_SATURATE = 776
  65741. }
  65742. /** @hidden */
  65743. export interface IGLTFProperty {
  65744. extensions?: {
  65745. [key: string]: any;
  65746. };
  65747. extras?: Object;
  65748. }
  65749. /** @hidden */
  65750. export interface IGLTFChildRootProperty extends IGLTFProperty {
  65751. name?: string;
  65752. }
  65753. /** @hidden */
  65754. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  65755. bufferView: string;
  65756. byteOffset: number;
  65757. byteStride: number;
  65758. count: number;
  65759. type: string;
  65760. componentType: EComponentType;
  65761. max?: number[];
  65762. min?: number[];
  65763. name?: string;
  65764. }
  65765. /** @hidden */
  65766. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  65767. buffer: string;
  65768. byteOffset: number;
  65769. byteLength: number;
  65770. byteStride: number;
  65771. target?: number;
  65772. }
  65773. /** @hidden */
  65774. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  65775. uri: string;
  65776. byteLength?: number;
  65777. type?: string;
  65778. }
  65779. /** @hidden */
  65780. export interface IGLTFShader extends IGLTFChildRootProperty {
  65781. uri: string;
  65782. type: EShaderType;
  65783. }
  65784. /** @hidden */
  65785. export interface IGLTFProgram extends IGLTFChildRootProperty {
  65786. attributes: string[];
  65787. fragmentShader: string;
  65788. vertexShader: string;
  65789. }
  65790. /** @hidden */
  65791. export interface IGLTFTechniqueParameter {
  65792. type: number;
  65793. count?: number;
  65794. semantic?: string;
  65795. node?: string;
  65796. value?: number | boolean | string | Array<any>;
  65797. source?: string;
  65798. babylonValue?: any;
  65799. }
  65800. /** @hidden */
  65801. export interface IGLTFTechniqueCommonProfile {
  65802. lightingModel: string;
  65803. texcoordBindings: Object;
  65804. parameters?: Array<any>;
  65805. }
  65806. /** @hidden */
  65807. export interface IGLTFTechniqueStatesFunctions {
  65808. blendColor?: number[];
  65809. blendEquationSeparate?: number[];
  65810. blendFuncSeparate?: number[];
  65811. colorMask: boolean[];
  65812. cullFace: number[];
  65813. }
  65814. /** @hidden */
  65815. export interface IGLTFTechniqueStates {
  65816. enable: number[];
  65817. functions: IGLTFTechniqueStatesFunctions;
  65818. }
  65819. /** @hidden */
  65820. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  65821. parameters: {
  65822. [key: string]: IGLTFTechniqueParameter;
  65823. };
  65824. program: string;
  65825. attributes: {
  65826. [key: string]: string;
  65827. };
  65828. uniforms: {
  65829. [key: string]: string;
  65830. };
  65831. states: IGLTFTechniqueStates;
  65832. }
  65833. /** @hidden */
  65834. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  65835. technique?: string;
  65836. values: string[];
  65837. }
  65838. /** @hidden */
  65839. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  65840. attributes: {
  65841. [key: string]: string;
  65842. };
  65843. indices: string;
  65844. material: string;
  65845. mode?: number;
  65846. }
  65847. /** @hidden */
  65848. export interface IGLTFMesh extends IGLTFChildRootProperty {
  65849. primitives: IGLTFMeshPrimitive[];
  65850. }
  65851. /** @hidden */
  65852. export interface IGLTFImage extends IGLTFChildRootProperty {
  65853. uri: string;
  65854. }
  65855. /** @hidden */
  65856. export interface IGLTFSampler extends IGLTFChildRootProperty {
  65857. magFilter?: number;
  65858. minFilter?: number;
  65859. wrapS?: number;
  65860. wrapT?: number;
  65861. }
  65862. /** @hidden */
  65863. export interface IGLTFTexture extends IGLTFChildRootProperty {
  65864. sampler: string;
  65865. source: string;
  65866. format?: ETextureFormat;
  65867. internalFormat?: ETextureFormat;
  65868. target?: number;
  65869. type?: number;
  65870. babylonTexture?: Texture;
  65871. }
  65872. /** @hidden */
  65873. export interface IGLTFAmbienLight {
  65874. color?: number[];
  65875. }
  65876. /** @hidden */
  65877. export interface IGLTFDirectionalLight {
  65878. color?: number[];
  65879. }
  65880. /** @hidden */
  65881. export interface IGLTFPointLight {
  65882. color?: number[];
  65883. constantAttenuation?: number;
  65884. linearAttenuation?: number;
  65885. quadraticAttenuation?: number;
  65886. }
  65887. /** @hidden */
  65888. export interface IGLTFSpotLight {
  65889. color?: number[];
  65890. constantAttenuation?: number;
  65891. fallOfAngle?: number;
  65892. fallOffExponent?: number;
  65893. linearAttenuation?: number;
  65894. quadraticAttenuation?: number;
  65895. }
  65896. /** @hidden */
  65897. export interface IGLTFLight extends IGLTFChildRootProperty {
  65898. type: string;
  65899. }
  65900. /** @hidden */
  65901. export interface IGLTFCameraOrthographic {
  65902. xmag: number;
  65903. ymag: number;
  65904. zfar: number;
  65905. znear: number;
  65906. }
  65907. /** @hidden */
  65908. export interface IGLTFCameraPerspective {
  65909. aspectRatio: number;
  65910. yfov: number;
  65911. zfar: number;
  65912. znear: number;
  65913. }
  65914. /** @hidden */
  65915. export interface IGLTFCamera extends IGLTFChildRootProperty {
  65916. type: string;
  65917. }
  65918. /** @hidden */
  65919. export interface IGLTFAnimationChannelTarget {
  65920. id: string;
  65921. path: string;
  65922. }
  65923. /** @hidden */
  65924. export interface IGLTFAnimationChannel {
  65925. sampler: string;
  65926. target: IGLTFAnimationChannelTarget;
  65927. }
  65928. /** @hidden */
  65929. export interface IGLTFAnimationSampler {
  65930. input: string;
  65931. output: string;
  65932. interpolation?: string;
  65933. }
  65934. /** @hidden */
  65935. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  65936. channels?: IGLTFAnimationChannel[];
  65937. parameters?: {
  65938. [key: string]: string;
  65939. };
  65940. samplers?: {
  65941. [key: string]: IGLTFAnimationSampler;
  65942. };
  65943. }
  65944. /** @hidden */
  65945. export interface IGLTFNodeInstanceSkin {
  65946. skeletons: string[];
  65947. skin: string;
  65948. meshes: string[];
  65949. }
  65950. /** @hidden */
  65951. export interface IGLTFSkins extends IGLTFChildRootProperty {
  65952. bindShapeMatrix: number[];
  65953. inverseBindMatrices: string;
  65954. jointNames: string[];
  65955. babylonSkeleton?: Skeleton;
  65956. }
  65957. /** @hidden */
  65958. export interface IGLTFNode extends IGLTFChildRootProperty {
  65959. camera?: string;
  65960. children: string[];
  65961. skin?: string;
  65962. jointName?: string;
  65963. light?: string;
  65964. matrix: number[];
  65965. mesh?: string;
  65966. meshes?: string[];
  65967. rotation?: number[];
  65968. scale?: number[];
  65969. translation?: number[];
  65970. babylonNode?: Node;
  65971. }
  65972. /** @hidden */
  65973. export interface IGLTFScene extends IGLTFChildRootProperty {
  65974. nodes: string[];
  65975. }
  65976. /** @hidden */
  65977. export interface IGLTFRuntime {
  65978. extensions: {
  65979. [key: string]: any;
  65980. };
  65981. accessors: {
  65982. [key: string]: IGLTFAccessor;
  65983. };
  65984. buffers: {
  65985. [key: string]: IGLTFBuffer;
  65986. };
  65987. bufferViews: {
  65988. [key: string]: IGLTFBufferView;
  65989. };
  65990. meshes: {
  65991. [key: string]: IGLTFMesh;
  65992. };
  65993. lights: {
  65994. [key: string]: IGLTFLight;
  65995. };
  65996. cameras: {
  65997. [key: string]: IGLTFCamera;
  65998. };
  65999. nodes: {
  66000. [key: string]: IGLTFNode;
  66001. };
  66002. images: {
  66003. [key: string]: IGLTFImage;
  66004. };
  66005. textures: {
  66006. [key: string]: IGLTFTexture;
  66007. };
  66008. shaders: {
  66009. [key: string]: IGLTFShader;
  66010. };
  66011. programs: {
  66012. [key: string]: IGLTFProgram;
  66013. };
  66014. samplers: {
  66015. [key: string]: IGLTFSampler;
  66016. };
  66017. techniques: {
  66018. [key: string]: IGLTFTechnique;
  66019. };
  66020. materials: {
  66021. [key: string]: IGLTFMaterial;
  66022. };
  66023. animations: {
  66024. [key: string]: IGLTFAnimation;
  66025. };
  66026. skins: {
  66027. [key: string]: IGLTFSkins;
  66028. };
  66029. currentScene?: Object;
  66030. scenes: {
  66031. [key: string]: IGLTFScene;
  66032. };
  66033. extensionsUsed: string[];
  66034. extensionsRequired?: string[];
  66035. buffersCount: number;
  66036. shaderscount: number;
  66037. scene: Scene;
  66038. rootUrl: string;
  66039. loadedBufferCount: number;
  66040. loadedBufferViews: {
  66041. [name: string]: ArrayBufferView;
  66042. };
  66043. loadedShaderCount: number;
  66044. importOnlyMeshes: boolean;
  66045. importMeshesNames?: string[];
  66046. dummyNodes: Node[];
  66047. }
  66048. /** @hidden */
  66049. export interface INodeToRoot {
  66050. bone: Bone;
  66051. node: IGLTFNode;
  66052. id: string;
  66053. }
  66054. /** @hidden */
  66055. export interface IJointNode {
  66056. node: IGLTFNode;
  66057. id: string;
  66058. }
  66059. }
  66060. declare module BABYLON.GLTF1 {
  66061. /**
  66062. * Utils functions for GLTF
  66063. * @hidden
  66064. */
  66065. export class GLTFUtils {
  66066. /**
  66067. * Sets the given "parameter" matrix
  66068. * @param scene: the Scene object
  66069. * @param source: the source node where to pick the matrix
  66070. * @param parameter: the GLTF technique parameter
  66071. * @param uniformName: the name of the shader's uniform
  66072. * @param shaderMaterial: the shader material
  66073. */
  66074. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  66075. /**
  66076. * Sets the given "parameter" matrix
  66077. * @param shaderMaterial: the shader material
  66078. * @param uniform: the name of the shader's uniform
  66079. * @param value: the value of the uniform
  66080. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  66081. */
  66082. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  66083. /**
  66084. * Returns the wrap mode of the texture
  66085. * @param mode: the mode value
  66086. */
  66087. static GetWrapMode(mode: number): number;
  66088. /**
  66089. * Returns the byte stride giving an accessor
  66090. * @param accessor: the GLTF accessor objet
  66091. */
  66092. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  66093. /**
  66094. * Returns the texture filter mode giving a mode value
  66095. * @param mode: the filter mode value
  66096. */
  66097. static GetTextureFilterMode(mode: number): ETextureFilterType;
  66098. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  66099. /**
  66100. * Returns a buffer from its accessor
  66101. * @param gltfRuntime: the GLTF runtime
  66102. * @param accessor: the GLTF accessor
  66103. */
  66104. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  66105. /**
  66106. * Decodes a buffer view into a string
  66107. * @param view: the buffer view
  66108. */
  66109. static DecodeBufferToText(view: ArrayBufferView): string;
  66110. /**
  66111. * Returns the default material of gltf. Related to
  66112. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  66113. * @param scene: the Babylon.js scene
  66114. */
  66115. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  66116. private static _DefaultMaterial;
  66117. }
  66118. }
  66119. declare module BABYLON.GLTF1 {
  66120. /**
  66121. * Implementation of the base glTF spec
  66122. * @hidden
  66123. */
  66124. export class GLTFLoaderBase {
  66125. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  66126. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  66127. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  66128. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  66129. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  66130. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  66131. }
  66132. /**
  66133. * glTF V1 Loader
  66134. * @hidden
  66135. */
  66136. export class GLTFLoader implements IGLTFLoader {
  66137. static Extensions: {
  66138. [name: string]: GLTFLoaderExtension;
  66139. };
  66140. static RegisterExtension(extension: GLTFLoaderExtension): void;
  66141. state: Nullable<GLTFLoaderState>;
  66142. dispose(): void;
  66143. private _importMeshAsync;
  66144. /**
  66145. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  66146. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  66147. * @param scene the scene the meshes should be added to
  66148. * @param data gltf data containing information of the meshes in a loaded file
  66149. * @param rootUrl root url to load from
  66150. * @param onProgress event that fires when loading progress has occured
  66151. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  66152. */
  66153. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  66154. meshes: AbstractMesh[];
  66155. particleSystems: IParticleSystem[];
  66156. skeletons: Skeleton[];
  66157. animationGroups: AnimationGroup[];
  66158. }>;
  66159. private _loadAsync;
  66160. /**
  66161. * Imports all objects from a loaded gltf file and adds them to the scene
  66162. * @param scene the scene the objects should be added to
  66163. * @param data gltf data containing information of the meshes in a loaded file
  66164. * @param rootUrl root url to load from
  66165. * @param onProgress event that fires when loading progress has occured
  66166. * @returns a promise which completes when objects have been loaded to the scene
  66167. */
  66168. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  66169. private _loadShadersAsync;
  66170. private _loadBuffersAsync;
  66171. private _createNodes;
  66172. }
  66173. /** @hidden */
  66174. export abstract class GLTFLoaderExtension {
  66175. private _name;
  66176. constructor(name: string);
  66177. readonly name: string;
  66178. /**
  66179. * Defines an override for loading the runtime
  66180. * Return true to stop further extensions from loading the runtime
  66181. */
  66182. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  66183. /**
  66184. * Defines an onverride for creating gltf runtime
  66185. * Return true to stop further extensions from creating the runtime
  66186. */
  66187. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  66188. /**
  66189. * Defines an override for loading buffers
  66190. * Return true to stop further extensions from loading this buffer
  66191. */
  66192. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  66193. /**
  66194. * Defines an override for loading texture buffers
  66195. * Return true to stop further extensions from loading this texture data
  66196. */
  66197. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  66198. /**
  66199. * Defines an override for creating textures
  66200. * Return true to stop further extensions from loading this texture
  66201. */
  66202. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  66203. /**
  66204. * Defines an override for loading shader strings
  66205. * Return true to stop further extensions from loading this shader data
  66206. */
  66207. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  66208. /**
  66209. * Defines an override for loading materials
  66210. * Return true to stop further extensions from loading this material
  66211. */
  66212. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  66213. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  66214. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  66215. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  66216. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  66217. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  66218. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  66219. private static LoadTextureBufferAsync;
  66220. private static CreateTextureAsync;
  66221. private static ApplyExtensions;
  66222. }
  66223. }
  66224. declare module BABYLON.GLTF1 {
  66225. /** @hidden */
  66226. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  66227. private _bin;
  66228. constructor();
  66229. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  66230. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  66231. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  66232. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  66233. }
  66234. }
  66235. declare module BABYLON.GLTF1 {
  66236. /** @hidden */
  66237. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  66238. constructor();
  66239. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  66240. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  66241. private _loadTexture;
  66242. }
  66243. }
  66244. declare module BABYLON.GLTF2.Loader {
  66245. /**
  66246. * Loader interface with an index field.
  66247. */
  66248. export interface IArrayItem {
  66249. /**
  66250. * The index of this item in the array.
  66251. */
  66252. index: number;
  66253. }
  66254. /**
  66255. * Loader interface with additional members.
  66256. */
  66257. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  66258. /** @hidden */
  66259. _data?: Promise<ArrayBufferView>;
  66260. /** @hidden */
  66261. _babylonVertexBuffer?: Promise<VertexBuffer>;
  66262. }
  66263. /**
  66264. * Loader interface with additional members.
  66265. */
  66266. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  66267. }
  66268. /** @hidden */
  66269. export interface _IAnimationSamplerData {
  66270. input: Float32Array;
  66271. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  66272. output: Float32Array;
  66273. }
  66274. /**
  66275. * Loader interface with additional members.
  66276. */
  66277. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  66278. /** @hidden */
  66279. _data?: Promise<_IAnimationSamplerData>;
  66280. }
  66281. /**
  66282. * Loader interface with additional members.
  66283. */
  66284. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  66285. channels: IAnimationChannel[];
  66286. samplers: IAnimationSampler[];
  66287. /** @hidden */
  66288. _babylonAnimationGroup?: AnimationGroup;
  66289. }
  66290. /**
  66291. * Loader interface with additional members.
  66292. */
  66293. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  66294. /** @hidden */
  66295. _data?: Promise<ArrayBufferView>;
  66296. }
  66297. /**
  66298. * Loader interface with additional members.
  66299. */
  66300. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  66301. /** @hidden */
  66302. _data?: Promise<ArrayBufferView>;
  66303. /** @hidden */
  66304. _babylonBuffer?: Promise<Buffer>;
  66305. }
  66306. /**
  66307. * Loader interface with additional members.
  66308. */
  66309. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  66310. }
  66311. /**
  66312. * Loader interface with additional members.
  66313. */
  66314. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  66315. /** @hidden */
  66316. _data?: Promise<ArrayBufferView>;
  66317. }
  66318. /**
  66319. * Loader interface with additional members.
  66320. */
  66321. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  66322. }
  66323. /**
  66324. * Loader interface with additional members.
  66325. */
  66326. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  66327. }
  66328. /**
  66329. * Loader interface with additional members.
  66330. */
  66331. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  66332. baseColorTexture?: ITextureInfo;
  66333. metallicRoughnessTexture?: ITextureInfo;
  66334. }
  66335. /**
  66336. * Loader interface with additional members.
  66337. */
  66338. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  66339. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  66340. normalTexture?: IMaterialNormalTextureInfo;
  66341. occlusionTexture?: IMaterialOcclusionTextureInfo;
  66342. emissiveTexture?: ITextureInfo;
  66343. /** @hidden */
  66344. _data?: {
  66345. [babylonDrawMode: number]: {
  66346. babylonMaterial: Material;
  66347. babylonMeshes: AbstractMesh[];
  66348. promise: Promise<void>;
  66349. };
  66350. };
  66351. }
  66352. /**
  66353. * Loader interface with additional members.
  66354. */
  66355. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  66356. primitives: IMeshPrimitive[];
  66357. }
  66358. /**
  66359. * Loader interface with additional members.
  66360. */
  66361. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  66362. /** @hidden */
  66363. _instanceData?: {
  66364. babylonSourceMesh: Mesh;
  66365. promise: Promise<any>;
  66366. };
  66367. }
  66368. /**
  66369. * Loader interface with additional members.
  66370. */
  66371. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  66372. /**
  66373. * The parent glTF node.
  66374. */
  66375. parent?: INode;
  66376. /** @hidden */
  66377. _babylonTransformNode?: TransformNode;
  66378. /** @hidden */
  66379. _primitiveBabylonMeshes?: AbstractMesh[];
  66380. /** @hidden */
  66381. _babylonBones?: Bone[];
  66382. /** @hidden */
  66383. _numMorphTargets?: number;
  66384. }
  66385. /** @hidden */
  66386. export interface _ISamplerData {
  66387. noMipMaps: boolean;
  66388. samplingMode: number;
  66389. wrapU: number;
  66390. wrapV: number;
  66391. }
  66392. /**
  66393. * Loader interface with additional members.
  66394. */
  66395. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  66396. /** @hidden */
  66397. _data?: _ISamplerData;
  66398. }
  66399. /**
  66400. * Loader interface with additional members.
  66401. */
  66402. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  66403. }
  66404. /**
  66405. * Loader interface with additional members.
  66406. */
  66407. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  66408. /** @hidden */
  66409. _data?: {
  66410. babylonSkeleton: Skeleton;
  66411. promise: Promise<void>;
  66412. };
  66413. }
  66414. /**
  66415. * Loader interface with additional members.
  66416. */
  66417. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  66418. }
  66419. /**
  66420. * Loader interface with additional members.
  66421. */
  66422. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  66423. }
  66424. /**
  66425. * Loader interface with additional members.
  66426. */
  66427. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  66428. accessors?: IAccessor[];
  66429. animations?: IAnimation[];
  66430. buffers?: IBuffer[];
  66431. bufferViews?: IBufferView[];
  66432. cameras?: ICamera[];
  66433. images?: IImage[];
  66434. materials?: IMaterial[];
  66435. meshes?: IMesh[];
  66436. nodes?: INode[];
  66437. samplers?: ISampler[];
  66438. scenes?: IScene[];
  66439. skins?: ISkin[];
  66440. textures?: ITexture[];
  66441. }
  66442. }
  66443. declare module BABYLON.GLTF2 {
  66444. /**
  66445. * Interface for a glTF loader extension.
  66446. */
  66447. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  66448. /**
  66449. * Called after the loader state changes to LOADING.
  66450. */
  66451. onLoading?(): void;
  66452. /**
  66453. * Called after the loader state changes to READY.
  66454. */
  66455. onReady?(): void;
  66456. /**
  66457. * Define this method to modify the default behavior when loading scenes.
  66458. * @param context The context when loading the asset
  66459. * @param scene The glTF scene property
  66460. * @returns A promise that resolves when the load is complete or null if not handled
  66461. */
  66462. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  66463. /**
  66464. * Define this method to modify the default behavior when loading nodes.
  66465. * @param context The context when loading the asset
  66466. * @param node The glTF node property
  66467. * @param assign A function called synchronously after parsing the glTF properties
  66468. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  66469. */
  66470. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66471. /**
  66472. * Define this method to modify the default behavior when loading cameras.
  66473. * @param context The context when loading the asset
  66474. * @param camera The glTF camera property
  66475. * @param assign A function called synchronously after parsing the glTF properties
  66476. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  66477. */
  66478. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  66479. /**
  66480. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  66481. * @param context The context when loading the asset
  66482. * @param primitive The glTF mesh primitive property
  66483. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  66484. */
  66485. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  66486. /**
  66487. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  66488. * @param context The context when loading the asset
  66489. * @param name The mesh name when loading the asset
  66490. * @param node The glTF node when loading the asset
  66491. * @param mesh The glTF mesh when loading the asset
  66492. * @param primitive The glTF mesh primitive property
  66493. * @param assign A function called synchronously after parsing the glTF properties
  66494. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  66495. */
  66496. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  66497. /**
  66498. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  66499. * @param context The context when loading the asset
  66500. * @param material The glTF material property
  66501. * @param assign A function called synchronously after parsing the glTF properties
  66502. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  66503. */
  66504. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  66505. /**
  66506. * Define this method to modify the default behavior when creating materials.
  66507. * @param context The context when loading the asset
  66508. * @param material The glTF material property
  66509. * @param babylonDrawMode The draw mode for the Babylon material
  66510. * @returns The Babylon material or null if not handled
  66511. */
  66512. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  66513. /**
  66514. * Define this method to modify the default behavior when loading material properties.
  66515. * @param context The context when loading the asset
  66516. * @param material The glTF material property
  66517. * @param babylonMaterial The Babylon material
  66518. * @returns A promise that resolves when the load is complete or null if not handled
  66519. */
  66520. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66521. /**
  66522. * Define this method to modify the default behavior when loading texture infos.
  66523. * @param context The context when loading the asset
  66524. * @param textureInfo The glTF texture info property
  66525. * @param assign A function called synchronously after parsing the glTF properties
  66526. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  66527. */
  66528. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  66529. /**
  66530. * Define this method to modify the default behavior when loading animations.
  66531. * @param context The context when loading the asset
  66532. * @param animation The glTF animation property
  66533. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  66534. */
  66535. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  66536. /**
  66537. * @hidden Define this method to modify the default behavior when loading skins.
  66538. * @param context The context when loading the asset
  66539. * @param node The glTF node property
  66540. * @param skin The glTF skin property
  66541. * @returns A promise that resolves when the load is complete or null if not handled
  66542. */
  66543. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  66544. /**
  66545. * @hidden Define this method to modify the default behavior when loading uris.
  66546. * @param context The context when loading the asset
  66547. * @param property The glTF property associated with the uri
  66548. * @param uri The uri to load
  66549. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  66550. */
  66551. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  66552. }
  66553. }
  66554. declare module BABYLON.GLTF2 {
  66555. /**
  66556. * Helper class for working with arrays when loading the glTF asset
  66557. */
  66558. export class ArrayItem {
  66559. /**
  66560. * Gets an item from the given array.
  66561. * @param context The context when loading the asset
  66562. * @param array The array to get the item from
  66563. * @param index The index to the array
  66564. * @returns The array item
  66565. */
  66566. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  66567. /**
  66568. * Assign an `index` field to each item of the given array.
  66569. * @param array The array of items
  66570. */
  66571. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  66572. }
  66573. /**
  66574. * The glTF 2.0 loader
  66575. */
  66576. export class GLTFLoader implements IGLTFLoader {
  66577. /** @hidden */
  66578. _completePromises: Promise<any>[];
  66579. private _disposed;
  66580. private _parent;
  66581. private _state;
  66582. private _extensions;
  66583. private _rootUrl;
  66584. private _fileName;
  66585. private _uniqueRootUrl;
  66586. private _gltf;
  66587. private _babylonScene;
  66588. private _rootBabylonMesh;
  66589. private _defaultBabylonMaterialData;
  66590. private _progressCallback?;
  66591. private _requests;
  66592. private static readonly _DefaultSampler;
  66593. private static _ExtensionNames;
  66594. private static _ExtensionFactories;
  66595. /**
  66596. * Registers a loader extension.
  66597. * @param name The name of the loader extension.
  66598. * @param factory The factory function that creates the loader extension.
  66599. */
  66600. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  66601. /**
  66602. * Unregisters a loader extension.
  66603. * @param name The name of the loader extenion.
  66604. * @returns A boolean indicating whether the extension has been unregistered
  66605. */
  66606. static UnregisterExtension(name: string): boolean;
  66607. /**
  66608. * Gets the loader state.
  66609. */
  66610. readonly state: Nullable<GLTFLoaderState>;
  66611. /**
  66612. * The glTF object parsed from the JSON.
  66613. */
  66614. readonly gltf: IGLTF;
  66615. /**
  66616. * The Babylon scene when loading the asset.
  66617. */
  66618. readonly babylonScene: Scene;
  66619. /**
  66620. * The root Babylon mesh when loading the asset.
  66621. */
  66622. readonly rootBabylonMesh: Mesh;
  66623. /** @hidden */
  66624. constructor(parent: GLTFFileLoader);
  66625. /** @hidden */
  66626. dispose(): void;
  66627. /** @hidden */
  66628. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  66629. meshes: AbstractMesh[];
  66630. particleSystems: IParticleSystem[];
  66631. skeletons: Skeleton[];
  66632. animationGroups: AnimationGroup[];
  66633. }>;
  66634. /** @hidden */
  66635. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  66636. private _loadAsync;
  66637. private _loadData;
  66638. private _setupData;
  66639. private _loadExtensions;
  66640. private _checkExtensions;
  66641. private _setState;
  66642. private _createRootNode;
  66643. /**
  66644. * Loads a glTF scene.
  66645. * @param context The context when loading the asset
  66646. * @param scene The glTF scene property
  66647. * @returns A promise that resolves when the load is complete
  66648. */
  66649. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  66650. private _forEachPrimitive;
  66651. private _getMeshes;
  66652. private _getSkeletons;
  66653. private _getAnimationGroups;
  66654. private _startAnimations;
  66655. /**
  66656. * Loads a glTF node.
  66657. * @param context The context when loading the asset
  66658. * @param node The glTF node property
  66659. * @param assign A function called synchronously after parsing the glTF properties
  66660. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  66661. */
  66662. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  66663. private _loadMeshAsync;
  66664. /**
  66665. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  66666. * @param context The context when loading the asset
  66667. * @param name The mesh name when loading the asset
  66668. * @param node The glTF node when loading the asset
  66669. * @param mesh The glTF mesh when loading the asset
  66670. * @param primitive The glTF mesh primitive property
  66671. * @param assign A function called synchronously after parsing the glTF properties
  66672. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  66673. */
  66674. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  66675. private _loadVertexDataAsync;
  66676. private _createMorphTargets;
  66677. private _loadMorphTargetsAsync;
  66678. private _loadMorphTargetVertexDataAsync;
  66679. private static _LoadTransform;
  66680. private _loadSkinAsync;
  66681. private _loadBones;
  66682. private _loadBone;
  66683. private _loadSkinInverseBindMatricesDataAsync;
  66684. private _updateBoneMatrices;
  66685. private _getNodeMatrix;
  66686. /**
  66687. * Loads a glTF camera.
  66688. * @param context The context when loading the asset
  66689. * @param camera The glTF camera property
  66690. * @param assign A function called synchronously after parsing the glTF properties
  66691. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  66692. */
  66693. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  66694. private _loadAnimationsAsync;
  66695. /**
  66696. * Loads a glTF animation.
  66697. * @param context The context when loading the asset
  66698. * @param animation The glTF animation property
  66699. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  66700. */
  66701. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  66702. /**
  66703. * @hidden Loads a glTF animation channel.
  66704. * @param context The context when loading the asset
  66705. * @param animationContext The context of the animation when loading the asset
  66706. * @param animation The glTF animation property
  66707. * @param channel The glTF animation channel property
  66708. * @param babylonAnimationGroup The babylon animation group property
  66709. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  66710. * @returns A void promise when the channel load is complete
  66711. */
  66712. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  66713. private _loadAnimationSamplerAsync;
  66714. private _loadBufferAsync;
  66715. /**
  66716. * Loads a glTF buffer view.
  66717. * @param context The context when loading the asset
  66718. * @param bufferView The glTF buffer view property
  66719. * @returns A promise that resolves with the loaded data when the load is complete
  66720. */
  66721. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  66722. private _loadAccessorAsync;
  66723. private _loadFloatAccessorAsync;
  66724. private _loadIndicesAccessorAsync;
  66725. private _loadVertexBufferViewAsync;
  66726. private _loadVertexAccessorAsync;
  66727. private _loadMaterialMetallicRoughnessPropertiesAsync;
  66728. /** @hidden */
  66729. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  66730. private _createDefaultMaterial;
  66731. /**
  66732. * Creates a Babylon material from a glTF material.
  66733. * @param context The context when loading the asset
  66734. * @param material The glTF material property
  66735. * @param babylonDrawMode The draw mode for the Babylon material
  66736. * @returns The Babylon material
  66737. */
  66738. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  66739. /**
  66740. * Loads properties from a glTF material into a Babylon material.
  66741. * @param context The context when loading the asset
  66742. * @param material The glTF material property
  66743. * @param babylonMaterial The Babylon material
  66744. * @returns A promise that resolves when the load is complete
  66745. */
  66746. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  66747. /**
  66748. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  66749. * @param context The context when loading the asset
  66750. * @param material The glTF material property
  66751. * @param babylonMaterial The Babylon material
  66752. * @returns A promise that resolves when the load is complete
  66753. */
  66754. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  66755. /**
  66756. * Loads the alpha properties from a glTF material into a Babylon material.
  66757. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  66758. * @param context The context when loading the asset
  66759. * @param material The glTF material property
  66760. * @param babylonMaterial The Babylon material
  66761. */
  66762. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  66763. /**
  66764. * Loads a glTF texture info.
  66765. * @param context The context when loading the asset
  66766. * @param textureInfo The glTF texture info property
  66767. * @param assign A function called synchronously after parsing the glTF properties
  66768. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  66769. */
  66770. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  66771. private _loadTextureAsync;
  66772. private _loadSampler;
  66773. /**
  66774. * Loads a glTF image.
  66775. * @param context The context when loading the asset
  66776. * @param image The glTF image property
  66777. * @returns A promise that resolves with the loaded data when the load is complete
  66778. */
  66779. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  66780. /**
  66781. * Loads a glTF uri.
  66782. * @param context The context when loading the asset
  66783. * @param property The glTF property associated with the uri
  66784. * @param uri The base64 or relative uri
  66785. * @returns A promise that resolves with the loaded data when the load is complete
  66786. */
  66787. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  66788. private _onProgress;
  66789. /**
  66790. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  66791. * @param babylonObject the Babylon object with metadata
  66792. * @param pointer the JSON pointer
  66793. */
  66794. static AddPointerMetadata(babylonObject: {
  66795. metadata: any;
  66796. }, pointer: string): void;
  66797. private static _GetTextureWrapMode;
  66798. private static _GetTextureSamplingMode;
  66799. private static _GetTypedArrayConstructor;
  66800. private static _GetTypedArray;
  66801. private static _GetNumComponents;
  66802. private static _ValidateUri;
  66803. private static _GetDrawMode;
  66804. private _compileMaterialsAsync;
  66805. private _compileShadowGeneratorsAsync;
  66806. private _forEachExtensions;
  66807. private _applyExtensions;
  66808. private _extensionsOnLoading;
  66809. private _extensionsOnReady;
  66810. private _extensionsLoadSceneAsync;
  66811. private _extensionsLoadNodeAsync;
  66812. private _extensionsLoadCameraAsync;
  66813. private _extensionsLoadVertexDataAsync;
  66814. private _extensionsLoadMeshPrimitiveAsync;
  66815. private _extensionsLoadMaterialAsync;
  66816. private _extensionsCreateMaterial;
  66817. private _extensionsLoadMaterialPropertiesAsync;
  66818. private _extensionsLoadTextureInfoAsync;
  66819. private _extensionsLoadAnimationAsync;
  66820. private _extensionsLoadSkinAsync;
  66821. private _extensionsLoadUriAsync;
  66822. /**
  66823. * Helper method called by a loader extension to load an glTF extension.
  66824. * @param context The context when loading the asset
  66825. * @param property The glTF property to load the extension from
  66826. * @param extensionName The name of the extension to load
  66827. * @param actionAsync The action to run
  66828. * @returns The promise returned by actionAsync or null if the extension does not exist
  66829. */
  66830. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  66831. /**
  66832. * Helper method called by a loader extension to load a glTF extra.
  66833. * @param context The context when loading the asset
  66834. * @param property The glTF property to load the extra from
  66835. * @param extensionName The name of the extension to load
  66836. * @param actionAsync The action to run
  66837. * @returns The promise returned by actionAsync or null if the extra does not exist
  66838. */
  66839. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  66840. /**
  66841. * Increments the indentation level and logs a message.
  66842. * @param message The message to log
  66843. */
  66844. logOpen(message: string): void;
  66845. /**
  66846. * Decrements the indentation level.
  66847. */
  66848. logClose(): void;
  66849. /**
  66850. * Logs a message
  66851. * @param message The message to log
  66852. */
  66853. log(message: string): void;
  66854. /**
  66855. * Starts a performance counter.
  66856. * @param counterName The name of the performance counter
  66857. */
  66858. startPerformanceCounter(counterName: string): void;
  66859. /**
  66860. * Ends a performance counter.
  66861. * @param counterName The name of the performance counter
  66862. */
  66863. endPerformanceCounter(counterName: string): void;
  66864. }
  66865. }
  66866. declare module BABYLON.GLTF2.Loader.Extensions {
  66867. /**
  66868. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  66869. */
  66870. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  66871. /** The name of this extension. */
  66872. readonly name: string;
  66873. /** Defines whether this extension is enabled. */
  66874. enabled: boolean;
  66875. private _loader;
  66876. private _lights?;
  66877. /** @hidden */
  66878. constructor(loader: GLTFLoader);
  66879. /** @hidden */
  66880. dispose(): void;
  66881. /** @hidden */
  66882. onLoading(): void;
  66883. /** @hidden */
  66884. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  66885. private _loadLightAsync;
  66886. }
  66887. }
  66888. declare module BABYLON.GLTF2.Loader.Extensions {
  66889. /**
  66890. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  66891. */
  66892. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  66893. /** The name of this extension. */
  66894. readonly name: string;
  66895. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  66896. dracoCompression?: DracoCompression;
  66897. /** Defines whether this extension is enabled. */
  66898. enabled: boolean;
  66899. private _loader;
  66900. /** @hidden */
  66901. constructor(loader: GLTFLoader);
  66902. /** @hidden */
  66903. dispose(): void;
  66904. /** @hidden */
  66905. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  66906. }
  66907. }
  66908. declare module BABYLON.GLTF2.Loader.Extensions {
  66909. /**
  66910. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  66911. */
  66912. export class KHR_lights implements IGLTFLoaderExtension {
  66913. /** The name of this extension. */
  66914. readonly name: string;
  66915. /** Defines whether this extension is enabled. */
  66916. enabled: boolean;
  66917. private _loader;
  66918. private _lights?;
  66919. /** @hidden */
  66920. constructor(loader: GLTFLoader);
  66921. /** @hidden */
  66922. dispose(): void;
  66923. /** @hidden */
  66924. onLoading(): void;
  66925. /** @hidden */
  66926. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66927. }
  66928. }
  66929. declare module BABYLON.GLTF2.Loader.Extensions {
  66930. /**
  66931. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  66932. */
  66933. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  66934. /** The name of this extension. */
  66935. readonly name: string;
  66936. /** Defines whether this extension is enabled. */
  66937. enabled: boolean;
  66938. private _loader;
  66939. /** @hidden */
  66940. constructor(loader: GLTFLoader);
  66941. /** @hidden */
  66942. dispose(): void;
  66943. /** @hidden */
  66944. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66945. private _loadSpecularGlossinessPropertiesAsync;
  66946. }
  66947. }
  66948. declare module BABYLON.GLTF2.Loader.Extensions {
  66949. /**
  66950. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  66951. */
  66952. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  66953. /** The name of this extension. */
  66954. readonly name: string;
  66955. /** Defines whether this extension is enabled. */
  66956. enabled: boolean;
  66957. private _loader;
  66958. /** @hidden */
  66959. constructor(loader: GLTFLoader);
  66960. /** @hidden */
  66961. dispose(): void;
  66962. /** @hidden */
  66963. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66964. private _loadUnlitPropertiesAsync;
  66965. }
  66966. }
  66967. declare module BABYLON.GLTF2.Loader.Extensions {
  66968. /**
  66969. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  66970. */
  66971. export class KHR_texture_transform implements IGLTFLoaderExtension {
  66972. /** The name of this extension. */
  66973. readonly name: string;
  66974. /** Defines whether this extension is enabled. */
  66975. enabled: boolean;
  66976. private _loader;
  66977. /** @hidden */
  66978. constructor(loader: GLTFLoader);
  66979. /** @hidden */
  66980. dispose(): void;
  66981. /** @hidden */
  66982. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  66983. }
  66984. }
  66985. declare module BABYLON.GLTF2.Loader.Extensions {
  66986. /**
  66987. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  66988. */
  66989. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  66990. /** The name of this extension. */
  66991. readonly name: string;
  66992. /** Defines whether this extension is enabled. */
  66993. enabled: boolean;
  66994. private _loader;
  66995. private _clips;
  66996. private _emitters;
  66997. /** @hidden */
  66998. constructor(loader: GLTFLoader);
  66999. /** @hidden */
  67000. dispose(): void;
  67001. /** @hidden */
  67002. onLoading(): void;
  67003. /** @hidden */
  67004. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  67005. /** @hidden */
  67006. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67007. /** @hidden */
  67008. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  67009. private _loadClipAsync;
  67010. private _loadEmitterAsync;
  67011. private _getEventAction;
  67012. private _loadAnimationEventAsync;
  67013. }
  67014. }
  67015. declare module BABYLON.GLTF2.Loader.Extensions {
  67016. /**
  67017. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  67018. */
  67019. export class MSFT_lod implements IGLTFLoaderExtension {
  67020. /** The name of this extension. */
  67021. readonly name: string;
  67022. /** Defines whether this extension is enabled. */
  67023. enabled: boolean;
  67024. /**
  67025. * Maximum number of LODs to load, starting from the lowest LOD.
  67026. */
  67027. maxLODsToLoad: number;
  67028. /**
  67029. * Observable raised when all node LODs of one level are loaded.
  67030. * The event data is the index of the loaded LOD starting from zero.
  67031. * Dispose the loader to cancel the loading of the next level of LODs.
  67032. */
  67033. onNodeLODsLoadedObservable: Observable<number>;
  67034. /**
  67035. * Observable raised when all material LODs of one level are loaded.
  67036. * The event data is the index of the loaded LOD starting from zero.
  67037. * Dispose the loader to cancel the loading of the next level of LODs.
  67038. */
  67039. onMaterialLODsLoadedObservable: Observable<number>;
  67040. private _loader;
  67041. private _nodeIndexLOD;
  67042. private _nodeSignalLODs;
  67043. private _nodePromiseLODs;
  67044. private _materialIndexLOD;
  67045. private _materialSignalLODs;
  67046. private _materialPromiseLODs;
  67047. /** @hidden */
  67048. constructor(loader: GLTFLoader);
  67049. /** @hidden */
  67050. dispose(): void;
  67051. /** @hidden */
  67052. onReady(): void;
  67053. /** @hidden */
  67054. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67055. /** @hidden */
  67056. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  67057. /** @hidden */
  67058. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  67059. /**
  67060. * Gets an array of LOD properties from lowest to highest.
  67061. */
  67062. private _getLODs;
  67063. private _disposeUnusedMaterials;
  67064. }
  67065. }
  67066. declare module BABYLON.GLTF2.Loader.Extensions {
  67067. /** @hidden */
  67068. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  67069. readonly name: string;
  67070. enabled: boolean;
  67071. private _loader;
  67072. constructor(loader: GLTFLoader);
  67073. dispose(): void;
  67074. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67075. }
  67076. }
  67077. declare module BABYLON.GLTF2.Loader.Extensions {
  67078. /** @hidden */
  67079. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  67080. readonly name: string;
  67081. enabled: boolean;
  67082. private _loader;
  67083. constructor(loader: GLTFLoader);
  67084. dispose(): void;
  67085. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67086. }
  67087. }
  67088. declare module BABYLON.GLTF2.Loader.Extensions {
  67089. /**
  67090. * Store glTF extras (if present) in BJS objects' metadata
  67091. */
  67092. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  67093. /** The name of this extension. */
  67094. readonly name: string;
  67095. /** Defines whether this extension is enabled. */
  67096. enabled: boolean;
  67097. private _loader;
  67098. private _assignExtras;
  67099. /** @hidden */
  67100. constructor(loader: GLTFLoader);
  67101. /** @hidden */
  67102. dispose(): void;
  67103. /** @hidden */
  67104. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67105. /** @hidden */
  67106. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  67107. /** @hidden */
  67108. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  67109. }
  67110. }
  67111. declare module BABYLON {
  67112. /**
  67113. * Class reading and parsing the MTL file bundled with the obj file.
  67114. */
  67115. export class MTLFileLoader {
  67116. /**
  67117. * All material loaded from the mtl will be set here
  67118. */
  67119. materials: StandardMaterial[];
  67120. /**
  67121. * This function will read the mtl file and create each material described inside
  67122. * This function could be improve by adding :
  67123. * -some component missing (Ni, Tf...)
  67124. * -including the specific options available
  67125. *
  67126. * @param scene defines the scene the material will be created in
  67127. * @param data defines the mtl data to parse
  67128. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  67129. */
  67130. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  67131. /**
  67132. * Gets the texture for the material.
  67133. *
  67134. * If the material is imported from input file,
  67135. * We sanitize the url to ensure it takes the textre from aside the material.
  67136. *
  67137. * @param rootUrl The root url to load from
  67138. * @param value The value stored in the mtl
  67139. * @return The Texture
  67140. */
  67141. private static _getTexture;
  67142. }
  67143. /**
  67144. * Options for loading OBJ/MTL files
  67145. */
  67146. type MeshLoadOptions = {
  67147. /**
  67148. * Defines if UVs are optimized by default during load.
  67149. */
  67150. OptimizeWithUV: boolean;
  67151. /**
  67152. * Defines custom scaling of UV coordinates of loaded meshes.
  67153. */
  67154. UVScaling: Vector2;
  67155. /**
  67156. * Invert model on y-axis (does a model scaling inversion)
  67157. */
  67158. InvertY: boolean;
  67159. /**
  67160. * Invert Y-Axis of referenced textures on load
  67161. */
  67162. InvertTextureY: boolean;
  67163. /**
  67164. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  67165. */
  67166. ImportVertexColors: boolean;
  67167. /**
  67168. * Compute the normals for the model, even if normals are present in the file.
  67169. */
  67170. ComputeNormals: boolean;
  67171. /**
  67172. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  67173. */
  67174. SkipMaterials: boolean;
  67175. /**
  67176. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  67177. */
  67178. MaterialLoadingFailsSilently: boolean;
  67179. };
  67180. /**
  67181. * OBJ file type loader.
  67182. * This is a babylon scene loader plugin.
  67183. */
  67184. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  67185. /**
  67186. * Defines if UVs are optimized by default during load.
  67187. */
  67188. static OPTIMIZE_WITH_UV: boolean;
  67189. /**
  67190. * Invert model on y-axis (does a model scaling inversion)
  67191. */
  67192. static INVERT_Y: boolean;
  67193. /**
  67194. * Invert Y-Axis of referenced textures on load
  67195. */
  67196. static INVERT_TEXTURE_Y: boolean;
  67197. /**
  67198. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  67199. */
  67200. static IMPORT_VERTEX_COLORS: boolean;
  67201. /**
  67202. * Compute the normals for the model, even if normals are present in the file.
  67203. */
  67204. static COMPUTE_NORMALS: boolean;
  67205. /**
  67206. * Defines custom scaling of UV coordinates of loaded meshes.
  67207. */
  67208. static UV_SCALING: Vector2;
  67209. /**
  67210. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  67211. */
  67212. static SKIP_MATERIALS: boolean;
  67213. /**
  67214. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  67215. *
  67216. * Defaults to true for backwards compatibility.
  67217. */
  67218. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  67219. /**
  67220. * Defines the name of the plugin.
  67221. */
  67222. name: string;
  67223. /**
  67224. * Defines the extension the plugin is able to load.
  67225. */
  67226. extensions: string;
  67227. /** @hidden */
  67228. obj: RegExp;
  67229. /** @hidden */
  67230. group: RegExp;
  67231. /** @hidden */
  67232. mtllib: RegExp;
  67233. /** @hidden */
  67234. usemtl: RegExp;
  67235. /** @hidden */
  67236. smooth: RegExp;
  67237. /** @hidden */
  67238. vertexPattern: RegExp;
  67239. /** @hidden */
  67240. normalPattern: RegExp;
  67241. /** @hidden */
  67242. uvPattern: RegExp;
  67243. /** @hidden */
  67244. facePattern1: RegExp;
  67245. /** @hidden */
  67246. facePattern2: RegExp;
  67247. /** @hidden */
  67248. facePattern3: RegExp;
  67249. /** @hidden */
  67250. facePattern4: RegExp;
  67251. /** @hidden */
  67252. facePattern5: RegExp;
  67253. private _meshLoadOptions;
  67254. /**
  67255. * Creates loader for .OBJ files
  67256. *
  67257. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  67258. */
  67259. constructor(meshLoadOptions?: MeshLoadOptions);
  67260. private static readonly currentMeshLoadOptions;
  67261. /**
  67262. * Calls synchronously the MTL file attached to this obj.
  67263. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  67264. * Without this function materials are not displayed in the first frame (but displayed after).
  67265. * In consequence it is impossible to get material information in your HTML file
  67266. *
  67267. * @param url The URL of the MTL file
  67268. * @param rootUrl
  67269. * @param onSuccess Callback function to be called when the MTL file is loaded
  67270. * @private
  67271. */
  67272. private _loadMTL;
  67273. /**
  67274. * Instantiates a OBJ file loader plugin.
  67275. * @returns the created plugin
  67276. */
  67277. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  67278. /**
  67279. * If the data string can be loaded directly.
  67280. *
  67281. * @param data string containing the file data
  67282. * @returns if the data can be loaded directly
  67283. */
  67284. canDirectLoad(data: string): boolean;
  67285. /**
  67286. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  67287. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67288. * @param scene the scene the meshes should be added to
  67289. * @param data the OBJ data to load
  67290. * @param rootUrl root url to load from
  67291. * @param onProgress event that fires when loading progress has occured
  67292. * @param fileName Defines the name of the file to load
  67293. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67294. */
  67295. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67296. meshes: AbstractMesh[];
  67297. particleSystems: IParticleSystem[];
  67298. skeletons: Skeleton[];
  67299. animationGroups: AnimationGroup[];
  67300. }>;
  67301. /**
  67302. * Imports all objects from the loaded OBJ data and adds them to the scene
  67303. * @param scene the scene the objects should be added to
  67304. * @param data the OBJ data to load
  67305. * @param rootUrl root url to load from
  67306. * @param onProgress event that fires when loading progress has occured
  67307. * @param fileName Defines the name of the file to load
  67308. * @returns a promise which completes when objects have been loaded to the scene
  67309. */
  67310. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67311. /**
  67312. * Load into an asset container.
  67313. * @param scene The scene to load into
  67314. * @param data The data to import
  67315. * @param rootUrl The root url for scene and resources
  67316. * @param onProgress The callback when the load progresses
  67317. * @param fileName Defines the name of the file to load
  67318. * @returns The loaded asset container
  67319. */
  67320. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  67321. /**
  67322. * Read the OBJ file and create an Array of meshes.
  67323. * Each mesh contains all information given by the OBJ and the MTL file.
  67324. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  67325. *
  67326. * @param meshesNames
  67327. * @param scene Scene The scene where are displayed the data
  67328. * @param data String The content of the obj file
  67329. * @param rootUrl String The path to the folder
  67330. * @returns Array<AbstractMesh>
  67331. * @private
  67332. */
  67333. private _parseSolid;
  67334. }
  67335. }
  67336. declare module BABYLON {
  67337. /**
  67338. * STL file type loader.
  67339. * This is a babylon scene loader plugin.
  67340. */
  67341. export class STLFileLoader implements ISceneLoaderPlugin {
  67342. /** @hidden */
  67343. solidPattern: RegExp;
  67344. /** @hidden */
  67345. facetsPattern: RegExp;
  67346. /** @hidden */
  67347. normalPattern: RegExp;
  67348. /** @hidden */
  67349. vertexPattern: RegExp;
  67350. /**
  67351. * Defines the name of the plugin.
  67352. */
  67353. name: string;
  67354. /**
  67355. * Defines the extensions the stl loader is able to load.
  67356. * force data to come in as an ArrayBuffer
  67357. * we'll convert to string if it looks like it's an ASCII .stl
  67358. */
  67359. extensions: ISceneLoaderPluginExtensions;
  67360. /**
  67361. * Import meshes into a scene.
  67362. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  67363. * @param scene The scene to import into
  67364. * @param data The data to import
  67365. * @param rootUrl The root url for scene and resources
  67366. * @param meshes The meshes array to import into
  67367. * @param particleSystems The particle systems array to import into
  67368. * @param skeletons The skeletons array to import into
  67369. * @param onError The callback when import fails
  67370. * @returns True if successful or false otherwise
  67371. */
  67372. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  67373. /**
  67374. * Load into a scene.
  67375. * @param scene The scene to load into
  67376. * @param data The data to import
  67377. * @param rootUrl The root url for scene and resources
  67378. * @param onError The callback when import fails
  67379. * @returns true if successful or false otherwise
  67380. */
  67381. load(scene: Scene, data: any, rootUrl: string): boolean;
  67382. /**
  67383. * Load into an asset container.
  67384. * @param scene The scene to load into
  67385. * @param data The data to import
  67386. * @param rootUrl The root url for scene and resources
  67387. * @param onError The callback when import fails
  67388. * @returns The loaded asset container
  67389. */
  67390. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  67391. private _isBinary;
  67392. private _parseBinary;
  67393. private _parseASCII;
  67394. }
  67395. }
  67396. declare module BABYLON {
  67397. /**
  67398. * Class for generating OBJ data from a Babylon scene.
  67399. */
  67400. export class OBJExport {
  67401. /**
  67402. * Exports the geometry of a Mesh array in .OBJ file format (text)
  67403. * @param mesh defines the list of meshes to serialize
  67404. * @param materials defines if materials should be exported
  67405. * @param matlibname defines the name of the associated mtl file
  67406. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  67407. * @returns the OBJ content
  67408. */
  67409. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  67410. /**
  67411. * Exports the material(s) of a mesh in .MTL file format (text)
  67412. * @param mesh defines the mesh to extract the material from
  67413. * @returns the mtl content
  67414. */
  67415. static MTL(mesh: Mesh): string;
  67416. }
  67417. }
  67418. declare module BABYLON {
  67419. /** @hidden */
  67420. export var __IGLTFExporterExtension: number;
  67421. /**
  67422. * Interface for extending the exporter
  67423. * @hidden
  67424. */
  67425. export interface IGLTFExporterExtension {
  67426. /**
  67427. * The name of this extension
  67428. */
  67429. readonly name: string;
  67430. /**
  67431. * Defines whether this extension is enabled
  67432. */
  67433. enabled: boolean;
  67434. /**
  67435. * Defines whether this extension is required
  67436. */
  67437. required: boolean;
  67438. }
  67439. }
  67440. declare module BABYLON.GLTF2.Exporter {
  67441. /** @hidden */
  67442. export var __IGLTFExporterExtensionV2: number;
  67443. /**
  67444. * Interface for a glTF exporter extension
  67445. * @hidden
  67446. */
  67447. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  67448. /**
  67449. * Define this method to modify the default behavior before exporting a texture
  67450. * @param context The context when loading the asset
  67451. * @param babylonTexture The glTF texture info property
  67452. * @param mimeType The mime-type of the generated image
  67453. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  67454. */
  67455. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  67456. /**
  67457. * Define this method to modify the default behavior when exporting texture info
  67458. * @param context The context when loading the asset
  67459. * @param meshPrimitive glTF mesh primitive
  67460. * @param babylonSubMesh Babylon submesh
  67461. * @param binaryWriter glTF serializer binary writer instance
  67462. * @returns nullable IMeshPrimitive promise
  67463. */
  67464. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  67465. /**
  67466. * Define this method to modify the default behavior when exporting a node
  67467. * @param context The context when exporting the node
  67468. * @param node glTF node
  67469. * @param babylonNode BabylonJS node
  67470. * @returns nullable INode promise
  67471. */
  67472. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  67473. /**
  67474. * Called after the exporter state changes to EXPORTING
  67475. */
  67476. onExporting?(): void;
  67477. }
  67478. }
  67479. declare module BABYLON.GLTF2.Exporter {
  67480. /**
  67481. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  67482. * @hidden
  67483. */
  67484. export class _GLTFMaterialExporter {
  67485. /**
  67486. * Represents the dielectric specular values for R, G and B
  67487. */
  67488. private static readonly _DielectricSpecular;
  67489. /**
  67490. * Allows the maximum specular power to be defined for material calculations
  67491. */
  67492. private static readonly _MaxSpecularPower;
  67493. /**
  67494. * Mapping to store textures
  67495. */
  67496. private _textureMap;
  67497. /**
  67498. * Numeric tolerance value
  67499. */
  67500. private static readonly _Epsilon;
  67501. /**
  67502. * Reference to the glTF Exporter
  67503. */
  67504. private _exporter;
  67505. constructor(exporter: _Exporter);
  67506. /**
  67507. * Specifies if two colors are approximately equal in value
  67508. * @param color1 first color to compare to
  67509. * @param color2 second color to compare to
  67510. * @param epsilon threshold value
  67511. */
  67512. private static FuzzyEquals;
  67513. /**
  67514. * Gets the materials from a Babylon scene and converts them to glTF materials
  67515. * @param scene babylonjs scene
  67516. * @param mimeType texture mime type
  67517. * @param images array of images
  67518. * @param textures array of textures
  67519. * @param materials array of materials
  67520. * @param imageData mapping of texture names to base64 textures
  67521. * @param hasTextureCoords specifies if texture coordinates are present on the material
  67522. */
  67523. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67524. /**
  67525. * Makes a copy of the glTF material without the texture parameters
  67526. * @param originalMaterial original glTF material
  67527. * @returns glTF material without texture parameters
  67528. */
  67529. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  67530. /**
  67531. * Specifies if the material has any texture parameters present
  67532. * @param material glTF Material
  67533. * @returns boolean specifying if texture parameters are present
  67534. */
  67535. _hasTexturesPresent(material: IMaterial): boolean;
  67536. /**
  67537. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  67538. * @param babylonStandardMaterial
  67539. * @returns glTF Metallic Roughness Material representation
  67540. */
  67541. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  67542. /**
  67543. * Computes the metallic factor
  67544. * @param diffuse diffused value
  67545. * @param specular specular value
  67546. * @param oneMinusSpecularStrength one minus the specular strength
  67547. * @returns metallic value
  67548. */
  67549. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  67550. /**
  67551. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  67552. * @param glTFMaterial glTF material
  67553. * @param babylonMaterial Babylon material
  67554. */
  67555. private static _SetAlphaMode;
  67556. /**
  67557. * Converts a Babylon Standard Material to a glTF Material
  67558. * @param babylonStandardMaterial BJS Standard Material
  67559. * @param mimeType mime type to use for the textures
  67560. * @param images array of glTF image interfaces
  67561. * @param textures array of glTF texture interfaces
  67562. * @param materials array of glTF material interfaces
  67563. * @param imageData map of image file name to data
  67564. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67565. */
  67566. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67567. /**
  67568. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  67569. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  67570. * @param mimeType mime type to use for the textures
  67571. * @param images array of glTF image interfaces
  67572. * @param textures array of glTF texture interfaces
  67573. * @param materials array of glTF material interfaces
  67574. * @param imageData map of image file name to data
  67575. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67576. */
  67577. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67578. /**
  67579. * Converts an image typed array buffer to a base64 image
  67580. * @param buffer typed array buffer
  67581. * @param width width of the image
  67582. * @param height height of the image
  67583. * @param mimeType mimetype of the image
  67584. * @returns base64 image string
  67585. */
  67586. private _createBase64FromCanvasAsync;
  67587. /**
  67588. * Generates a white texture based on the specified width and height
  67589. * @param width width of the texture in pixels
  67590. * @param height height of the texture in pixels
  67591. * @param scene babylonjs scene
  67592. * @returns white texture
  67593. */
  67594. private _createWhiteTexture;
  67595. /**
  67596. * 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
  67597. * @param texture1 first texture to resize
  67598. * @param texture2 second texture to resize
  67599. * @param scene babylonjs scene
  67600. * @returns resized textures or null
  67601. */
  67602. private _resizeTexturesToSameDimensions;
  67603. /**
  67604. * Converts an array of pixels to a Float32Array
  67605. * Throws an error if the pixel format is not supported
  67606. * @param pixels - array buffer containing pixel values
  67607. * @returns Float32 of pixels
  67608. */
  67609. private _convertPixelArrayToFloat32;
  67610. /**
  67611. * Convert Specular Glossiness Textures to Metallic Roughness
  67612. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  67613. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  67614. * @param diffuseTexture texture used to store diffuse information
  67615. * @param specularGlossinessTexture texture used to store specular and glossiness information
  67616. * @param factors specular glossiness material factors
  67617. * @param mimeType the mime type to use for the texture
  67618. * @returns pbr metallic roughness interface or null
  67619. */
  67620. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  67621. /**
  67622. * Converts specular glossiness material properties to metallic roughness
  67623. * @param specularGlossiness interface with specular glossiness material properties
  67624. * @returns interface with metallic roughness material properties
  67625. */
  67626. private _convertSpecularGlossinessToMetallicRoughness;
  67627. /**
  67628. * Calculates the surface reflectance, independent of lighting conditions
  67629. * @param color Color source to calculate brightness from
  67630. * @returns number representing the perceived brightness, or zero if color is undefined
  67631. */
  67632. private _getPerceivedBrightness;
  67633. /**
  67634. * Returns the maximum color component value
  67635. * @param color
  67636. * @returns maximum color component value, or zero if color is null or undefined
  67637. */
  67638. private _getMaxComponent;
  67639. /**
  67640. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  67641. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  67642. * @param mimeType mime type to use for the textures
  67643. * @param images array of glTF image interfaces
  67644. * @param textures array of glTF texture interfaces
  67645. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  67646. * @param imageData map of image file name to data
  67647. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67648. * @returns glTF PBR Metallic Roughness factors
  67649. */
  67650. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  67651. private _getGLTFTextureSampler;
  67652. private _getGLTFTextureWrapMode;
  67653. private _getGLTFTextureWrapModesSampler;
  67654. /**
  67655. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  67656. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  67657. * @param mimeType mime type to use for the textures
  67658. * @param images array of glTF image interfaces
  67659. * @param textures array of glTF texture interfaces
  67660. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  67661. * @param imageData map of image file name to data
  67662. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67663. * @returns glTF PBR Metallic Roughness factors
  67664. */
  67665. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  67666. /**
  67667. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  67668. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  67669. * @param mimeType mime type to use for the textures
  67670. * @param images array of glTF image interfaces
  67671. * @param textures array of glTF texture interfaces
  67672. * @param materials array of glTF material interfaces
  67673. * @param imageData map of image file name to data
  67674. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67675. */
  67676. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67677. private setMetallicRoughnessPbrMaterial;
  67678. private getPixelsFromTexture;
  67679. /**
  67680. * Extracts a texture from a Babylon texture into file data and glTF data
  67681. * @param babylonTexture Babylon texture to extract
  67682. * @param mimeType Mime Type of the babylonTexture
  67683. * @return glTF texture info, or null if the texture format is not supported
  67684. */
  67685. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  67686. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  67687. /**
  67688. * Builds a texture from base64 string
  67689. * @param base64Texture base64 texture string
  67690. * @param baseTextureName Name to use for the texture
  67691. * @param mimeType image mime type for the texture
  67692. * @param images array of images
  67693. * @param textures array of textures
  67694. * @param imageData map of image data
  67695. * @returns glTF texture info, or null if the texture format is not supported
  67696. */
  67697. private _getTextureInfoFromBase64;
  67698. }
  67699. }
  67700. declare module BABYLON {
  67701. /**
  67702. * Class for holding and downloading glTF file data
  67703. */
  67704. export class GLTFData {
  67705. /**
  67706. * Object which contains the file name as the key and its data as the value
  67707. */
  67708. glTFFiles: {
  67709. [fileName: string]: string | Blob;
  67710. };
  67711. /**
  67712. * Initializes the glTF file object
  67713. */
  67714. constructor();
  67715. /**
  67716. * Downloads the glTF data as files based on their names and data
  67717. */
  67718. downloadFiles(): void;
  67719. }
  67720. }
  67721. declare module BABYLON {
  67722. /**
  67723. * Holds a collection of exporter options and parameters
  67724. */
  67725. export interface IExportOptions {
  67726. /**
  67727. * Function which indicates whether a babylon node should be exported or not
  67728. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  67729. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  67730. */
  67731. shouldExportNode?(node: Node): boolean;
  67732. /**
  67733. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  67734. * @param metadata source metadata to read from
  67735. * @returns the data to store to glTF node extras
  67736. */
  67737. metadataSelector?(metadata: any): any;
  67738. /**
  67739. * The sample rate to bake animation curves
  67740. */
  67741. animationSampleRate?: number;
  67742. /**
  67743. * Begin serialization without waiting for the scene to be ready
  67744. */
  67745. exportWithoutWaitingForScene?: boolean;
  67746. }
  67747. /**
  67748. * Class for generating glTF data from a Babylon scene.
  67749. */
  67750. export class GLTF2Export {
  67751. /**
  67752. * Exports the geometry of the scene to .gltf file format asynchronously
  67753. * @param scene Babylon scene with scene hierarchy information
  67754. * @param filePrefix File prefix to use when generating the glTF file
  67755. * @param options Exporter options
  67756. * @returns Returns an object with a .gltf file and associates texture names
  67757. * as keys and their data and paths as values
  67758. */
  67759. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  67760. private static _PreExportAsync;
  67761. private static _PostExportAsync;
  67762. /**
  67763. * Exports the geometry of the scene to .glb file format asychronously
  67764. * @param scene Babylon scene with scene hierarchy information
  67765. * @param filePrefix File prefix to use when generating glb file
  67766. * @param options Exporter options
  67767. * @returns Returns an object with a .glb filename as key and data as value
  67768. */
  67769. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  67770. }
  67771. }
  67772. declare module BABYLON.GLTF2.Exporter {
  67773. /**
  67774. * @hidden
  67775. */
  67776. export class _GLTFUtilities {
  67777. /**
  67778. * Creates a buffer view based on the supplied arguments
  67779. * @param bufferIndex index value of the specified buffer
  67780. * @param byteOffset byte offset value
  67781. * @param byteLength byte length of the bufferView
  67782. * @param byteStride byte distance between conequential elements
  67783. * @param name name of the buffer view
  67784. * @returns bufferView for glTF
  67785. */
  67786. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  67787. /**
  67788. * Creates an accessor based on the supplied arguments
  67789. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  67790. * @param name The name of the accessor
  67791. * @param type The type of the accessor
  67792. * @param componentType The datatype of components in the attribute
  67793. * @param count The number of attributes referenced by this accessor
  67794. * @param byteOffset The offset relative to the start of the bufferView in bytes
  67795. * @param min Minimum value of each component in this attribute
  67796. * @param max Maximum value of each component in this attribute
  67797. * @returns accessor for glTF
  67798. */
  67799. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  67800. /**
  67801. * Calculates the minimum and maximum values of an array of position floats
  67802. * @param positions Positions array of a mesh
  67803. * @param vertexStart Starting vertex offset to calculate min and max values
  67804. * @param vertexCount Number of vertices to check for min and max values
  67805. * @returns min number array and max number array
  67806. */
  67807. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  67808. min: number[];
  67809. max: number[];
  67810. };
  67811. /**
  67812. * Converts a new right-handed Vector3
  67813. * @param vector vector3 array
  67814. * @returns right-handed Vector3
  67815. */
  67816. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  67817. /**
  67818. * Converts a Vector3 to right-handed
  67819. * @param vector Vector3 to convert to right-handed
  67820. */
  67821. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  67822. /**
  67823. * Converts a three element number array to right-handed
  67824. * @param vector number array to convert to right-handed
  67825. */
  67826. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  67827. /**
  67828. * Converts a new right-handed Vector3
  67829. * @param vector vector3 array
  67830. * @returns right-handed Vector3
  67831. */
  67832. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  67833. /**
  67834. * Converts a Vector3 to right-handed
  67835. * @param vector Vector3 to convert to right-handed
  67836. */
  67837. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  67838. /**
  67839. * Converts a three element number array to right-handed
  67840. * @param vector number array to convert to right-handed
  67841. */
  67842. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  67843. /**
  67844. * Converts a Vector4 to right-handed
  67845. * @param vector Vector4 to convert to right-handed
  67846. */
  67847. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  67848. /**
  67849. * Converts a Vector4 to right-handed
  67850. * @param vector Vector4 to convert to right-handed
  67851. */
  67852. static _GetRightHandedArray4FromRef(vector: number[]): void;
  67853. /**
  67854. * Converts a Quaternion to right-handed
  67855. * @param quaternion Source quaternion to convert to right-handed
  67856. */
  67857. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  67858. /**
  67859. * Converts a Quaternion to right-handed
  67860. * @param quaternion Source quaternion to convert to right-handed
  67861. */
  67862. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  67863. static _NormalizeTangentFromRef(tangent: Vector4): void;
  67864. }
  67865. }
  67866. declare module BABYLON.GLTF2.Exporter {
  67867. /**
  67868. * Converts Babylon Scene into glTF 2.0.
  67869. * @hidden
  67870. */
  67871. export class _Exporter {
  67872. /**
  67873. * Stores the glTF to export
  67874. */
  67875. _glTF: IGLTF;
  67876. /**
  67877. * Stores all generated buffer views, which represents views into the main glTF buffer data
  67878. */
  67879. _bufferViews: IBufferView[];
  67880. /**
  67881. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  67882. */
  67883. _accessors: IAccessor[];
  67884. /**
  67885. * Stores all the generated nodes, which contains transform and/or mesh information per node
  67886. */
  67887. private _nodes;
  67888. /**
  67889. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  67890. */
  67891. private _scenes;
  67892. /**
  67893. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  67894. */
  67895. private _meshes;
  67896. /**
  67897. * Stores all the generated material information, which represents the appearance of each primitive
  67898. */
  67899. _materials: IMaterial[];
  67900. _materialMap: {
  67901. [materialID: number]: number;
  67902. };
  67903. /**
  67904. * Stores all the generated texture information, which is referenced by glTF materials
  67905. */
  67906. _textures: ITexture[];
  67907. /**
  67908. * Stores all the generated image information, which is referenced by glTF textures
  67909. */
  67910. _images: IImage[];
  67911. /**
  67912. * Stores all the texture samplers
  67913. */
  67914. _samplers: ISampler[];
  67915. /**
  67916. * Stores all the generated animation samplers, which is referenced by glTF animations
  67917. */
  67918. /**
  67919. * Stores the animations for glTF models
  67920. */
  67921. private _animations;
  67922. /**
  67923. * Stores the total amount of bytes stored in the glTF buffer
  67924. */
  67925. private _totalByteLength;
  67926. /**
  67927. * Stores a reference to the Babylon scene containing the source geometry and material information
  67928. */
  67929. _babylonScene: Scene;
  67930. /**
  67931. * Stores a map of the image data, where the key is the file name and the value
  67932. * is the image data
  67933. */
  67934. _imageData: {
  67935. [fileName: string]: {
  67936. data: Uint8Array;
  67937. mimeType: ImageMimeType;
  67938. };
  67939. };
  67940. /**
  67941. * Stores a map of the unique id of a node to its index in the node array
  67942. */
  67943. private _nodeMap;
  67944. /**
  67945. * Specifies if the Babylon scene should be converted to right-handed on export
  67946. */
  67947. _convertToRightHandedSystem: boolean;
  67948. /**
  67949. * Baked animation sample rate
  67950. */
  67951. private _animationSampleRate;
  67952. private _options;
  67953. private _localEngine;
  67954. _glTFMaterialExporter: _GLTFMaterialExporter;
  67955. private _extensions;
  67956. private static _ExtensionNames;
  67957. private static _ExtensionFactories;
  67958. private _applyExtensions;
  67959. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  67960. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  67961. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  67962. private _forEachExtensions;
  67963. private _extensionsOnExporting;
  67964. /**
  67965. * Load glTF serializer extensions
  67966. */
  67967. private _loadExtensions;
  67968. /**
  67969. * Creates a glTF Exporter instance, which can accept optional exporter options
  67970. * @param babylonScene Babylon scene object
  67971. * @param options Options to modify the behavior of the exporter
  67972. */
  67973. constructor(babylonScene: Scene, options?: IExportOptions);
  67974. /**
  67975. * Registers a glTF exporter extension
  67976. * @param name Name of the extension to export
  67977. * @param factory The factory function that creates the exporter extension
  67978. */
  67979. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  67980. /**
  67981. * Un-registers an exporter extension
  67982. * @param name The name fo the exporter extension
  67983. * @returns A boolean indicating whether the extension has been un-registered
  67984. */
  67985. static UnregisterExtension(name: string): boolean;
  67986. /**
  67987. * Lazy load a local engine with premultiplied alpha set to false
  67988. */
  67989. _getLocalEngine(): Engine;
  67990. private reorderIndicesBasedOnPrimitiveMode;
  67991. /**
  67992. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  67993. * clock-wise during export to glTF
  67994. * @param submesh BabylonJS submesh
  67995. * @param primitiveMode Primitive mode of the mesh
  67996. * @param sideOrientation the winding order of the submesh
  67997. * @param vertexBufferKind The type of vertex attribute
  67998. * @param meshAttributeArray The vertex attribute data
  67999. * @param byteOffset The offset to the binary data
  68000. * @param binaryWriter The binary data for the glTF file
  68001. */
  68002. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  68003. /**
  68004. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  68005. * clock-wise during export to glTF
  68006. * @param submesh BabylonJS submesh
  68007. * @param primitiveMode Primitive mode of the mesh
  68008. * @param sideOrientation the winding order of the submesh
  68009. * @param vertexBufferKind The type of vertex attribute
  68010. * @param meshAttributeArray The vertex attribute data
  68011. * @param byteOffset The offset to the binary data
  68012. * @param binaryWriter The binary data for the glTF file
  68013. */
  68014. private reorderTriangleFillMode;
  68015. /**
  68016. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  68017. * clock-wise during export to glTF
  68018. * @param submesh BabylonJS submesh
  68019. * @param primitiveMode Primitive mode of the mesh
  68020. * @param sideOrientation the winding order of the submesh
  68021. * @param vertexBufferKind The type of vertex attribute
  68022. * @param meshAttributeArray The vertex attribute data
  68023. * @param byteOffset The offset to the binary data
  68024. * @param binaryWriter The binary data for the glTF file
  68025. */
  68026. private reorderTriangleStripDrawMode;
  68027. /**
  68028. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  68029. * clock-wise during export to glTF
  68030. * @param submesh BabylonJS submesh
  68031. * @param primitiveMode Primitive mode of the mesh
  68032. * @param sideOrientation the winding order of the submesh
  68033. * @param vertexBufferKind The type of vertex attribute
  68034. * @param meshAttributeArray The vertex attribute data
  68035. * @param byteOffset The offset to the binary data
  68036. * @param binaryWriter The binary data for the glTF file
  68037. */
  68038. private reorderTriangleFanMode;
  68039. /**
  68040. * Writes the vertex attribute data to binary
  68041. * @param vertices The vertices to write to the binary writer
  68042. * @param byteOffset The offset into the binary writer to overwrite binary data
  68043. * @param vertexAttributeKind The vertex attribute type
  68044. * @param meshAttributeArray The vertex attribute data
  68045. * @param binaryWriter The writer containing the binary data
  68046. */
  68047. private writeVertexAttributeData;
  68048. /**
  68049. * Writes mesh attribute data to a data buffer
  68050. * Returns the bytelength of the data
  68051. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  68052. * @param meshAttributeArray Array containing the attribute data
  68053. * @param binaryWriter The buffer to write the binary data to
  68054. * @param indices Used to specify the order of the vertex data
  68055. */
  68056. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  68057. /**
  68058. * Generates glTF json data
  68059. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  68060. * @param glTFPrefix Text to use when prefixing a glTF file
  68061. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  68062. * @returns json data as string
  68063. */
  68064. private generateJSON;
  68065. /**
  68066. * Generates data for .gltf and .bin files based on the glTF prefix string
  68067. * @param glTFPrefix Text to use when prefixing a glTF file
  68068. * @returns GLTFData with glTF file data
  68069. */
  68070. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  68071. /**
  68072. * Creates a binary buffer for glTF
  68073. * @returns array buffer for binary data
  68074. */
  68075. private _generateBinaryAsync;
  68076. /**
  68077. * Pads the number to a multiple of 4
  68078. * @param num number to pad
  68079. * @returns padded number
  68080. */
  68081. private _getPadding;
  68082. /**
  68083. * Generates a glb file from the json and binary data
  68084. * Returns an object with the glb file name as the key and data as the value
  68085. * @param glTFPrefix
  68086. * @returns object with glb filename as key and data as value
  68087. */
  68088. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  68089. /**
  68090. * Sets the TRS for each node
  68091. * @param node glTF Node for storing the transformation data
  68092. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  68093. */
  68094. private setNodeTransformation;
  68095. private getVertexBufferFromMesh;
  68096. /**
  68097. * Creates a bufferview based on the vertices type for the Babylon mesh
  68098. * @param kind Indicates the type of vertices data
  68099. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  68100. * @param binaryWriter The buffer to write the bufferview data to
  68101. */
  68102. private createBufferViewKind;
  68103. /**
  68104. * The primitive mode of the Babylon mesh
  68105. * @param babylonMesh The BabylonJS mesh
  68106. */
  68107. private getMeshPrimitiveMode;
  68108. /**
  68109. * Sets the primitive mode of the glTF mesh primitive
  68110. * @param meshPrimitive glTF mesh primitive
  68111. * @param primitiveMode The primitive mode
  68112. */
  68113. private setPrimitiveMode;
  68114. /**
  68115. * Sets the vertex attribute accessor based of the glTF mesh primitive
  68116. * @param meshPrimitive glTF mesh primitive
  68117. * @param attributeKind vertex attribute
  68118. * @returns boolean specifying if uv coordinates are present
  68119. */
  68120. private setAttributeKind;
  68121. /**
  68122. * Sets data for the primitive attributes of each submesh
  68123. * @param mesh glTF Mesh object to store the primitive attribute information
  68124. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  68125. * @param binaryWriter Buffer to write the attribute data to
  68126. */
  68127. private setPrimitiveAttributesAsync;
  68128. /**
  68129. * Creates a glTF scene based on the array of meshes
  68130. * Returns the the total byte offset
  68131. * @param babylonScene Babylon scene to get the mesh data from
  68132. * @param binaryWriter Buffer to write binary data to
  68133. */
  68134. private createSceneAsync;
  68135. /**
  68136. * Creates a mapping of Node unique id to node index and handles animations
  68137. * @param babylonScene Babylon Scene
  68138. * @param nodes Babylon transform nodes
  68139. * @param binaryWriter Buffer to write binary data to
  68140. * @returns Node mapping of unique id to index
  68141. */
  68142. private createNodeMapAndAnimationsAsync;
  68143. /**
  68144. * Creates a glTF node from a Babylon mesh
  68145. * @param babylonMesh Source Babylon mesh
  68146. * @param binaryWriter Buffer for storing geometry data
  68147. * @returns glTF node
  68148. */
  68149. private createNodeAsync;
  68150. }
  68151. /**
  68152. * @hidden
  68153. *
  68154. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  68155. */
  68156. export class _BinaryWriter {
  68157. /**
  68158. * Array buffer which stores all binary data
  68159. */
  68160. private _arrayBuffer;
  68161. /**
  68162. * View of the array buffer
  68163. */
  68164. private _dataView;
  68165. /**
  68166. * byte offset of data in array buffer
  68167. */
  68168. private _byteOffset;
  68169. /**
  68170. * Initialize binary writer with an initial byte length
  68171. * @param byteLength Initial byte length of the array buffer
  68172. */
  68173. constructor(byteLength: number);
  68174. /**
  68175. * Resize the array buffer to the specified byte length
  68176. * @param byteLength
  68177. */
  68178. private resizeBuffer;
  68179. /**
  68180. * Get an array buffer with the length of the byte offset
  68181. * @returns ArrayBuffer resized to the byte offset
  68182. */
  68183. getArrayBuffer(): ArrayBuffer;
  68184. /**
  68185. * Get the byte offset of the array buffer
  68186. * @returns byte offset
  68187. */
  68188. getByteOffset(): number;
  68189. /**
  68190. * Stores an UInt8 in the array buffer
  68191. * @param entry
  68192. * @param byteOffset If defined, specifies where to set the value as an offset.
  68193. */
  68194. setUInt8(entry: number, byteOffset?: number): void;
  68195. /**
  68196. * Gets an UInt32 in the array buffer
  68197. * @param entry
  68198. * @param byteOffset If defined, specifies where to set the value as an offset.
  68199. */
  68200. getUInt32(byteOffset: number): number;
  68201. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  68202. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  68203. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  68204. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  68205. /**
  68206. * Stores a Float32 in the array buffer
  68207. * @param entry
  68208. */
  68209. setFloat32(entry: number, byteOffset?: number): void;
  68210. /**
  68211. * Stores an UInt32 in the array buffer
  68212. * @param entry
  68213. * @param byteOffset If defined, specifies where to set the value as an offset.
  68214. */
  68215. setUInt32(entry: number, byteOffset?: number): void;
  68216. }
  68217. }
  68218. declare module BABYLON.GLTF2.Exporter {
  68219. /**
  68220. * @hidden
  68221. * Interface to store animation data.
  68222. */
  68223. export interface _IAnimationData {
  68224. /**
  68225. * Keyframe data.
  68226. */
  68227. inputs: number[];
  68228. /**
  68229. * Value data.
  68230. */
  68231. outputs: number[][];
  68232. /**
  68233. * Animation interpolation data.
  68234. */
  68235. samplerInterpolation: AnimationSamplerInterpolation;
  68236. /**
  68237. * Minimum keyframe value.
  68238. */
  68239. inputsMin: number;
  68240. /**
  68241. * Maximum keyframe value.
  68242. */
  68243. inputsMax: number;
  68244. }
  68245. /**
  68246. * @hidden
  68247. */
  68248. export interface _IAnimationInfo {
  68249. /**
  68250. * The target channel for the animation
  68251. */
  68252. animationChannelTargetPath: AnimationChannelTargetPath;
  68253. /**
  68254. * The glTF accessor type for the data.
  68255. */
  68256. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  68257. /**
  68258. * Specifies if quaternions should be used.
  68259. */
  68260. useQuaternion: boolean;
  68261. }
  68262. /**
  68263. * @hidden
  68264. * Utility class for generating glTF animation data from BabylonJS.
  68265. */
  68266. export class _GLTFAnimation {
  68267. /**
  68268. * @ignore
  68269. *
  68270. * Creates glTF channel animation from BabylonJS animation.
  68271. * @param babylonTransformNode - BabylonJS mesh.
  68272. * @param animation - animation.
  68273. * @param animationChannelTargetPath - The target animation channel.
  68274. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  68275. * @param useQuaternion - Specifies if quaternions are used.
  68276. * @returns nullable IAnimationData
  68277. */
  68278. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  68279. private static _DeduceAnimationInfo;
  68280. /**
  68281. * @ignore
  68282. * Create node animations from the transform node animations
  68283. * @param babylonNode
  68284. * @param runtimeGLTFAnimation
  68285. * @param idleGLTFAnimations
  68286. * @param nodeMap
  68287. * @param nodes
  68288. * @param binaryWriter
  68289. * @param bufferViews
  68290. * @param accessors
  68291. * @param convertToRightHandedSystem
  68292. */
  68293. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  68294. [key: number]: number;
  68295. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  68296. /**
  68297. * @ignore
  68298. * Create node animations from the animation groups
  68299. * @param babylonScene
  68300. * @param glTFAnimations
  68301. * @param nodeMap
  68302. * @param nodes
  68303. * @param binaryWriter
  68304. * @param bufferViews
  68305. * @param accessors
  68306. * @param convertToRightHandedSystem
  68307. */
  68308. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  68309. [key: number]: number;
  68310. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  68311. private static AddAnimation;
  68312. /**
  68313. * Create a baked animation
  68314. * @param babylonTransformNode BabylonJS mesh
  68315. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  68316. * @param animationChannelTargetPath animation target channel
  68317. * @param minFrame minimum animation frame
  68318. * @param maxFrame maximum animation frame
  68319. * @param fps frames per second of the animation
  68320. * @param inputs input key frames of the animation
  68321. * @param outputs output key frame data of the animation
  68322. * @param convertToRightHandedSystem converts the values to right-handed
  68323. * @param useQuaternion specifies if quaternions should be used
  68324. */
  68325. private static _CreateBakedAnimation;
  68326. private static _ConvertFactorToVector3OrQuaternion;
  68327. private static _SetInterpolatedValue;
  68328. /**
  68329. * Creates linear animation from the animation key frames
  68330. * @param babylonTransformNode BabylonJS mesh
  68331. * @param animation BabylonJS animation
  68332. * @param animationChannelTargetPath The target animation channel
  68333. * @param frameDelta The difference between the last and first frame of the animation
  68334. * @param inputs Array to store the key frame times
  68335. * @param outputs Array to store the key frame data
  68336. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  68337. * @param useQuaternion Specifies if quaternions are used in the animation
  68338. */
  68339. private static _CreateLinearOrStepAnimation;
  68340. /**
  68341. * Creates cubic spline animation from the animation key frames
  68342. * @param babylonTransformNode BabylonJS mesh
  68343. * @param animation BabylonJS animation
  68344. * @param animationChannelTargetPath The target animation channel
  68345. * @param frameDelta The difference between the last and first frame of the animation
  68346. * @param inputs Array to store the key frame times
  68347. * @param outputs Array to store the key frame data
  68348. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  68349. * @param useQuaternion Specifies if quaternions are used in the animation
  68350. */
  68351. private static _CreateCubicSplineAnimation;
  68352. private static _GetBasePositionRotationOrScale;
  68353. /**
  68354. * Adds a key frame value
  68355. * @param keyFrame
  68356. * @param animation
  68357. * @param outputs
  68358. * @param animationChannelTargetPath
  68359. * @param basePositionRotationOrScale
  68360. * @param convertToRightHandedSystem
  68361. * @param useQuaternion
  68362. */
  68363. private static _AddKeyframeValue;
  68364. /**
  68365. * Determine the interpolation based on the key frames
  68366. * @param keyFrames
  68367. * @param animationChannelTargetPath
  68368. * @param useQuaternion
  68369. */
  68370. private static _DeduceInterpolation;
  68371. /**
  68372. * Adds an input tangent or output tangent to the output data
  68373. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  68374. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  68375. * @param outputs The animation data by keyframe
  68376. * @param animationChannelTargetPath The target animation channel
  68377. * @param interpolation The interpolation type
  68378. * @param keyFrame The key frame with the animation data
  68379. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  68380. * @param useQuaternion Specifies if quaternions are used
  68381. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  68382. */
  68383. private static AddSplineTangent;
  68384. /**
  68385. * Get the minimum and maximum key frames' frame values
  68386. * @param keyFrames animation key frames
  68387. * @returns the minimum and maximum key frame value
  68388. */
  68389. private static calculateMinMaxKeyFrames;
  68390. }
  68391. }
  68392. declare module BABYLON.GLTF2.Exporter {
  68393. /** @hidden */
  68394. export var textureTransformPixelShader: {
  68395. name: string;
  68396. shader: string;
  68397. };
  68398. }
  68399. declare module BABYLON.GLTF2.Exporter.Extensions {
  68400. /**
  68401. * @hidden
  68402. */
  68403. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  68404. /** Name of this extension */
  68405. readonly name: string;
  68406. /** Defines whether this extension is enabled */
  68407. enabled: boolean;
  68408. /** Defines whether this extension is required */
  68409. required: boolean;
  68410. /** Reference to the glTF exporter */
  68411. private _exporter;
  68412. constructor(exporter: _Exporter);
  68413. dispose(): void;
  68414. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  68415. /**
  68416. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  68417. * @param babylonTexture
  68418. * @param offset
  68419. * @param rotation
  68420. * @param scale
  68421. * @param scene
  68422. */
  68423. private _textureTransformTextureAsync;
  68424. }
  68425. }
  68426. declare module BABYLON.GLTF2.Exporter.Extensions {
  68427. /**
  68428. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  68429. */
  68430. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  68431. /** The name of this extension. */
  68432. readonly name: string;
  68433. /** Defines whether this extension is enabled. */
  68434. enabled: boolean;
  68435. /** Defines whether this extension is required */
  68436. required: boolean;
  68437. /** Reference to the glTF exporter */
  68438. private _exporter;
  68439. private _lights;
  68440. /** @hidden */
  68441. constructor(exporter: _Exporter);
  68442. /** @hidden */
  68443. dispose(): void;
  68444. /** @hidden */
  68445. onExporting(): void;
  68446. /**
  68447. * Define this method to modify the default behavior when exporting a node
  68448. * @param context The context when exporting the node
  68449. * @param node glTF node
  68450. * @param babylonNode BabylonJS node
  68451. * @returns nullable INode promise
  68452. */
  68453. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  68454. }
  68455. }
  68456. declare module BABYLON {
  68457. /**
  68458. * Class for generating STL data from a Babylon scene.
  68459. */
  68460. export class STLExport {
  68461. /**
  68462. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  68463. * @param meshes list defines the mesh to serialize
  68464. * @param download triggers the automatic download of the file.
  68465. * @param fileName changes the downloads fileName.
  68466. * @param binary changes the STL to a binary type.
  68467. * @param isLittleEndian toggle for binary type exporter.
  68468. * @returns the STL as UTF8 string
  68469. */
  68470. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  68471. }
  68472. }
  68473. /**
  68474. * @ignoreChildren
  68475. * @ignore
  68476. */
  68477. declare module "babylonjs-gltf2interface" {
  68478. export = BABYLON.GLTF2;
  68479. }
  68480. /**
  68481. * Module for glTF 2.0 Interface
  68482. * @ignoreChildren
  68483. * @ignore
  68484. */
  68485. declare module BABYLON.GLTF2 {
  68486. /**
  68487. * The datatype of the components in the attribute
  68488. */
  68489. const enum AccessorComponentType {
  68490. /**
  68491. * Byte
  68492. */
  68493. BYTE = 5120,
  68494. /**
  68495. * Unsigned Byte
  68496. */
  68497. UNSIGNED_BYTE = 5121,
  68498. /**
  68499. * Short
  68500. */
  68501. SHORT = 5122,
  68502. /**
  68503. * Unsigned Short
  68504. */
  68505. UNSIGNED_SHORT = 5123,
  68506. /**
  68507. * Unsigned Int
  68508. */
  68509. UNSIGNED_INT = 5125,
  68510. /**
  68511. * Float
  68512. */
  68513. FLOAT = 5126,
  68514. }
  68515. /**
  68516. * Specifies if the attirbute is a scalar, vector, or matrix
  68517. */
  68518. const enum AccessorType {
  68519. /**
  68520. * Scalar
  68521. */
  68522. SCALAR = "SCALAR",
  68523. /**
  68524. * Vector2
  68525. */
  68526. VEC2 = "VEC2",
  68527. /**
  68528. * Vector3
  68529. */
  68530. VEC3 = "VEC3",
  68531. /**
  68532. * Vector4
  68533. */
  68534. VEC4 = "VEC4",
  68535. /**
  68536. * Matrix2x2
  68537. */
  68538. MAT2 = "MAT2",
  68539. /**
  68540. * Matrix3x3
  68541. */
  68542. MAT3 = "MAT3",
  68543. /**
  68544. * Matrix4x4
  68545. */
  68546. MAT4 = "MAT4",
  68547. }
  68548. /**
  68549. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  68550. */
  68551. const enum AnimationChannelTargetPath {
  68552. /**
  68553. * Translation
  68554. */
  68555. TRANSLATION = "translation",
  68556. /**
  68557. * Rotation
  68558. */
  68559. ROTATION = "rotation",
  68560. /**
  68561. * Scale
  68562. */
  68563. SCALE = "scale",
  68564. /**
  68565. * Weights
  68566. */
  68567. WEIGHTS = "weights",
  68568. }
  68569. /**
  68570. * Interpolation algorithm
  68571. */
  68572. const enum AnimationSamplerInterpolation {
  68573. /**
  68574. * The animated values are linearly interpolated between keyframes
  68575. */
  68576. LINEAR = "LINEAR",
  68577. /**
  68578. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  68579. */
  68580. STEP = "STEP",
  68581. /**
  68582. * The animation's interpolation is computed using a cubic spline with specified tangents
  68583. */
  68584. CUBICSPLINE = "CUBICSPLINE",
  68585. }
  68586. /**
  68587. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  68588. */
  68589. const enum CameraType {
  68590. /**
  68591. * A perspective camera containing properties to create a perspective projection matrix
  68592. */
  68593. PERSPECTIVE = "perspective",
  68594. /**
  68595. * An orthographic camera containing properties to create an orthographic projection matrix
  68596. */
  68597. ORTHOGRAPHIC = "orthographic",
  68598. }
  68599. /**
  68600. * The mime-type of the image
  68601. */
  68602. const enum ImageMimeType {
  68603. /**
  68604. * JPEG Mime-type
  68605. */
  68606. JPEG = "image/jpeg",
  68607. /**
  68608. * PNG Mime-type
  68609. */
  68610. PNG = "image/png",
  68611. }
  68612. /**
  68613. * The alpha rendering mode of the material
  68614. */
  68615. const enum MaterialAlphaMode {
  68616. /**
  68617. * The alpha value is ignored and the rendered output is fully opaque
  68618. */
  68619. OPAQUE = "OPAQUE",
  68620. /**
  68621. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  68622. */
  68623. MASK = "MASK",
  68624. /**
  68625. * 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)
  68626. */
  68627. BLEND = "BLEND",
  68628. }
  68629. /**
  68630. * The type of the primitives to render
  68631. */
  68632. const enum MeshPrimitiveMode {
  68633. /**
  68634. * Points
  68635. */
  68636. POINTS = 0,
  68637. /**
  68638. * Lines
  68639. */
  68640. LINES = 1,
  68641. /**
  68642. * Line Loop
  68643. */
  68644. LINE_LOOP = 2,
  68645. /**
  68646. * Line Strip
  68647. */
  68648. LINE_STRIP = 3,
  68649. /**
  68650. * Triangles
  68651. */
  68652. TRIANGLES = 4,
  68653. /**
  68654. * Triangle Strip
  68655. */
  68656. TRIANGLE_STRIP = 5,
  68657. /**
  68658. * Triangle Fan
  68659. */
  68660. TRIANGLE_FAN = 6,
  68661. }
  68662. /**
  68663. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  68664. */
  68665. const enum TextureMagFilter {
  68666. /**
  68667. * Nearest
  68668. */
  68669. NEAREST = 9728,
  68670. /**
  68671. * Linear
  68672. */
  68673. LINEAR = 9729,
  68674. }
  68675. /**
  68676. * Minification filter. All valid values correspond to WebGL enums
  68677. */
  68678. const enum TextureMinFilter {
  68679. /**
  68680. * Nearest
  68681. */
  68682. NEAREST = 9728,
  68683. /**
  68684. * Linear
  68685. */
  68686. LINEAR = 9729,
  68687. /**
  68688. * Nearest Mip-Map Nearest
  68689. */
  68690. NEAREST_MIPMAP_NEAREST = 9984,
  68691. /**
  68692. * Linear Mipmap Nearest
  68693. */
  68694. LINEAR_MIPMAP_NEAREST = 9985,
  68695. /**
  68696. * Nearest Mipmap Linear
  68697. */
  68698. NEAREST_MIPMAP_LINEAR = 9986,
  68699. /**
  68700. * Linear Mipmap Linear
  68701. */
  68702. LINEAR_MIPMAP_LINEAR = 9987,
  68703. }
  68704. /**
  68705. * S (U) wrapping mode. All valid values correspond to WebGL enums
  68706. */
  68707. const enum TextureWrapMode {
  68708. /**
  68709. * Clamp to Edge
  68710. */
  68711. CLAMP_TO_EDGE = 33071,
  68712. /**
  68713. * Mirrored Repeat
  68714. */
  68715. MIRRORED_REPEAT = 33648,
  68716. /**
  68717. * Repeat
  68718. */
  68719. REPEAT = 10497,
  68720. }
  68721. /**
  68722. * glTF Property
  68723. */
  68724. interface IProperty {
  68725. /**
  68726. * Dictionary object with extension-specific objects
  68727. */
  68728. extensions?: {
  68729. [key: string]: any;
  68730. };
  68731. /**
  68732. * Application-Specific data
  68733. */
  68734. extras?: any;
  68735. }
  68736. /**
  68737. * glTF Child of Root Property
  68738. */
  68739. interface IChildRootProperty extends IProperty {
  68740. /**
  68741. * The user-defined name of this object
  68742. */
  68743. name?: string;
  68744. }
  68745. /**
  68746. * Indices of those attributes that deviate from their initialization value
  68747. */
  68748. interface IAccessorSparseIndices extends IProperty {
  68749. /**
  68750. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  68751. */
  68752. bufferView: number;
  68753. /**
  68754. * The offset relative to the start of the bufferView in bytes. Must be aligned
  68755. */
  68756. byteOffset?: number;
  68757. /**
  68758. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  68759. */
  68760. componentType: AccessorComponentType;
  68761. }
  68762. /**
  68763. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  68764. */
  68765. interface IAccessorSparseValues extends IProperty {
  68766. /**
  68767. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  68768. */
  68769. bufferView: number;
  68770. /**
  68771. * The offset relative to the start of the bufferView in bytes. Must be aligned
  68772. */
  68773. byteOffset?: number;
  68774. }
  68775. /**
  68776. * Sparse storage of attributes that deviate from their initialization value
  68777. */
  68778. interface IAccessorSparse extends IProperty {
  68779. /**
  68780. * The number of attributes encoded in this sparse accessor
  68781. */
  68782. count: number;
  68783. /**
  68784. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  68785. */
  68786. indices: IAccessorSparseIndices;
  68787. /**
  68788. * 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
  68789. */
  68790. values: IAccessorSparseValues;
  68791. }
  68792. /**
  68793. * 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
  68794. */
  68795. interface IAccessor extends IChildRootProperty {
  68796. /**
  68797. * The index of the bufferview
  68798. */
  68799. bufferView?: number;
  68800. /**
  68801. * The offset relative to the start of the bufferView in bytes
  68802. */
  68803. byteOffset?: number;
  68804. /**
  68805. * The datatype of components in the attribute
  68806. */
  68807. componentType: AccessorComponentType;
  68808. /**
  68809. * Specifies whether integer data values should be normalized
  68810. */
  68811. normalized?: boolean;
  68812. /**
  68813. * The number of attributes referenced by this accessor
  68814. */
  68815. count: number;
  68816. /**
  68817. * Specifies if the attribute is a scalar, vector, or matrix
  68818. */
  68819. type: AccessorType;
  68820. /**
  68821. * Maximum value of each component in this attribute
  68822. */
  68823. max?: number[];
  68824. /**
  68825. * Minimum value of each component in this attribute
  68826. */
  68827. min?: number[];
  68828. /**
  68829. * Sparse storage of attributes that deviate from their initialization value
  68830. */
  68831. sparse?: IAccessorSparse;
  68832. }
  68833. /**
  68834. * Targets an animation's sampler at a node's property
  68835. */
  68836. interface IAnimationChannel extends IProperty {
  68837. /**
  68838. * The index of a sampler in this animation used to compute the value for the target
  68839. */
  68840. sampler: number;
  68841. /**
  68842. * The index of the node and TRS property to target
  68843. */
  68844. target: IAnimationChannelTarget;
  68845. }
  68846. /**
  68847. * The index of the node and TRS property that an animation channel targets
  68848. */
  68849. interface IAnimationChannelTarget extends IProperty {
  68850. /**
  68851. * The index of the node to target
  68852. */
  68853. node: number;
  68854. /**
  68855. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  68856. */
  68857. path: AnimationChannelTargetPath;
  68858. }
  68859. /**
  68860. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  68861. */
  68862. interface IAnimationSampler extends IProperty {
  68863. /**
  68864. * The index of an accessor containing keyframe input values, e.g., time
  68865. */
  68866. input: number;
  68867. /**
  68868. * Interpolation algorithm
  68869. */
  68870. interpolation?: AnimationSamplerInterpolation;
  68871. /**
  68872. * The index of an accessor, containing keyframe output values
  68873. */
  68874. output: number;
  68875. }
  68876. /**
  68877. * A keyframe animation
  68878. */
  68879. interface IAnimation extends IChildRootProperty {
  68880. /**
  68881. * An array of channels, each of which targets an animation's sampler at a node's property
  68882. */
  68883. channels: IAnimationChannel[];
  68884. /**
  68885. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  68886. */
  68887. samplers: IAnimationSampler[];
  68888. }
  68889. /**
  68890. * Metadata about the glTF asset
  68891. */
  68892. interface IAsset extends IChildRootProperty {
  68893. /**
  68894. * A copyright message suitable for display to credit the content creator
  68895. */
  68896. copyright?: string;
  68897. /**
  68898. * Tool that generated this glTF model. Useful for debugging
  68899. */
  68900. generator?: string;
  68901. /**
  68902. * The glTF version that this asset targets
  68903. */
  68904. version: string;
  68905. /**
  68906. * The minimum glTF version that this asset targets
  68907. */
  68908. minVersion?: string;
  68909. }
  68910. /**
  68911. * A buffer points to binary geometry, animation, or skins
  68912. */
  68913. interface IBuffer extends IChildRootProperty {
  68914. /**
  68915. * 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
  68916. */
  68917. uri?: string;
  68918. /**
  68919. * The length of the buffer in bytes
  68920. */
  68921. byteLength: number;
  68922. }
  68923. /**
  68924. * A view into a buffer generally representing a subset of the buffer
  68925. */
  68926. interface IBufferView extends IChildRootProperty {
  68927. /**
  68928. * The index of the buffer
  68929. */
  68930. buffer: number;
  68931. /**
  68932. * The offset into the buffer in bytes
  68933. */
  68934. byteOffset?: number;
  68935. /**
  68936. * The lenth of the bufferView in bytes
  68937. */
  68938. byteLength: number;
  68939. /**
  68940. * The stride, in bytes
  68941. */
  68942. byteStride?: number;
  68943. }
  68944. /**
  68945. * An orthographic camera containing properties to create an orthographic projection matrix
  68946. */
  68947. interface ICameraOrthographic extends IProperty {
  68948. /**
  68949. * The floating-point horizontal magnification of the view. Must not be zero
  68950. */
  68951. xmag: number;
  68952. /**
  68953. * The floating-point vertical magnification of the view. Must not be zero
  68954. */
  68955. ymag: number;
  68956. /**
  68957. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  68958. */
  68959. zfar: number;
  68960. /**
  68961. * The floating-point distance to the near clipping plane
  68962. */
  68963. znear: number;
  68964. }
  68965. /**
  68966. * A perspective camera containing properties to create a perspective projection matrix
  68967. */
  68968. interface ICameraPerspective extends IProperty {
  68969. /**
  68970. * The floating-point aspect ratio of the field of view
  68971. */
  68972. aspectRatio?: number;
  68973. /**
  68974. * The floating-point vertical field of view in radians
  68975. */
  68976. yfov: number;
  68977. /**
  68978. * The floating-point distance to the far clipping plane
  68979. */
  68980. zfar?: number;
  68981. /**
  68982. * The floating-point distance to the near clipping plane
  68983. */
  68984. znear: number;
  68985. }
  68986. /**
  68987. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  68988. */
  68989. interface ICamera extends IChildRootProperty {
  68990. /**
  68991. * An orthographic camera containing properties to create an orthographic projection matrix
  68992. */
  68993. orthographic?: ICameraOrthographic;
  68994. /**
  68995. * A perspective camera containing properties to create a perspective projection matrix
  68996. */
  68997. perspective?: ICameraPerspective;
  68998. /**
  68999. * Specifies if the camera uses a perspective or orthographic projection
  69000. */
  69001. type: CameraType;
  69002. }
  69003. /**
  69004. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  69005. */
  69006. interface IImage extends IChildRootProperty {
  69007. /**
  69008. * 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
  69009. */
  69010. uri?: string;
  69011. /**
  69012. * The image's MIME type
  69013. */
  69014. mimeType?: ImageMimeType;
  69015. /**
  69016. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  69017. */
  69018. bufferView?: number;
  69019. }
  69020. /**
  69021. * Material Normal Texture Info
  69022. */
  69023. interface IMaterialNormalTextureInfo extends ITextureInfo {
  69024. /**
  69025. * The scalar multiplier applied to each normal vector of the normal texture
  69026. */
  69027. scale?: number;
  69028. }
  69029. /**
  69030. * Material Occlusion Texture Info
  69031. */
  69032. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  69033. /**
  69034. * A scalar multiplier controlling the amount of occlusion applied
  69035. */
  69036. strength?: number;
  69037. }
  69038. /**
  69039. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  69040. */
  69041. interface IMaterialPbrMetallicRoughness {
  69042. /**
  69043. * The material's base color factor
  69044. */
  69045. baseColorFactor?: number[];
  69046. /**
  69047. * The base color texture
  69048. */
  69049. baseColorTexture?: ITextureInfo;
  69050. /**
  69051. * The metalness of the material
  69052. */
  69053. metallicFactor?: number;
  69054. /**
  69055. * The roughness of the material
  69056. */
  69057. roughnessFactor?: number;
  69058. /**
  69059. * The metallic-roughness texture
  69060. */
  69061. metallicRoughnessTexture?: ITextureInfo;
  69062. }
  69063. /**
  69064. * The material appearance of a primitive
  69065. */
  69066. interface IMaterial extends IChildRootProperty {
  69067. /**
  69068. * 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
  69069. */
  69070. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  69071. /**
  69072. * The normal map texture
  69073. */
  69074. normalTexture?: IMaterialNormalTextureInfo;
  69075. /**
  69076. * The occlusion map texture
  69077. */
  69078. occlusionTexture?: IMaterialOcclusionTextureInfo;
  69079. /**
  69080. * The emissive map texture
  69081. */
  69082. emissiveTexture?: ITextureInfo;
  69083. /**
  69084. * 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
  69085. */
  69086. emissiveFactor?: number[];
  69087. /**
  69088. * The alpha rendering mode of the material
  69089. */
  69090. alphaMode?: MaterialAlphaMode;
  69091. /**
  69092. * The alpha cutoff value of the material
  69093. */
  69094. alphaCutoff?: number;
  69095. /**
  69096. * Specifies whether the material is double sided
  69097. */
  69098. doubleSided?: boolean;
  69099. }
  69100. /**
  69101. * Geometry to be rendered with the given material
  69102. */
  69103. interface IMeshPrimitive extends IProperty {
  69104. /**
  69105. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  69106. */
  69107. attributes: {
  69108. [name: string]: number;
  69109. };
  69110. /**
  69111. * The index of the accessor that contains the indices
  69112. */
  69113. indices?: number;
  69114. /**
  69115. * The index of the material to apply to this primitive when rendering
  69116. */
  69117. material?: number;
  69118. /**
  69119. * The type of primitives to render. All valid values correspond to WebGL enums
  69120. */
  69121. mode?: MeshPrimitiveMode;
  69122. /**
  69123. * 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
  69124. */
  69125. targets?: {
  69126. [name: string]: number;
  69127. }[];
  69128. }
  69129. /**
  69130. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  69131. */
  69132. interface IMesh extends IChildRootProperty {
  69133. /**
  69134. * An array of primitives, each defining geometry to be rendered with a material
  69135. */
  69136. primitives: IMeshPrimitive[];
  69137. /**
  69138. * Array of weights to be applied to the Morph Targets
  69139. */
  69140. weights?: number[];
  69141. }
  69142. /**
  69143. * A node in the node hierarchy
  69144. */
  69145. interface INode extends IChildRootProperty {
  69146. /**
  69147. * The index of the camera referenced by this node
  69148. */
  69149. camera?: number;
  69150. /**
  69151. * The indices of this node's children
  69152. */
  69153. children?: number[];
  69154. /**
  69155. * The index of the skin referenced by this node
  69156. */
  69157. skin?: number;
  69158. /**
  69159. * A floating-point 4x4 transformation matrix stored in column-major order
  69160. */
  69161. matrix?: number[];
  69162. /**
  69163. * The index of the mesh in this node
  69164. */
  69165. mesh?: number;
  69166. /**
  69167. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  69168. */
  69169. rotation?: number[];
  69170. /**
  69171. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  69172. */
  69173. scale?: number[];
  69174. /**
  69175. * The node's translation along the x, y, and z axes
  69176. */
  69177. translation?: number[];
  69178. /**
  69179. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  69180. */
  69181. weights?: number[];
  69182. }
  69183. /**
  69184. * Texture sampler properties for filtering and wrapping modes
  69185. */
  69186. interface ISampler extends IChildRootProperty {
  69187. /**
  69188. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  69189. */
  69190. magFilter?: TextureMagFilter;
  69191. /**
  69192. * Minification filter. All valid values correspond to WebGL enums
  69193. */
  69194. minFilter?: TextureMinFilter;
  69195. /**
  69196. * S (U) wrapping mode. All valid values correspond to WebGL enums
  69197. */
  69198. wrapS?: TextureWrapMode;
  69199. /**
  69200. * T (V) wrapping mode. All valid values correspond to WebGL enums
  69201. */
  69202. wrapT?: TextureWrapMode;
  69203. }
  69204. /**
  69205. * The root nodes of a scene
  69206. */
  69207. interface IScene extends IChildRootProperty {
  69208. /**
  69209. * The indices of each root node
  69210. */
  69211. nodes: number[];
  69212. }
  69213. /**
  69214. * Joints and matrices defining a skin
  69215. */
  69216. interface ISkin extends IChildRootProperty {
  69217. /**
  69218. * 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
  69219. */
  69220. inverseBindMatrices?: number;
  69221. /**
  69222. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  69223. */
  69224. skeleton?: number;
  69225. /**
  69226. * 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)
  69227. */
  69228. joints: number[];
  69229. }
  69230. /**
  69231. * A texture and its sampler
  69232. */
  69233. interface ITexture extends IChildRootProperty {
  69234. /**
  69235. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  69236. */
  69237. sampler?: number;
  69238. /**
  69239. * The index of the image used by this texture
  69240. */
  69241. source: number;
  69242. }
  69243. /**
  69244. * Reference to a texture
  69245. */
  69246. interface ITextureInfo extends IProperty {
  69247. /**
  69248. * The index of the texture
  69249. */
  69250. index: number;
  69251. /**
  69252. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  69253. */
  69254. texCoord?: number;
  69255. }
  69256. /**
  69257. * The root object for a glTF asset
  69258. */
  69259. interface IGLTF extends IProperty {
  69260. /**
  69261. * An array of accessors. An accessor is a typed view into a bufferView
  69262. */
  69263. accessors?: IAccessor[];
  69264. /**
  69265. * An array of keyframe animations
  69266. */
  69267. animations?: IAnimation[];
  69268. /**
  69269. * Metadata about the glTF asset
  69270. */
  69271. asset: IAsset;
  69272. /**
  69273. * An array of buffers. A buffer points to binary geometry, animation, or skins
  69274. */
  69275. buffers?: IBuffer[];
  69276. /**
  69277. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  69278. */
  69279. bufferViews?: IBufferView[];
  69280. /**
  69281. * An array of cameras
  69282. */
  69283. cameras?: ICamera[];
  69284. /**
  69285. * Names of glTF extensions used somewhere in this asset
  69286. */
  69287. extensionsUsed?: string[];
  69288. /**
  69289. * Names of glTF extensions required to properly load this asset
  69290. */
  69291. extensionsRequired?: string[];
  69292. /**
  69293. * An array of images. An image defines data used to create a texture
  69294. */
  69295. images?: IImage[];
  69296. /**
  69297. * An array of materials. A material defines the appearance of a primitive
  69298. */
  69299. materials?: IMaterial[];
  69300. /**
  69301. * An array of meshes. A mesh is a set of primitives to be rendered
  69302. */
  69303. meshes?: IMesh[];
  69304. /**
  69305. * An array of nodes
  69306. */
  69307. nodes?: INode[];
  69308. /**
  69309. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  69310. */
  69311. samplers?: ISampler[];
  69312. /**
  69313. * The index of the default scene
  69314. */
  69315. scene?: number;
  69316. /**
  69317. * An array of scenes
  69318. */
  69319. scenes?: IScene[];
  69320. /**
  69321. * An array of skins. A skin is defined by joints and matrices
  69322. */
  69323. skins?: ISkin[];
  69324. /**
  69325. * An array of textures
  69326. */
  69327. textures?: ITexture[];
  69328. }
  69329. /**
  69330. * The glTF validation results
  69331. */
  69332. interface IGLTFValidationResults {
  69333. info: {
  69334. generator: string;
  69335. hasAnimations: boolean;
  69336. hasDefaultScene: boolean;
  69337. hasMaterials: boolean;
  69338. hasMorphTargets: boolean;
  69339. hasSkins: boolean;
  69340. hasTextures: boolean;
  69341. maxAttributesUsed: number;
  69342. primitivesCount: number
  69343. };
  69344. issues: {
  69345. messages: Array<string>;
  69346. numErrors: number;
  69347. numHints: number;
  69348. numInfos: number;
  69349. numWarnings: number;
  69350. truncated: boolean
  69351. };
  69352. mimeType: string;
  69353. uri: string;
  69354. validatedAt: string;
  69355. validatorVersion: string;
  69356. }
  69357. /**
  69358. * The glTF validation options
  69359. */
  69360. interface IGLTFValidationOptions {
  69361. uri?: string;
  69362. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  69363. validateAccessorData?: boolean;
  69364. maxIssues?: number;
  69365. ignoredIssues?: Array<string>;
  69366. severityOverrides?: Object;
  69367. }
  69368. /**
  69369. * The glTF validator object
  69370. */
  69371. interface IGLTFValidator {
  69372. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  69373. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  69374. }
  69375. }
  69376. declare module BABYLON {
  69377. /** @hidden */
  69378. export var cellPixelShader: {
  69379. name: string;
  69380. shader: string;
  69381. };
  69382. }
  69383. declare module BABYLON {
  69384. /** @hidden */
  69385. export var cellVertexShader: {
  69386. name: string;
  69387. shader: string;
  69388. };
  69389. }
  69390. declare module BABYLON {
  69391. export class CellMaterial extends BABYLON.PushMaterial {
  69392. private _diffuseTexture;
  69393. diffuseTexture: BABYLON.BaseTexture;
  69394. diffuseColor: BABYLON.Color3;
  69395. _computeHighLevel: boolean;
  69396. computeHighLevel: boolean;
  69397. private _disableLighting;
  69398. disableLighting: boolean;
  69399. private _maxSimultaneousLights;
  69400. maxSimultaneousLights: number;
  69401. private _renderId;
  69402. constructor(name: string, scene: BABYLON.Scene);
  69403. needAlphaBlending(): boolean;
  69404. needAlphaTesting(): boolean;
  69405. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69406. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69407. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69408. getAnimatables(): BABYLON.IAnimatable[];
  69409. getActiveTextures(): BABYLON.BaseTexture[];
  69410. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69411. dispose(forceDisposeEffect?: boolean): void;
  69412. getClassName(): string;
  69413. clone(name: string): CellMaterial;
  69414. serialize(): any;
  69415. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  69416. }
  69417. }
  69418. declare module BABYLON {
  69419. export class CustomShaderStructure {
  69420. FragmentStore: string;
  69421. VertexStore: string;
  69422. constructor();
  69423. }
  69424. export class ShaderSpecialParts {
  69425. constructor();
  69426. Fragment_Begin: string;
  69427. Fragment_Definitions: string;
  69428. Fragment_MainBegin: string;
  69429. Fragment_Custom_Diffuse: string;
  69430. Fragment_Before_Lights: string;
  69431. Fragment_Before_Fog: string;
  69432. Fragment_Custom_Alpha: string;
  69433. Fragment_Before_FragColor: string;
  69434. Vertex_Begin: string;
  69435. Vertex_Definitions: string;
  69436. Vertex_MainBegin: string;
  69437. Vertex_Before_PositionUpdated: string;
  69438. Vertex_Before_NormalUpdated: string;
  69439. Vertex_MainEnd: string;
  69440. }
  69441. export class CustomMaterial extends BABYLON.StandardMaterial {
  69442. static ShaderIndexer: number;
  69443. CustomParts: ShaderSpecialParts;
  69444. _isCreatedShader: boolean;
  69445. _createdShaderName: string;
  69446. _customUniform: string[];
  69447. _newUniforms: string[];
  69448. _newUniformInstances: any[];
  69449. _newSamplerInstances: BABYLON.Texture[];
  69450. FragmentShader: string;
  69451. VertexShader: string;
  69452. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  69453. ReviewUniform(name: string, arr: string[]): string[];
  69454. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  69455. constructor(name: string, scene: BABYLON.Scene);
  69456. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  69457. Fragment_Begin(shaderPart: string): CustomMaterial;
  69458. Fragment_Definitions(shaderPart: string): CustomMaterial;
  69459. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  69460. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  69461. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  69462. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  69463. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  69464. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  69465. Vertex_Begin(shaderPart: string): CustomMaterial;
  69466. Vertex_Definitions(shaderPart: string): CustomMaterial;
  69467. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  69468. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  69469. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  69470. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  69471. }
  69472. }
  69473. declare module BABYLON {
  69474. export class ShaderAlebdoParts {
  69475. constructor();
  69476. Fragment_Begin: string;
  69477. Fragment_Definitions: string;
  69478. Fragment_MainBegin: string;
  69479. Fragment_Custom_Albedo: string;
  69480. Fragment_Before_Lights: string;
  69481. Fragment_Custom_MetallicRoughness: string;
  69482. Fragment_Custom_MicroSurface: string;
  69483. Fragment_Before_Fog: string;
  69484. Fragment_Custom_Alpha: string;
  69485. Fragment_Before_FragColor: string;
  69486. Vertex_Begin: string;
  69487. Vertex_Definitions: string;
  69488. Vertex_MainBegin: string;
  69489. Vertex_Before_PositionUpdated: string;
  69490. Vertex_Before_NormalUpdated: string;
  69491. Vertex_MainEnd: string;
  69492. }
  69493. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  69494. static ShaderIndexer: number;
  69495. CustomParts: ShaderAlebdoParts;
  69496. _isCreatedShader: boolean;
  69497. _createdShaderName: string;
  69498. _customUniform: string[];
  69499. _newUniforms: string[];
  69500. _newUniformInstances: any[];
  69501. _newSamplerInstances: BABYLON.Texture[];
  69502. FragmentShader: string;
  69503. VertexShader: string;
  69504. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  69505. ReviewUniform(name: string, arr: string[]): string[];
  69506. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  69507. constructor(name: string, scene: BABYLON.Scene);
  69508. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  69509. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  69510. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  69511. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  69512. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  69513. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  69514. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  69515. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  69516. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  69517. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  69518. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  69519. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  69520. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  69521. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  69522. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  69523. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  69524. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  69525. }
  69526. }
  69527. declare module BABYLON {
  69528. /** @hidden */
  69529. export var firePixelShader: {
  69530. name: string;
  69531. shader: string;
  69532. };
  69533. }
  69534. declare module BABYLON {
  69535. /** @hidden */
  69536. export var fireVertexShader: {
  69537. name: string;
  69538. shader: string;
  69539. };
  69540. }
  69541. declare module BABYLON {
  69542. export class FireMaterial extends BABYLON.PushMaterial {
  69543. private _diffuseTexture;
  69544. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  69545. private _distortionTexture;
  69546. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  69547. private _opacityTexture;
  69548. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  69549. diffuseColor: BABYLON.Color3;
  69550. speed: number;
  69551. private _scaledDiffuse;
  69552. private _renderId;
  69553. private _lastTime;
  69554. constructor(name: string, scene: BABYLON.Scene);
  69555. needAlphaBlending(): boolean;
  69556. needAlphaTesting(): boolean;
  69557. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69558. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69559. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69560. getAnimatables(): BABYLON.IAnimatable[];
  69561. getActiveTextures(): BABYLON.BaseTexture[];
  69562. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69563. getClassName(): string;
  69564. dispose(forceDisposeEffect?: boolean): void;
  69565. clone(name: string): FireMaterial;
  69566. serialize(): any;
  69567. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  69568. }
  69569. }
  69570. declare module BABYLON {
  69571. /** @hidden */
  69572. export var furPixelShader: {
  69573. name: string;
  69574. shader: string;
  69575. };
  69576. }
  69577. declare module BABYLON {
  69578. /** @hidden */
  69579. export var furVertexShader: {
  69580. name: string;
  69581. shader: string;
  69582. };
  69583. }
  69584. declare module BABYLON {
  69585. export class FurMaterial extends BABYLON.PushMaterial {
  69586. private _diffuseTexture;
  69587. diffuseTexture: BABYLON.BaseTexture;
  69588. private _heightTexture;
  69589. heightTexture: BABYLON.BaseTexture;
  69590. diffuseColor: BABYLON.Color3;
  69591. furLength: number;
  69592. furAngle: number;
  69593. furColor: BABYLON.Color3;
  69594. furOffset: number;
  69595. furSpacing: number;
  69596. furGravity: BABYLON.Vector3;
  69597. furSpeed: number;
  69598. furDensity: number;
  69599. furOcclusion: number;
  69600. furTexture: BABYLON.DynamicTexture;
  69601. private _disableLighting;
  69602. disableLighting: boolean;
  69603. private _maxSimultaneousLights;
  69604. maxSimultaneousLights: number;
  69605. highLevelFur: boolean;
  69606. _meshes: BABYLON.AbstractMesh[];
  69607. private _renderId;
  69608. private _furTime;
  69609. constructor(name: string, scene: BABYLON.Scene);
  69610. furTime: number;
  69611. needAlphaBlending(): boolean;
  69612. needAlphaTesting(): boolean;
  69613. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69614. updateFur(): void;
  69615. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69616. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69617. getAnimatables(): BABYLON.IAnimatable[];
  69618. getActiveTextures(): BABYLON.BaseTexture[];
  69619. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69620. dispose(forceDisposeEffect?: boolean): void;
  69621. clone(name: string): FurMaterial;
  69622. serialize(): any;
  69623. getClassName(): string;
  69624. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  69625. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  69626. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  69627. }
  69628. }
  69629. declare module BABYLON {
  69630. /** @hidden */
  69631. export var gradientPixelShader: {
  69632. name: string;
  69633. shader: string;
  69634. };
  69635. }
  69636. declare module BABYLON {
  69637. /** @hidden */
  69638. export var gradientVertexShader: {
  69639. name: string;
  69640. shader: string;
  69641. };
  69642. }
  69643. declare module BABYLON {
  69644. export class GradientMaterial extends BABYLON.PushMaterial {
  69645. private _maxSimultaneousLights;
  69646. maxSimultaneousLights: number;
  69647. topColor: BABYLON.Color3;
  69648. topColorAlpha: number;
  69649. bottomColor: BABYLON.Color3;
  69650. bottomColorAlpha: number;
  69651. offset: number;
  69652. scale: number;
  69653. smoothness: number;
  69654. private _disableLighting;
  69655. disableLighting: boolean;
  69656. private _renderId;
  69657. constructor(name: string, scene: BABYLON.Scene);
  69658. needAlphaBlending(): boolean;
  69659. needAlphaTesting(): boolean;
  69660. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69661. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69662. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69663. getAnimatables(): BABYLON.IAnimatable[];
  69664. dispose(forceDisposeEffect?: boolean): void;
  69665. clone(name: string): GradientMaterial;
  69666. serialize(): any;
  69667. getClassName(): string;
  69668. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  69669. }
  69670. }
  69671. declare module BABYLON {
  69672. /** @hidden */
  69673. export var gridPixelShader: {
  69674. name: string;
  69675. shader: string;
  69676. };
  69677. }
  69678. declare module BABYLON {
  69679. /** @hidden */
  69680. export var gridVertexShader: {
  69681. name: string;
  69682. shader: string;
  69683. };
  69684. }
  69685. declare module BABYLON {
  69686. /**
  69687. * The grid materials allows you to wrap any shape with a grid.
  69688. * Colors are customizable.
  69689. */
  69690. export class GridMaterial extends BABYLON.PushMaterial {
  69691. /**
  69692. * Main color of the grid (e.g. between lines)
  69693. */
  69694. mainColor: BABYLON.Color3;
  69695. /**
  69696. * Color of the grid lines.
  69697. */
  69698. lineColor: BABYLON.Color3;
  69699. /**
  69700. * The scale of the grid compared to unit.
  69701. */
  69702. gridRatio: number;
  69703. /**
  69704. * Allows setting an offset for the grid lines.
  69705. */
  69706. gridOffset: BABYLON.Vector3;
  69707. /**
  69708. * The frequency of thicker lines.
  69709. */
  69710. majorUnitFrequency: number;
  69711. /**
  69712. * The visibility of minor units in the grid.
  69713. */
  69714. minorUnitVisibility: number;
  69715. /**
  69716. * The grid opacity outside of the lines.
  69717. */
  69718. opacity: number;
  69719. /**
  69720. * Determine RBG output is premultiplied by alpha value.
  69721. */
  69722. preMultiplyAlpha: boolean;
  69723. private _opacityTexture;
  69724. opacityTexture: BABYLON.BaseTexture;
  69725. private _gridControl;
  69726. private _renderId;
  69727. /**
  69728. * constructor
  69729. * @param name The name given to the material in order to identify it afterwards.
  69730. * @param scene The scene the material is used in.
  69731. */
  69732. constructor(name: string, scene: BABYLON.Scene);
  69733. /**
  69734. * Returns wehter or not the grid requires alpha blending.
  69735. */
  69736. needAlphaBlending(): boolean;
  69737. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  69738. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69739. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69740. /**
  69741. * Dispose the material and its associated resources.
  69742. * @param forceDisposeEffect will also dispose the used effect when true
  69743. */
  69744. dispose(forceDisposeEffect?: boolean): void;
  69745. clone(name: string): GridMaterial;
  69746. serialize(): any;
  69747. getClassName(): string;
  69748. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  69749. }
  69750. }
  69751. declare module BABYLON {
  69752. /** @hidden */
  69753. export var lavaPixelShader: {
  69754. name: string;
  69755. shader: string;
  69756. };
  69757. }
  69758. declare module BABYLON {
  69759. /** @hidden */
  69760. export var lavaVertexShader: {
  69761. name: string;
  69762. shader: string;
  69763. };
  69764. }
  69765. declare module BABYLON {
  69766. export class LavaMaterial extends BABYLON.PushMaterial {
  69767. private _diffuseTexture;
  69768. diffuseTexture: BABYLON.BaseTexture;
  69769. noiseTexture: BABYLON.BaseTexture;
  69770. fogColor: BABYLON.Color3;
  69771. speed: number;
  69772. movingSpeed: number;
  69773. lowFrequencySpeed: number;
  69774. fogDensity: number;
  69775. private _lastTime;
  69776. diffuseColor: BABYLON.Color3;
  69777. private _disableLighting;
  69778. disableLighting: boolean;
  69779. private _unlit;
  69780. unlit: boolean;
  69781. private _maxSimultaneousLights;
  69782. maxSimultaneousLights: number;
  69783. private _scaledDiffuse;
  69784. private _renderId;
  69785. constructor(name: string, scene: BABYLON.Scene);
  69786. needAlphaBlending(): boolean;
  69787. needAlphaTesting(): boolean;
  69788. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69789. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69790. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69791. getAnimatables(): BABYLON.IAnimatable[];
  69792. getActiveTextures(): BABYLON.BaseTexture[];
  69793. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69794. dispose(forceDisposeEffect?: boolean): void;
  69795. clone(name: string): LavaMaterial;
  69796. serialize(): any;
  69797. getClassName(): string;
  69798. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  69799. }
  69800. }
  69801. declare module BABYLON {
  69802. /** @hidden */
  69803. export var mixPixelShader: {
  69804. name: string;
  69805. shader: string;
  69806. };
  69807. }
  69808. declare module BABYLON {
  69809. /** @hidden */
  69810. export var mixVertexShader: {
  69811. name: string;
  69812. shader: string;
  69813. };
  69814. }
  69815. declare module BABYLON {
  69816. export class MixMaterial extends BABYLON.PushMaterial {
  69817. /**
  69818. * Mix textures
  69819. */
  69820. private _mixTexture1;
  69821. mixTexture1: BABYLON.BaseTexture;
  69822. private _mixTexture2;
  69823. mixTexture2: BABYLON.BaseTexture;
  69824. /**
  69825. * Diffuse textures
  69826. */
  69827. private _diffuseTexture1;
  69828. diffuseTexture1: BABYLON.Texture;
  69829. private _diffuseTexture2;
  69830. diffuseTexture2: BABYLON.Texture;
  69831. private _diffuseTexture3;
  69832. diffuseTexture3: BABYLON.Texture;
  69833. private _diffuseTexture4;
  69834. diffuseTexture4: BABYLON.Texture;
  69835. private _diffuseTexture5;
  69836. diffuseTexture5: BABYLON.Texture;
  69837. private _diffuseTexture6;
  69838. diffuseTexture6: BABYLON.Texture;
  69839. private _diffuseTexture7;
  69840. diffuseTexture7: BABYLON.Texture;
  69841. private _diffuseTexture8;
  69842. diffuseTexture8: BABYLON.Texture;
  69843. /**
  69844. * Uniforms
  69845. */
  69846. diffuseColor: BABYLON.Color3;
  69847. specularColor: BABYLON.Color3;
  69848. specularPower: number;
  69849. private _disableLighting;
  69850. disableLighting: boolean;
  69851. private _maxSimultaneousLights;
  69852. maxSimultaneousLights: number;
  69853. private _renderId;
  69854. constructor(name: string, scene: BABYLON.Scene);
  69855. needAlphaBlending(): boolean;
  69856. needAlphaTesting(): boolean;
  69857. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69858. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69859. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69860. getAnimatables(): BABYLON.IAnimatable[];
  69861. getActiveTextures(): BABYLON.BaseTexture[];
  69862. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69863. dispose(forceDisposeEffect?: boolean): void;
  69864. clone(name: string): MixMaterial;
  69865. serialize(): any;
  69866. getClassName(): string;
  69867. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  69868. }
  69869. }
  69870. declare module BABYLON {
  69871. /** @hidden */
  69872. export var normalPixelShader: {
  69873. name: string;
  69874. shader: string;
  69875. };
  69876. }
  69877. declare module BABYLON {
  69878. /** @hidden */
  69879. export var normalVertexShader: {
  69880. name: string;
  69881. shader: string;
  69882. };
  69883. }
  69884. declare module BABYLON {
  69885. export class NormalMaterial extends BABYLON.PushMaterial {
  69886. private _diffuseTexture;
  69887. diffuseTexture: BABYLON.BaseTexture;
  69888. diffuseColor: BABYLON.Color3;
  69889. private _disableLighting;
  69890. disableLighting: boolean;
  69891. private _maxSimultaneousLights;
  69892. maxSimultaneousLights: number;
  69893. private _renderId;
  69894. constructor(name: string, scene: BABYLON.Scene);
  69895. needAlphaBlending(): boolean;
  69896. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  69897. needAlphaTesting(): boolean;
  69898. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69899. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69900. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69901. getAnimatables(): BABYLON.IAnimatable[];
  69902. getActiveTextures(): BABYLON.BaseTexture[];
  69903. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69904. dispose(forceDisposeEffect?: boolean): void;
  69905. clone(name: string): NormalMaterial;
  69906. serialize(): any;
  69907. getClassName(): string;
  69908. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  69909. }
  69910. }
  69911. declare module BABYLON {
  69912. /** @hidden */
  69913. export var shadowOnlyPixelShader: {
  69914. name: string;
  69915. shader: string;
  69916. };
  69917. }
  69918. declare module BABYLON {
  69919. /** @hidden */
  69920. export var shadowOnlyVertexShader: {
  69921. name: string;
  69922. shader: string;
  69923. };
  69924. }
  69925. declare module BABYLON {
  69926. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  69927. private _renderId;
  69928. private _activeLight;
  69929. constructor(name: string, scene: BABYLON.Scene);
  69930. shadowColor: BABYLON.Color3;
  69931. needAlphaBlending(): boolean;
  69932. needAlphaTesting(): boolean;
  69933. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69934. activeLight: BABYLON.IShadowLight;
  69935. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69936. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69937. clone(name: string): ShadowOnlyMaterial;
  69938. serialize(): any;
  69939. getClassName(): string;
  69940. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  69941. }
  69942. }
  69943. declare module BABYLON {
  69944. /** @hidden */
  69945. export var simplePixelShader: {
  69946. name: string;
  69947. shader: string;
  69948. };
  69949. }
  69950. declare module BABYLON {
  69951. /** @hidden */
  69952. export var simpleVertexShader: {
  69953. name: string;
  69954. shader: string;
  69955. };
  69956. }
  69957. declare module BABYLON {
  69958. export class SimpleMaterial extends BABYLON.PushMaterial {
  69959. private _diffuseTexture;
  69960. diffuseTexture: BABYLON.BaseTexture;
  69961. diffuseColor: BABYLON.Color3;
  69962. private _disableLighting;
  69963. disableLighting: boolean;
  69964. private _maxSimultaneousLights;
  69965. maxSimultaneousLights: number;
  69966. private _renderId;
  69967. constructor(name: string, scene: BABYLON.Scene);
  69968. needAlphaBlending(): boolean;
  69969. needAlphaTesting(): boolean;
  69970. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69971. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69972. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69973. getAnimatables(): BABYLON.IAnimatable[];
  69974. getActiveTextures(): BABYLON.BaseTexture[];
  69975. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69976. dispose(forceDisposeEffect?: boolean): void;
  69977. clone(name: string): SimpleMaterial;
  69978. serialize(): any;
  69979. getClassName(): string;
  69980. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  69981. }
  69982. }
  69983. declare module BABYLON {
  69984. /** @hidden */
  69985. export var skyPixelShader: {
  69986. name: string;
  69987. shader: string;
  69988. };
  69989. }
  69990. declare module BABYLON {
  69991. /** @hidden */
  69992. export var skyVertexShader: {
  69993. name: string;
  69994. shader: string;
  69995. };
  69996. }
  69997. declare module BABYLON {
  69998. /**
  69999. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  70000. * @see https://doc.babylonjs.com/extensions/sky
  70001. */
  70002. export class SkyMaterial extends BABYLON.PushMaterial {
  70003. /**
  70004. * Defines the overall luminance of sky in interval ]0, 1[.
  70005. */
  70006. luminance: number;
  70007. /**
  70008. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  70009. */
  70010. turbidity: number;
  70011. /**
  70012. * Defines the sky appearance (light intensity).
  70013. */
  70014. rayleigh: number;
  70015. /**
  70016. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  70017. */
  70018. mieCoefficient: number;
  70019. /**
  70020. * Defines the amount of haze particles following the Mie scattering theory.
  70021. */
  70022. mieDirectionalG: number;
  70023. /**
  70024. * Defines the distance of the sun according to the active scene camera.
  70025. */
  70026. distance: number;
  70027. /**
  70028. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  70029. * "inclined".
  70030. */
  70031. inclination: number;
  70032. /**
  70033. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  70034. * an object direction and a reference direction.
  70035. */
  70036. azimuth: number;
  70037. /**
  70038. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  70039. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  70040. */
  70041. sunPosition: BABYLON.Vector3;
  70042. /**
  70043. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  70044. * .sunPosition property.
  70045. */
  70046. useSunPosition: boolean;
  70047. /**
  70048. * Defines an offset vector used to get a horizon offset.
  70049. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  70050. */
  70051. cameraOffset: BABYLON.Vector3;
  70052. private _cameraPosition;
  70053. private _renderId;
  70054. /**
  70055. * Instantiates a new sky material.
  70056. * This material allows to create dynamic and texture free
  70057. * effects for skyboxes by taking care of the atmosphere state.
  70058. * @see https://doc.babylonjs.com/extensions/sky
  70059. * @param name Define the name of the material in the scene
  70060. * @param scene Define the scene the material belong to
  70061. */
  70062. constructor(name: string, scene: BABYLON.Scene);
  70063. /**
  70064. * Specifies if the material will require alpha blending
  70065. * @returns a boolean specifying if alpha blending is needed
  70066. */
  70067. needAlphaBlending(): boolean;
  70068. /**
  70069. * Specifies if this material should be rendered in alpha test mode
  70070. * @returns false as the sky material doesn't need alpha testing.
  70071. */
  70072. needAlphaTesting(): boolean;
  70073. /**
  70074. * Get the texture used for alpha test purpose.
  70075. * @returns null as the sky material has no texture.
  70076. */
  70077. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70078. /**
  70079. * Get if the submesh is ready to be used and all its information available.
  70080. * Child classes can use it to update shaders
  70081. * @param mesh defines the mesh to check
  70082. * @param subMesh defines which submesh to check
  70083. * @param useInstances specifies that instances should be used
  70084. * @returns a boolean indicating that the submesh is ready or not
  70085. */
  70086. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70087. /**
  70088. * Binds the submesh to this material by preparing the effect and shader to draw
  70089. * @param world defines the world transformation matrix
  70090. * @param mesh defines the mesh containing the submesh
  70091. * @param subMesh defines the submesh to bind the material to
  70092. */
  70093. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70094. /**
  70095. * Get the list of animatables in the material.
  70096. * @returns the list of animatables object used in the material
  70097. */
  70098. getAnimatables(): BABYLON.IAnimatable[];
  70099. /**
  70100. * Disposes the material
  70101. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  70102. */
  70103. dispose(forceDisposeEffect?: boolean): void;
  70104. /**
  70105. * Makes a duplicate of the material, and gives it a new name
  70106. * @param name defines the new name for the duplicated material
  70107. * @returns the cloned material
  70108. */
  70109. clone(name: string): SkyMaterial;
  70110. /**
  70111. * Serializes this material in a JSON representation
  70112. * @returns the serialized material object
  70113. */
  70114. serialize(): any;
  70115. /**
  70116. * Gets the current class name of the material e.g. "SkyMaterial"
  70117. * Mainly use in serialization.
  70118. * @returns the class name
  70119. */
  70120. getClassName(): string;
  70121. /**
  70122. * Creates a sky material from parsed material data
  70123. * @param source defines the JSON representation of the material
  70124. * @param scene defines the hosting scene
  70125. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70126. * @returns a new sky material
  70127. */
  70128. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  70129. }
  70130. }
  70131. declare module BABYLON {
  70132. /** @hidden */
  70133. export var terrainPixelShader: {
  70134. name: string;
  70135. shader: string;
  70136. };
  70137. }
  70138. declare module BABYLON {
  70139. /** @hidden */
  70140. export var terrainVertexShader: {
  70141. name: string;
  70142. shader: string;
  70143. };
  70144. }
  70145. declare module BABYLON {
  70146. export class TerrainMaterial extends BABYLON.PushMaterial {
  70147. private _mixTexture;
  70148. mixTexture: BABYLON.BaseTexture;
  70149. private _diffuseTexture1;
  70150. diffuseTexture1: BABYLON.Texture;
  70151. private _diffuseTexture2;
  70152. diffuseTexture2: BABYLON.Texture;
  70153. private _diffuseTexture3;
  70154. diffuseTexture3: BABYLON.Texture;
  70155. private _bumpTexture1;
  70156. bumpTexture1: BABYLON.Texture;
  70157. private _bumpTexture2;
  70158. bumpTexture2: BABYLON.Texture;
  70159. private _bumpTexture3;
  70160. bumpTexture3: BABYLON.Texture;
  70161. diffuseColor: BABYLON.Color3;
  70162. specularColor: BABYLON.Color3;
  70163. specularPower: number;
  70164. private _disableLighting;
  70165. disableLighting: boolean;
  70166. private _maxSimultaneousLights;
  70167. maxSimultaneousLights: number;
  70168. private _renderId;
  70169. constructor(name: string, scene: BABYLON.Scene);
  70170. needAlphaBlending(): boolean;
  70171. needAlphaTesting(): boolean;
  70172. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70173. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70174. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70175. getAnimatables(): BABYLON.IAnimatable[];
  70176. getActiveTextures(): BABYLON.BaseTexture[];
  70177. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70178. dispose(forceDisposeEffect?: boolean): void;
  70179. clone(name: string): TerrainMaterial;
  70180. serialize(): any;
  70181. getClassName(): string;
  70182. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  70183. }
  70184. }
  70185. declare module BABYLON {
  70186. /** @hidden */
  70187. export var triplanarPixelShader: {
  70188. name: string;
  70189. shader: string;
  70190. };
  70191. }
  70192. declare module BABYLON {
  70193. /** @hidden */
  70194. export var triplanarVertexShader: {
  70195. name: string;
  70196. shader: string;
  70197. };
  70198. }
  70199. declare module BABYLON {
  70200. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  70201. mixTexture: BABYLON.BaseTexture;
  70202. private _diffuseTextureX;
  70203. diffuseTextureX: BABYLON.BaseTexture;
  70204. private _diffuseTextureY;
  70205. diffuseTextureY: BABYLON.BaseTexture;
  70206. private _diffuseTextureZ;
  70207. diffuseTextureZ: BABYLON.BaseTexture;
  70208. private _normalTextureX;
  70209. normalTextureX: BABYLON.BaseTexture;
  70210. private _normalTextureY;
  70211. normalTextureY: BABYLON.BaseTexture;
  70212. private _normalTextureZ;
  70213. normalTextureZ: BABYLON.BaseTexture;
  70214. tileSize: number;
  70215. diffuseColor: BABYLON.Color3;
  70216. specularColor: BABYLON.Color3;
  70217. specularPower: number;
  70218. private _disableLighting;
  70219. disableLighting: boolean;
  70220. private _maxSimultaneousLights;
  70221. maxSimultaneousLights: number;
  70222. private _renderId;
  70223. constructor(name: string, scene: BABYLON.Scene);
  70224. needAlphaBlending(): boolean;
  70225. needAlphaTesting(): boolean;
  70226. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70227. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70228. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70229. getAnimatables(): BABYLON.IAnimatable[];
  70230. getActiveTextures(): BABYLON.BaseTexture[];
  70231. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70232. dispose(forceDisposeEffect?: boolean): void;
  70233. clone(name: string): TriPlanarMaterial;
  70234. serialize(): any;
  70235. getClassName(): string;
  70236. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  70237. }
  70238. }
  70239. declare module BABYLON {
  70240. /** @hidden */
  70241. export var waterPixelShader: {
  70242. name: string;
  70243. shader: string;
  70244. };
  70245. }
  70246. declare module BABYLON {
  70247. /** @hidden */
  70248. export var waterVertexShader: {
  70249. name: string;
  70250. shader: string;
  70251. };
  70252. }
  70253. declare module BABYLON {
  70254. export class WaterMaterial extends BABYLON.PushMaterial {
  70255. renderTargetSize: BABYLON.Vector2;
  70256. private _bumpTexture;
  70257. bumpTexture: BABYLON.BaseTexture;
  70258. diffuseColor: BABYLON.Color3;
  70259. specularColor: BABYLON.Color3;
  70260. specularPower: number;
  70261. private _disableLighting;
  70262. disableLighting: boolean;
  70263. private _maxSimultaneousLights;
  70264. maxSimultaneousLights: number;
  70265. /**
  70266. * @param {number}: Represents the wind force
  70267. */
  70268. windForce: number;
  70269. /**
  70270. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  70271. */
  70272. windDirection: BABYLON.Vector2;
  70273. /**
  70274. * @param {number}: Wave height, represents the height of the waves
  70275. */
  70276. waveHeight: number;
  70277. /**
  70278. * @param {number}: Bump height, represents the bump height related to the bump map
  70279. */
  70280. bumpHeight: number;
  70281. /**
  70282. * @param {boolean}: Add a smaller moving bump to less steady waves.
  70283. */
  70284. private _bumpSuperimpose;
  70285. bumpSuperimpose: boolean;
  70286. /**
  70287. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  70288. */
  70289. private _fresnelSeparate;
  70290. fresnelSeparate: boolean;
  70291. /**
  70292. * @param {boolean}: bump Waves modify the reflection.
  70293. */
  70294. private _bumpAffectsReflection;
  70295. bumpAffectsReflection: boolean;
  70296. /**
  70297. * @param {number}: The water color blended with the refraction (near)
  70298. */
  70299. waterColor: BABYLON.Color3;
  70300. /**
  70301. * @param {number}: The blend factor related to the water color
  70302. */
  70303. colorBlendFactor: number;
  70304. /**
  70305. * @param {number}: The water color blended with the reflection (far)
  70306. */
  70307. waterColor2: BABYLON.Color3;
  70308. /**
  70309. * @param {number}: The blend factor related to the water color (reflection, far)
  70310. */
  70311. colorBlendFactor2: number;
  70312. /**
  70313. * @param {number}: Represents the maximum length of a wave
  70314. */
  70315. waveLength: number;
  70316. /**
  70317. * @param {number}: Defines the waves speed
  70318. */
  70319. waveSpeed: number;
  70320. /**
  70321. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  70322. * will avoid calculating useless pixels in the pixel shader of the water material.
  70323. */
  70324. disableClipPlane: boolean;
  70325. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  70326. private _mesh;
  70327. private _refractionRTT;
  70328. private _reflectionRTT;
  70329. private _reflectionTransform;
  70330. private _lastTime;
  70331. private _lastDeltaTime;
  70332. private _renderId;
  70333. private _useLogarithmicDepth;
  70334. private _waitingRenderList;
  70335. private _imageProcessingConfiguration;
  70336. private _imageProcessingObserver;
  70337. /**
  70338. * Gets a boolean indicating that current material needs to register RTT
  70339. */
  70340. readonly hasRenderTargetTextures: boolean;
  70341. /**
  70342. * Constructor
  70343. */
  70344. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  70345. useLogarithmicDepth: boolean;
  70346. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  70347. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  70348. addToRenderList(node: any): void;
  70349. enableRenderTargets(enable: boolean): void;
  70350. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  70351. readonly renderTargetsEnabled: boolean;
  70352. needAlphaBlending(): boolean;
  70353. needAlphaTesting(): boolean;
  70354. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70355. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70356. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70357. private _createRenderTargets;
  70358. getAnimatables(): BABYLON.IAnimatable[];
  70359. getActiveTextures(): BABYLON.BaseTexture[];
  70360. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70361. dispose(forceDisposeEffect?: boolean): void;
  70362. clone(name: string): WaterMaterial;
  70363. serialize(): any;
  70364. getClassName(): string;
  70365. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  70366. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  70367. }
  70368. }
  70369. declare module BABYLON {
  70370. /** @hidden */
  70371. export var asciiartPixelShader: {
  70372. name: string;
  70373. shader: string;
  70374. };
  70375. }
  70376. declare module BABYLON {
  70377. /**
  70378. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  70379. *
  70380. * It basically takes care rendering the font front the given font size to a texture.
  70381. * This is used later on in the postprocess.
  70382. */
  70383. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  70384. private _font;
  70385. private _text;
  70386. private _charSize;
  70387. /**
  70388. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  70389. */
  70390. readonly charSize: number;
  70391. /**
  70392. * Create a new instance of the Ascii Art FontTexture class
  70393. * @param name the name of the texture
  70394. * @param font the font to use, use the W3C CSS notation
  70395. * @param text the caracter set to use in the rendering.
  70396. * @param scene the scene that owns the texture
  70397. */
  70398. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  70399. /**
  70400. * Gets the max char width of a font.
  70401. * @param font the font to use, use the W3C CSS notation
  70402. * @return the max char width
  70403. */
  70404. private getFontWidth;
  70405. /**
  70406. * Gets the max char height of a font.
  70407. * @param font the font to use, use the W3C CSS notation
  70408. * @return the max char height
  70409. */
  70410. private getFontHeight;
  70411. /**
  70412. * Clones the current AsciiArtTexture.
  70413. * @return the clone of the texture.
  70414. */
  70415. clone(): AsciiArtFontTexture;
  70416. /**
  70417. * Parses a json object representing the texture and returns an instance of it.
  70418. * @param source the source JSON representation
  70419. * @param scene the scene to create the texture for
  70420. * @return the parsed texture
  70421. */
  70422. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  70423. }
  70424. /**
  70425. * Option available in the Ascii Art Post Process.
  70426. */
  70427. export interface IAsciiArtPostProcessOptions {
  70428. /**
  70429. * The font to use following the w3c font definition.
  70430. */
  70431. font?: string;
  70432. /**
  70433. * The character set to use in the postprocess.
  70434. */
  70435. characterSet?: string;
  70436. /**
  70437. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  70438. * This number is defined between 0 and 1;
  70439. */
  70440. mixToTile?: number;
  70441. /**
  70442. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  70443. * This number is defined between 0 and 1;
  70444. */
  70445. mixToNormal?: number;
  70446. }
  70447. /**
  70448. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  70449. *
  70450. * Simmply add it to your scene and let the nerd that lives in you have fun.
  70451. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  70452. */
  70453. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  70454. /**
  70455. * The font texture used to render the char in the post process.
  70456. */
  70457. private _asciiArtFontTexture;
  70458. /**
  70459. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  70460. * This number is defined between 0 and 1;
  70461. */
  70462. mixToTile: number;
  70463. /**
  70464. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  70465. * This number is defined between 0 and 1;
  70466. */
  70467. mixToNormal: number;
  70468. /**
  70469. * Instantiates a new Ascii Art Post Process.
  70470. * @param name the name to give to the postprocess
  70471. * @camera the camera to apply the post process to.
  70472. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  70473. */
  70474. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  70475. }
  70476. }
  70477. declare module BABYLON {
  70478. /** @hidden */
  70479. export var digitalrainPixelShader: {
  70480. name: string;
  70481. shader: string;
  70482. };
  70483. }
  70484. declare module BABYLON {
  70485. /**
  70486. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  70487. *
  70488. * It basically takes care rendering the font front the given font size to a texture.
  70489. * This is used later on in the postprocess.
  70490. */
  70491. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  70492. private _font;
  70493. private _text;
  70494. private _charSize;
  70495. /**
  70496. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  70497. */
  70498. readonly charSize: number;
  70499. /**
  70500. * Create a new instance of the Digital Rain FontTexture class
  70501. * @param name the name of the texture
  70502. * @param font the font to use, use the W3C CSS notation
  70503. * @param text the caracter set to use in the rendering.
  70504. * @param scene the scene that owns the texture
  70505. */
  70506. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  70507. /**
  70508. * Gets the max char width of a font.
  70509. * @param font the font to use, use the W3C CSS notation
  70510. * @return the max char width
  70511. */
  70512. private getFontWidth;
  70513. /**
  70514. * Gets the max char height of a font.
  70515. * @param font the font to use, use the W3C CSS notation
  70516. * @return the max char height
  70517. */
  70518. private getFontHeight;
  70519. /**
  70520. * Clones the current DigitalRainFontTexture.
  70521. * @return the clone of the texture.
  70522. */
  70523. clone(): DigitalRainFontTexture;
  70524. /**
  70525. * Parses a json object representing the texture and returns an instance of it.
  70526. * @param source the source JSON representation
  70527. * @param scene the scene to create the texture for
  70528. * @return the parsed texture
  70529. */
  70530. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  70531. }
  70532. /**
  70533. * Option available in the Digital Rain Post Process.
  70534. */
  70535. export interface IDigitalRainPostProcessOptions {
  70536. /**
  70537. * The font to use following the w3c font definition.
  70538. */
  70539. font?: string;
  70540. /**
  70541. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  70542. * This number is defined between 0 and 1;
  70543. */
  70544. mixToTile?: number;
  70545. /**
  70546. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  70547. * This number is defined between 0 and 1;
  70548. */
  70549. mixToNormal?: number;
  70550. }
  70551. /**
  70552. * DigitalRainPostProcess helps rendering everithing in digital rain.
  70553. *
  70554. * Simmply add it to your scene and let the nerd that lives in you have fun.
  70555. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  70556. */
  70557. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  70558. /**
  70559. * The font texture used to render the char in the post process.
  70560. */
  70561. private _digitalRainFontTexture;
  70562. /**
  70563. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  70564. * This number is defined between 0 and 1;
  70565. */
  70566. mixToTile: number;
  70567. /**
  70568. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  70569. * This number is defined between 0 and 1;
  70570. */
  70571. mixToNormal: number;
  70572. /**
  70573. * Instantiates a new Digital Rain Post Process.
  70574. * @param name the name to give to the postprocess
  70575. * @camera the camera to apply the post process to.
  70576. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  70577. */
  70578. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  70579. }
  70580. }
  70581. declare module BABYLON {
  70582. /** @hidden */
  70583. export var oceanPostProcessPixelShader: {
  70584. name: string;
  70585. shader: string;
  70586. };
  70587. }
  70588. declare module BABYLON {
  70589. /**
  70590. * Option available in the Ocean Post Process.
  70591. */
  70592. export interface IOceanPostProcessOptions {
  70593. /**
  70594. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  70595. */
  70596. reflectionSize?: number | {
  70597. width: number;
  70598. height: number;
  70599. } | {
  70600. ratio: number;
  70601. };
  70602. /**
  70603. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  70604. */
  70605. refractionSize?: number | {
  70606. width: number;
  70607. height: number;
  70608. } | {
  70609. ratio: number;
  70610. };
  70611. }
  70612. /**
  70613. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  70614. *
  70615. * Simmply add it to your scene and let the nerd that lives in you have fun.
  70616. * Example usage:
  70617. * var pp = new OceanPostProcess("myOcean", camera);
  70618. * pp.reflectionEnabled = true;
  70619. * pp.refractionEnabled = true;
  70620. */
  70621. export class OceanPostProcess extends BABYLON.PostProcess {
  70622. /**
  70623. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  70624. */
  70625. /**
  70626. * Sets weither or not the real-time reflection is enabled on the ocean.
  70627. * Is set to true, the reflection mirror texture will be used as reflection texture.
  70628. */
  70629. reflectionEnabled: boolean;
  70630. /**
  70631. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  70632. */
  70633. /**
  70634. * Sets weither or not the real-time refraction is enabled on the ocean.
  70635. * Is set to true, the refraction render target texture will be used as refraction texture.
  70636. */
  70637. refractionEnabled: boolean;
  70638. /**
  70639. * Gets wether or not the post-processes is supported by the running hardware.
  70640. * This requires draw buffer supports.
  70641. */
  70642. readonly isSupported: boolean;
  70643. /**
  70644. * This is the reflection mirror texture used to display reflections on the ocean.
  70645. * By default, render list is empty.
  70646. */
  70647. reflectionTexture: BABYLON.MirrorTexture;
  70648. /**
  70649. * This is the refraction render target texture used to display refraction on the ocean.
  70650. * By default, render list is empty.
  70651. */
  70652. refractionTexture: BABYLON.RenderTargetTexture;
  70653. private _time;
  70654. private _cameraRotation;
  70655. private _cameraViewMatrix;
  70656. private _reflectionEnabled;
  70657. private _refractionEnabled;
  70658. private _geometryRenderer;
  70659. /**
  70660. * Instantiates a new Ocean Post Process.
  70661. * @param name the name to give to the postprocess.
  70662. * @camera the camera to apply the post process to.
  70663. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  70664. */
  70665. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  70666. /**
  70667. * Returns the appropriate defines according to the current configuration.
  70668. */
  70669. private _getDefines;
  70670. /**
  70671. * Computes the current camera rotation as the shader requires a camera rotation.
  70672. */
  70673. private _computeCameraRotation;
  70674. }
  70675. }
  70676. declare module BABYLON {
  70677. /** @hidden */
  70678. export var brickProceduralTexturePixelShader: {
  70679. name: string;
  70680. shader: string;
  70681. };
  70682. }
  70683. declare module BABYLON {
  70684. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  70685. private _numberOfBricksHeight;
  70686. private _numberOfBricksWidth;
  70687. private _jointColor;
  70688. private _brickColor;
  70689. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70690. updateShaderUniforms(): void;
  70691. numberOfBricksHeight: number;
  70692. numberOfBricksWidth: number;
  70693. jointColor: BABYLON.Color3;
  70694. brickColor: BABYLON.Color3;
  70695. /**
  70696. * Serializes this brick procedural texture
  70697. * @returns a serialized brick procedural texture object
  70698. */
  70699. serialize(): any;
  70700. /**
  70701. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  70702. * @param parsedTexture defines parsed texture data
  70703. * @param scene defines the current scene
  70704. * @param rootUrl defines the root URL containing brick procedural texture information
  70705. * @returns a parsed Brick Procedural BABYLON.Texture
  70706. */
  70707. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  70708. }
  70709. }
  70710. declare module BABYLON {
  70711. /** @hidden */
  70712. export var cloudProceduralTexturePixelShader: {
  70713. name: string;
  70714. shader: string;
  70715. };
  70716. }
  70717. declare module BABYLON {
  70718. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  70719. private _skyColor;
  70720. private _cloudColor;
  70721. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70722. updateShaderUniforms(): void;
  70723. skyColor: BABYLON.Color4;
  70724. cloudColor: BABYLON.Color4;
  70725. /**
  70726. * Serializes this cloud procedural texture
  70727. * @returns a serialized cloud procedural texture object
  70728. */
  70729. serialize(): any;
  70730. /**
  70731. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  70732. * @param parsedTexture defines parsed texture data
  70733. * @param scene defines the current scene
  70734. * @param rootUrl defines the root URL containing cloud procedural texture information
  70735. * @returns a parsed Cloud Procedural BABYLON.Texture
  70736. */
  70737. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  70738. }
  70739. }
  70740. declare module BABYLON {
  70741. /** @hidden */
  70742. export var fireProceduralTexturePixelShader: {
  70743. name: string;
  70744. shader: string;
  70745. };
  70746. }
  70747. declare module BABYLON {
  70748. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  70749. private _time;
  70750. private _speed;
  70751. private _autoGenerateTime;
  70752. private _fireColors;
  70753. private _alphaThreshold;
  70754. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70755. updateShaderUniforms(): void;
  70756. render(useCameraPostProcess?: boolean): void;
  70757. static readonly PurpleFireColors: BABYLON.Color3[];
  70758. static readonly GreenFireColors: BABYLON.Color3[];
  70759. static readonly RedFireColors: BABYLON.Color3[];
  70760. static readonly BlueFireColors: BABYLON.Color3[];
  70761. autoGenerateTime: boolean;
  70762. fireColors: BABYLON.Color3[];
  70763. time: number;
  70764. speed: BABYLON.Vector2;
  70765. alphaThreshold: number;
  70766. /**
  70767. * Serializes this fire procedural texture
  70768. * @returns a serialized fire procedural texture object
  70769. */
  70770. serialize(): any;
  70771. /**
  70772. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  70773. * @param parsedTexture defines parsed texture data
  70774. * @param scene defines the current scene
  70775. * @param rootUrl defines the root URL containing fire procedural texture information
  70776. * @returns a parsed Fire Procedural BABYLON.Texture
  70777. */
  70778. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  70779. }
  70780. }
  70781. declare module BABYLON {
  70782. /** @hidden */
  70783. export var grassProceduralTexturePixelShader: {
  70784. name: string;
  70785. shader: string;
  70786. };
  70787. }
  70788. declare module BABYLON {
  70789. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  70790. private _grassColors;
  70791. private _groundColor;
  70792. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70793. updateShaderUniforms(): void;
  70794. grassColors: BABYLON.Color3[];
  70795. groundColor: BABYLON.Color3;
  70796. /**
  70797. * Serializes this grass procedural texture
  70798. * @returns a serialized grass procedural texture object
  70799. */
  70800. serialize(): any;
  70801. /**
  70802. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  70803. * @param parsedTexture defines parsed texture data
  70804. * @param scene defines the current scene
  70805. * @param rootUrl defines the root URL containing grass procedural texture information
  70806. * @returns a parsed Grass Procedural BABYLON.Texture
  70807. */
  70808. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  70809. }
  70810. }
  70811. declare module BABYLON {
  70812. /** @hidden */
  70813. export var marbleProceduralTexturePixelShader: {
  70814. name: string;
  70815. shader: string;
  70816. };
  70817. }
  70818. declare module BABYLON {
  70819. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  70820. private _numberOfTilesHeight;
  70821. private _numberOfTilesWidth;
  70822. private _amplitude;
  70823. private _jointColor;
  70824. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70825. updateShaderUniforms(): void;
  70826. numberOfTilesHeight: number;
  70827. amplitude: number;
  70828. numberOfTilesWidth: number;
  70829. jointColor: BABYLON.Color3;
  70830. /**
  70831. * Serializes this marble procedural texture
  70832. * @returns a serialized marble procedural texture object
  70833. */
  70834. serialize(): any;
  70835. /**
  70836. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  70837. * @param parsedTexture defines parsed texture data
  70838. * @param scene defines the current scene
  70839. * @param rootUrl defines the root URL containing marble procedural texture information
  70840. * @returns a parsed Marble Procedural BABYLON.Texture
  70841. */
  70842. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  70843. }
  70844. }
  70845. declare module BABYLON {
  70846. /** @hidden */
  70847. export var normalMapProceduralTexturePixelShader: {
  70848. name: string;
  70849. shader: string;
  70850. };
  70851. }
  70852. declare module BABYLON {
  70853. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  70854. private _baseTexture;
  70855. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70856. updateShaderUniforms(): void;
  70857. render(useCameraPostProcess?: boolean): void;
  70858. resize(size: any, generateMipMaps: any): void;
  70859. baseTexture: BABYLON.Texture;
  70860. /**
  70861. * Serializes this normal map procedural texture
  70862. * @returns a serialized normal map procedural texture object
  70863. */
  70864. serialize(): any;
  70865. /**
  70866. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  70867. * @param parsedTexture defines parsed texture data
  70868. * @param scene defines the current scene
  70869. * @param rootUrl defines the root URL containing normal map procedural texture information
  70870. * @returns a parsed Normal Map Procedural BABYLON.Texture
  70871. */
  70872. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  70873. }
  70874. }
  70875. declare module BABYLON {
  70876. /** @hidden */
  70877. export var perlinNoiseProceduralTexturePixelShader: {
  70878. name: string;
  70879. shader: string;
  70880. };
  70881. }
  70882. declare module BABYLON {
  70883. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  70884. time: number;
  70885. timeScale: number;
  70886. translationSpeed: number;
  70887. private _currentTranslation;
  70888. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70889. updateShaderUniforms(): void;
  70890. render(useCameraPostProcess?: boolean): void;
  70891. resize(size: any, generateMipMaps: any): void;
  70892. /**
  70893. * Serializes this perlin noise procedural texture
  70894. * @returns a serialized perlin noise procedural texture object
  70895. */
  70896. serialize(): any;
  70897. /**
  70898. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  70899. * @param parsedTexture defines parsed texture data
  70900. * @param scene defines the current scene
  70901. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  70902. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  70903. */
  70904. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  70905. }
  70906. }
  70907. declare module BABYLON {
  70908. /** @hidden */
  70909. export var roadProceduralTexturePixelShader: {
  70910. name: string;
  70911. shader: string;
  70912. };
  70913. }
  70914. declare module BABYLON {
  70915. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  70916. private _roadColor;
  70917. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70918. updateShaderUniforms(): void;
  70919. roadColor: BABYLON.Color3;
  70920. /**
  70921. * Serializes this road procedural texture
  70922. * @returns a serialized road procedural texture object
  70923. */
  70924. serialize(): any;
  70925. /**
  70926. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  70927. * @param parsedTexture defines parsed texture data
  70928. * @param scene defines the current scene
  70929. * @param rootUrl defines the root URL containing road procedural texture information
  70930. * @returns a parsed Road Procedural BABYLON.Texture
  70931. */
  70932. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  70933. }
  70934. }
  70935. declare module BABYLON {
  70936. /** @hidden */
  70937. export var starfieldProceduralTexturePixelShader: {
  70938. name: string;
  70939. shader: string;
  70940. };
  70941. }
  70942. declare module BABYLON {
  70943. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  70944. private _time;
  70945. private _alpha;
  70946. private _beta;
  70947. private _zoom;
  70948. private _formuparam;
  70949. private _stepsize;
  70950. private _tile;
  70951. private _brightness;
  70952. private _darkmatter;
  70953. private _distfading;
  70954. private _saturation;
  70955. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70956. updateShaderUniforms(): void;
  70957. time: number;
  70958. alpha: number;
  70959. beta: number;
  70960. formuparam: number;
  70961. stepsize: number;
  70962. zoom: number;
  70963. tile: number;
  70964. brightness: number;
  70965. darkmatter: number;
  70966. distfading: number;
  70967. saturation: number;
  70968. /**
  70969. * Serializes this starfield procedural texture
  70970. * @returns a serialized starfield procedural texture object
  70971. */
  70972. serialize(): any;
  70973. /**
  70974. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  70975. * @param parsedTexture defines parsed texture data
  70976. * @param scene defines the current scene
  70977. * @param rootUrl defines the root URL containing startfield procedural texture information
  70978. * @returns a parsed Starfield Procedural BABYLON.Texture
  70979. */
  70980. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  70981. }
  70982. }
  70983. declare module BABYLON {
  70984. /** @hidden */
  70985. export var woodProceduralTexturePixelShader: {
  70986. name: string;
  70987. shader: string;
  70988. };
  70989. }
  70990. declare module BABYLON {
  70991. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  70992. private _ampScale;
  70993. private _woodColor;
  70994. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70995. updateShaderUniforms(): void;
  70996. ampScale: number;
  70997. woodColor: BABYLON.Color3;
  70998. /**
  70999. * Serializes this wood procedural texture
  71000. * @returns a serialized wood procedural texture object
  71001. */
  71002. serialize(): any;
  71003. /**
  71004. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  71005. * @param parsedTexture defines parsed texture data
  71006. * @param scene defines the current scene
  71007. * @param rootUrl defines the root URL containing wood procedural texture information
  71008. * @returns a parsed Wood Procedural BABYLON.Texture
  71009. */
  71010. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  71011. }
  71012. }